Merge pull request #137 from eisnerd/bug-xpath-reverse-axes-497017
[mono.git] / mcs / tools / compiler-tester / compiler-tester.cs
index 8715ca4d7b121fc6e8bdf9ad2986410c18ba9a2a..07bea6c36c891725f2bd7852ae8aec8f2ded9dd5 100644 (file)
@@ -35,6 +35,7 @@ using System.Reflection;
 using System.Text;
 using System.Collections;
 using System.Xml;
+using System.Collections.Generic;
 
 namespace TestRunner {
 
@@ -725,13 +726,13 @@ namespace TestRunner {
                                        return true;
 
                                if (md.ILSize > il_size) {
-                                       checker.LogFileLine (test.FileName, "{0} (code size reduction {1} -> {2})", m_name, md.ILSize, il_size);
+                                       checker.LogFileLine (test.FileName, "{0} (code size reduction {1} -> {2})", decl_type + ": " + m_name, md.ILSize, il_size);
                                        md.ILSize = il_size;
                                        return true;
                                }
 
                                checker.HandleFailure (test.FileName, PositiveChecker.TestResult.ILError,
-                                       string.Format ("{0} (code size {1} -> {2})", m_name, md.ILSize, il_size));
+                                       string.Format ("{0} (code size {1} -> {2})", decl_type + ": " + m_name, md.ILSize, il_size));
 
                                md.ILSize = il_size;
 
@@ -816,6 +817,7 @@ namespace TestRunner {
                        }
 
                        AppDomain domain = null;
+#if !NET_2_1
                        if (safe_execution) {
                                // Create a new AppDomain, with the current directory as the base.
                                AppDomainSetup setupInfo = new AppDomainSetup ();
@@ -823,13 +825,15 @@ namespace TestRunner {
                                setupInfo.LoaderOptimization = LoaderOptimization.SingleDomain;
                                domain = AppDomain.CreateDomain (Path.GetFileNameWithoutExtension (file), null, setupInfo);
                        }
-
+#endif
                        try {
                                DomainTester tester;
                                try {
+#if !NET_2_1
                                        if (domain != null)
                                                tester = (DomainTester) domain.CreateInstanceAndUnwrap (typeof (PositiveChecker).Assembly.FullName, typeof (DomainTester).FullName);
                                        else
+#endif
                                                tester = new DomainTester ();
 
                                        if (!tester.Test (file))
@@ -1138,7 +1142,7 @@ namespace TestRunner {
                        ArrayList ld = new ArrayList ();
                        CompilerError result = CompilerError.Missing;
                        while (line != null) {
-                               if (ld.Contains (line)) {
+                               if (ld.Contains (line) && result == CompilerError.Expected) {
                                        if (line.IndexOf ("Location of the symbol related to previous") == -1)
                                                return CompilerError.Duplicate;
                                }
@@ -1149,8 +1153,13 @@ namespace TestRunner {
                                                if (check_msg) {
                                                        int first = line.IndexOf (':');
                                                        int second = line.IndexOf (':', first + 1);
-                                                       if (second == -1 || !check_error_line)
+                                                       if (line.IndexOf ("Warning as Error: ", first, StringComparison.Ordinal) > 0) {
+                                                               if (check_error_line) {
+                                                                       second = line.IndexOf (':', second + 1);
+                                                               }
+                                                       } else if (second == -1 || !check_error_line) {
                                                                second = first;
+                                                       }
 
                                                        string msg = line.Substring (second + 1).TrimEnd ('.').Trim ();
                                                        if (msg != expected_message && msg != expected_message.Replace ('`', '\'')) {
@@ -1317,14 +1326,17 @@ namespace TestRunner {
                        }
 
                        Checker checker;
+                       bool positive;
                        switch (mode) {
                                case "neg":
                                        checker = new NegativeChecker (tester, true);
+                                       positive = false;
                                        break;
                                case "pos":
                                        string iltest;
                                        GetOption ("il", args, false, out iltest);
                                        checker = new PositiveChecker (tester, iltest);
+                                       positive = true;
 
                                        if (iltest != null && GetOption ("update-il", args, false, out temp)) {
                                                ((PositiveChecker) checker).UpdateVerificationDataFile = true;
@@ -1356,14 +1368,41 @@ namespace TestRunner {
                                return 1;
                        }
 
-                       string [] files = Directory.GetFiles (".", test_pattern);
-                       if (files.Length == 0) {
+                       var files = new List<string> ();
+                       switch (test_pattern) {
+                       case "v1":
+                               files.AddRange (Directory.GetFiles (".", positive ? "test*.cs" : "cs*.cs"));
+                               break;
+                       case "v2":
+                               files.AddRange (Directory.GetFiles (".", positive ? "gtest*.cs" : "gcs*.cs"));
+                               goto case "v1";
+                       case "v4":
+                               files.AddRange (Directory.GetFiles (".", positive ? "dtest*.cs" : "dcs*.cs"));
+                               goto case "v2";
+                       default:
+                               files.AddRange (Directory.GetFiles (".", test_pattern));
+                               break;
+                       }
+
+                       if (files.Count == 0) {
                                Console.Error.WriteLine ("No files matching `{0}' found", test_pattern);
                                return 2;
                        }
 
                        checker.Initialize ();
+/*
+                       files.Sort ((a, b) => {
+                               if (a.EndsWith ("-lib.cs", StringComparison.Ordinal)) {
+                                       if (!b.EndsWith ("-lib.cs", StringComparison.Ordinal))
+                                               return -1;
+                               } else if (b.EndsWith ("-lib.cs", StringComparison.Ordinal)) {
+                                       if (!a.EndsWith ("-lib.cs", StringComparison.Ordinal))
+                                               return 1;
+                               }
 
+                               return a.CompareTo (b);
+                       });
+*/
                        foreach (string s in files) {
                                string filename = Path.GetFileName (s);
                                if (Char.IsUpper (filename, 0)) { // Windows hack