Author: marek
Date: 2005-03-16 06:54:02 -0500 (Wed, 16 Mar 2005)
New Revision: 41889

Modified:
   trunk/mcs/errors/ChangeLog
   trunk/mcs/errors/TestRunner.cs
Log:
2005-03-16 Marek Safar <[EMAIL PROTECTED]>

        * TestRunner.cs: Add support for (no errors, ignore errors).

Modified: trunk/mcs/errors/ChangeLog
===================================================================
--- trunk/mcs/errors/ChangeLog  2005-03-16 11:35:49 UTC (rev 41888)
+++ trunk/mcs/errors/ChangeLog  2005-03-16 11:54:02 UTC (rev 41889)
@@ -1,3 +1,7 @@
+2005-03-16 Marek Safar <[EMAIL PROTECTED]>
+
+       * TestRunner.cs: Add support for (no errors, ignore errors).
+
 2005-03-16  Raja R Harinath  <[EMAIL PROTECTED]>
 
        * Makefile (RUNTEST_PL, test-multi-local): Remove, now that

Modified: trunk/mcs/errors/TestRunner.cs
===================================================================
--- trunk/mcs/errors/TestRunner.cs      2005-03-16 11:35:49 UTC (rev 41888)
+++ trunk/mcs/errors/TestRunner.cs      2005-03-16 11:54:02 UTC (rev 41889)
@@ -86,22 +86,37 @@
 
        class Tester {
 
+               enum CompilerError
+               {
+                       Expected,
+                       Wrong,
+                       Missing
+               }
+
                static ArrayList know_issues = new ArrayList ();
+               static ArrayList ignore_list = new ArrayList ();
+               static ArrayList no_error_list = new ArrayList ();
                static ArrayList regression = new ArrayList ();
 
                static int Main(string[] args) {
                        if (args.Length != 3) {
-                               Console.WriteLine ("Usage: TestRunner test-dir 
compiler know-issues");
+                               Console.WriteLine ("Usage: TestRunner 
test-pattern compiler know-issues");
                                return 1;
                        }
 
-                       string test_directory = args [0];
+                       string test_pattern = args [0];
                        string mcs = args [1];
                        string issue_file = args [2];
 
-                       string wrong_errors_file = Path.Combine 
(test_directory, issue_file);
-                       string[] files = Directory.GetFiles (test_directory, 
"cs*.cs");
+                       // THIS IS BUG #73763 workaround
+                       if (test_pattern == "1")
+                               test_pattern = "cs*.cs";
+                       else
+                               test_pattern = "*cs*.cs";
 
+                       string wrong_errors_file = issue_file;
+                       string[] files = Directory.GetFiles (".", test_pattern);
+
                        ReadWrongErrors (wrong_errors_file);
                        ITester tester;
                        try {
@@ -110,7 +125,7 @@
                        catch (Exception) {
                                Console.Error.WriteLine ("Switching to command 
line mode (compiler entry point was not found)");
                                if (!File.Exists (mcs)) {
-                                       Console.WriteLine ("ERROR: Tested 
compiler was not been found");
+                                       Console.WriteLine ("ERROR: Tested 
compiler was not found");
                                        return 1;
                                }
                                tester = new ProcessTester (mcs);
@@ -138,40 +153,43 @@
                                test_args [test_args.Length - 1] = s;
 
                                Console.Write ("...\t");
+
+                               if (ignore_list.Contains (filename)) {
+                                       Console.WriteLine ("NOT TESTED");
+                                       total--;
+                                       continue;
+                               }
+
                                try {
 
                                        bool result = tester.Invoke (test_args);
                                        if (result) {
-                                               PrintFailed (filename);
+                                               HandleFailure (filename, 
CompilerError.Missing);
                                                continue;
                                        }
 
                                        int end_char = filename.IndexOfAny (new 
char [] { '-', '.' } );
                                        string expected = filename.Substring 
(2, end_char - 2);
-                                       if (CheckCompilerError (expected, 
tester.Output)) {
+                                       CompilerError result_code = 
GetCompilerError (expected, tester.Output);
+                                       if (HandleFailure (filename, 
result_code)) {
                                                success++;
-
-                                               if (know_issues.Contains (s)) {
-                                                       Console.WriteLine 
("FIXED ISSUE");
-                                                       continue;
-                                               }
-                                               Console.WriteLine ("OK");
-                                               continue;
+                                       } else {
+                                               Console.WriteLine 
(tester.Output);
                                        }
-                                       PrintFailed (filename);
-                                       Console.WriteLine (tester.Output);
                                }
                                catch (Exception e) {
-                                       PrintFailed (filename);
+                                       HandleFailure (filename, 
CompilerError.Missing);
                                        Console.WriteLine (e.ToString ());
                                }
                        }
 
                        Console.WriteLine ("Done" + Environment.NewLine);
                        Console.WriteLine ("{0} correctly detected error cases 
({1:.##%})", success, (float) (success) / (float)total);
+
+                       know_issues.AddRange (no_error_list);
                        if (know_issues.Count > 0) {
                                Console.WriteLine ();
-                               Console.WriteLine (issue_file + " contains 
already fixed issues. Please remove");
+                               Console.WriteLine (issue_file + " contains {0} 
already fixed issues. Please remove", know_issues.Count);
                                foreach (string s in know_issues)
                                        Console.WriteLine (s);
                        }
@@ -185,50 +203,107 @@
                        return 0;
                }
 
-               static void ReadWrongErrors (string file) {
+               static void ReadWrongErrors (string file)
+               {
+                       const string ignored = "IGNORE";
+                       const string no_error = "NO ERROR";
+
                        using (StreamReader sr = new StreamReader (file)) {
-                               String line;
+                               string line;
                                while ((line = sr.ReadLine()) != null) {
                                        if (line.StartsWith ("#"))
                                                continue;
 
+                                       ArrayList active_cont = know_issues;
+
+                                       if (line.IndexOf (ignored) > 0)
+                                               active_cont = ignore_list;
+                                       else if (line.IndexOf (no_error) > 0)
+                                               active_cont = no_error_list;
+
                                        string file_name = line.Split (' ')[0];
                                        if (file_name.Length == 0)
                                                continue;
-                                       know_issues.Add (file_name);
+
+                                       active_cont.Add (file_name);
                                }
                        }
                }
 
-               static void PrintFailed (string file) {
-                       if (know_issues.Contains (file)) {
-                               Console.WriteLine ("KNOW ISSUE");
-                               know_issues.Remove (file);
-                               return;
+               static bool HandleFailure (string file, CompilerError status)
+               {
+                       switch (status) {
+                               case CompilerError.Expected:
+                                       if (know_issues.Contains (file) || 
no_error_list.Contains (file)) {
+                                               Console.WriteLine ("FIXED 
ISSUE");
+                                               return true;
+                                       }
+                                       Console.WriteLine ("OK");
+                                       return true;
+
+                               case CompilerError.Wrong:
+                                       if (know_issues.Contains (file)) {
+                                               Console.WriteLine ("KNOW 
ISSUE");
+                                               know_issues.Remove (file);
+                                               return false;
+                                       }
+                                       if (no_error_list.Contains (file)) {
+                                               Console.WriteLine ("REGRESSION 
(NO ERROR -> WRONG ERROR)");
+                                               no_error_list.Remove (file);
+                                       }
+                                       else {
+                                               Console.WriteLine ("REGRESSION 
(CORRECT ERROR -> WRONG ERROR)");
+                                       }
+
+                                       break;
+
+                               case CompilerError.Missing:
+                                       if (no_error_list.Contains (file)) {
+                                               Console.WriteLine ("KNOW 
ISSUE");
+                                               no_error_list.Remove (file);
+                                               return false;
+                                       }
+
+                                       if (know_issues.Contains (file)) {
+                                               Console.WriteLine ("REGRESSION 
(WRONG ERROR -> NO ERROR)");
+                                               know_issues.Remove (file);
+                                       }
+                                       else {
+                                               Console.WriteLine ("REGRESSION 
(CORRECT ERROR -> NO ERROR)");
+                                       }
+
+                                       break;
                        }
-                       Console.WriteLine ("REGRESSION");
-                       regression.Add (file);
+
+                       regression.Add (file);;
+                       return false;
                }
 
-               static bool CheckCompilerError (string expected, string buffer) 
{
-                       string tested_text = "error CS" + expected;
+               static CompilerError GetCompilerError (string expected, string 
buffer)
+               {
+                       const string error_prefix = "CS";
+                       const string ignored_error = "error CS5001";
+                       string tested_text = "error " + error_prefix + expected;
                        StringReader sr = new StringReader (buffer);
                        string line = sr.ReadLine ();
-                       int row = 0;
+                       bool any_error = false;
                        while (line != null) {
-                               row++;
-                               if (line.IndexOf (tested_text) != -1) {
-                                       //if (row > 1)
-                                       //      Console.WriteLine ("WARNING: 
Not reported as primary error");
-                                       return true;
-                               }
+
+                               if (line.IndexOf (tested_text) != -1)
+                                       return CompilerError.Expected;
+
+                               if (line.IndexOf (error_prefix) != -1 &&
+                                       line.IndexOf (ignored_error) == -1)
+                                       any_error = true;
+
                                line = sr.ReadLine ();
                        }
                        
-                       return false;
+                       return any_error ? CompilerError.Wrong : 
CompilerError.Missing;
                }
 
-               static string[] GetExtraOptions (string file) {
+               static string[] GetExtraOptions (string file)
+               {
                        const string options = "// Compiler options:";
 
                        int row = 0;

_______________________________________________
Mono-patches maillist  -  [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches

Reply via email to