public bool Invoke(string[] args)
{
- StringBuilder sb = new StringBuilder ("/nologo ");
+ StringBuilder sb = new StringBuilder ();
foreach (string s in args) {
sb.Append (s);
sb.Append (" ");
{
protected ITester tester;
protected int success;
- protected int total;
- protected int ignored;
+ int total;
string issue_file;
StreamWriter log_file;
- protected string[] compiler_options;
protected ArrayList regression = new ArrayList ();
protected ArrayList know_issues = new ArrayList ();
this.log_file = new StreamWriter (log_file, false);
}
- protected virtual bool GetExtraOptions (string file)
+ protected virtual string[] GetExtraOptions (string file)
{
+ const string options = "// Compiler options:";
+
int row = 0;
using (StreamReader sr = new StreamReader (file)) {
String line;
while (row++ < 3 && (line = sr.ReadLine()) != null) {
- if (!AnalyzeTestFile (row, line))
- return false;
+ int index = line.IndexOf (options);
+ if (index != -1) {
+ string[] o = line.Substring (index + options.Length).Trim().Split (' ');
+ for (int i = 0; i < o.Length; i++)
+ o [i] = o[i].TrimStart ();
+ return o;
+ }
}
}
- return true;
- }
-
- protected virtual bool AnalyzeTestFile (int row, string line)
- {
- const string options = "// Compiler options:";
-
- if (row == 1)
- compiler_options = null;
-
- int index = line.IndexOf (options);
- if (index != -1) {
- compiler_options = line.Substring (index + options.Length).Trim().Split (' ');
- for (int i = 0; i < compiler_options.Length; i++)
- compiler_options[i] = compiler_options[i].TrimStart ();
- }
- return true;
+ return null;
}
public void Do (string filename)
Log ("...\t");
if (ignore_list.Contains (filename)) {
- ++ignored;
LogLine ("NOT TESTED");
return;
}
- if (!GetExtraOptions (filename)) {
- return;
- }
-
++total;
Check (filename);
}
protected virtual bool Check (string filename)
{
+ string[] extra = GetExtraOptions (filename);
string[] test_args;
- if (compiler_options != null) {
- test_args = new string [1 + compiler_options.Length];
- compiler_options.CopyTo (test_args, 0);
+ if (extra != null) {
+ test_args = new string [1 + extra.Length];
+ extra.CopyTo (test_args, 0);
} else {
test_args = new string [1];
}
LogLine ("Done" + Environment.NewLine);
LogLine ("{0} test cases passed ({1:.##%})", success, (float) (success) / (float)total);
- if (ignored > 0)
- LogLine ("{0} test cases ignored", ignored);
-
know_issues.AddRange (no_error_list);
if (know_issues.Count > 0) {
LogLine ("");
}
}
- protected override bool GetExtraOptions(string file) {
- if (!base.GetExtraOptions (file))
- return false;
-
+ protected override string[] GetExtraOptions(string file)
+ {
doc_output = null;
- if (compiler_options == null)
- return true;
+ string[] opt = base.GetExtraOptions (file);
+ if (opt == null)
+ return null;
- foreach (string one_opt in compiler_options) {
+ foreach (string one_opt in opt) {
if (one_opt.StartsWith ("-doc:")) {
- doc_output = one_opt.Split (':')[1];
+ doc_output = one_opt.Split (':')[1];
}
}
- return true;
+
+ return opt;
}
- protected override bool Check(string filename) {
+ protected override bool Check(string filename)
+ {
try {
if (!base.Check (filename)) {
- HandleFailure (filename, TestResult.CompileError, tester.Output);
+ HandleFailure (filename, TestResult.CompileError, null);
return false;
}
}
return false;
}
- // Test setup
- if (filename.EndsWith ("-lib.cs") || filename.EndsWith ("-mod.cs")) {
- LogLine ("OK");
- --total;
- return true;
- }
-
MethodInfo mi = null;
string file = Path.Combine (files_folder, Path.GetFileNameWithoutExtension (filename) + ".exe");
if (!appdomain_limit_reached) {
know_issues.Remove (file);
return;
}
- LogLine ("REGRESSION (SUCCESS -> EXECUTION ERROR)");
+ LogLine ("REGRESSION (SUCCESS -> EXECUTE ERROR)");
break;
case TestResult.XmlError:
class NegativeChecker: Checker
{
- string expected_message;
- string error_message;
- bool check_msg;
- bool check_error_line;
-
protected enum CompilerError {
Expected,
Wrong,
- Missing,
- WrongMessage,
- MissingLocation
+ Missing
}
- public NegativeChecker (ITester tester, string log_file, string issue_file, bool check_msg):
+ public NegativeChecker (ITester tester, string log_file, string issue_file):
base (tester, log_file, issue_file)
{
- this.check_msg = check_msg;
}
- protected override bool AnalyzeTestFile(int row, string line)
- {
- if (row == 1) {
- expected_message = null;
-
- int index = line.IndexOf (':');
- if (index == -1 || index > 15) {
- LogLine ("IGNORING: Wrong test file syntax (missing error mesage text)");
- ++ignored;
- base.AnalyzeTestFile (row, line);
- return false;
- }
-
- expected_message = line.Substring (index + 1).Trim ();
- }
-
- if (row == 2) {
- string filtered = line.Replace (" ", "");
- check_error_line = !filtered.StartsWith ("//Line:0");
-
- if (!filtered.StartsWith ("//Line:")) {
- LogLine ("IGNORING: Wrong test syntax (second line must have `// Line: xx' syntax");
- ++ignored;
- return false;
- }
- }
-
- return base.AnalyzeTestFile (row, line);
- }
-
-
protected override bool Check (string filename)
{
int start_char = 0;
return true;
}
- if (result_code == CompilerError.Wrong)
- LogLine (tester.Output);
-
+ LogLine (tester.Output);
return false;
}
bool any_error = false;
while (line != null) {
- if (line.IndexOf (tested_text) != -1) {
- if (check_msg) {
- int first = line.IndexOf (':');
- int second = line.IndexOf (':', first + 1);
- if (second == -1)
- second = first;
-
- string msg = line.Substring (second + 1).TrimEnd ('.').Trim ();
- if (msg != expected_message && msg != expected_message.Replace ('`', '\'')) {
- if (check_error_line && line.IndexOf (".cs(") == -1)
- return CompilerError.MissingLocation;
- error_message = msg;
- return CompilerError.WrongMessage;
- }
- }
+ if (line.IndexOf (tested_text) != -1)
return CompilerError.Expected;
- }
if (line.IndexOf (error_prefix) != -1 &&
line.IndexOf (ignored_error) == -1)
return false;
}
if (no_error_list.Contains (file)) {
- LogLine ("REGRESSION (NO ERROR -> WRONG ERROR CODE)");
+ LogLine ("REGRESSION (NO ERROR -> WRONG ERROR)");
no_error_list.Remove (file);
}
else {
- LogLine ("REGRESSION (CORRECT ERROR -> WRONG ERROR CODE)");
+ LogLine ("REGRESSION (CORRECT ERROR -> WRONG ERROR)");
}
- break;
- case CompilerError.WrongMessage:
- if (know_issues.Contains (file)) {
- LogLine ("KNOWN ISSUE (Wrong error message reported)");
- know_issues.Remove (file);
- return false;
- }
- if (no_error_list.Contains (file)) {
- LogLine ("REGRESSION (NO ERROR -> WRONG ERROR MESSAGE)");
- no_error_list.Remove (file);
- }
- else {
- LogLine ("REGRESSION (CORRECT ERROR -> WRONG ERROR MESSAGE)");
- LogLine ("Exp: {0}", expected_message);
- LogLine ("Was: {0}", error_message);
- }
break;
case CompilerError.Missing:
}
break;
-
- case CompilerError.MissingLocation:
- LogLine ("OK (Missing location information)");
- return true;
-
- // Temporary disabled
-/*
- if (know_issues.Contains (file)) {
- LogLine ("KNOWN ISSUE (Missing error location)");
- know_issues.Remove (file);
- return false;
- }
- if (no_error_list.Contains (file)) {
- LogLine ("REGRESSION (NO ERROR -> MISSING ERROR LOCATION)");
- no_error_list.Remove (file);
- }
- else {
- LogLine ("REGRESSION (CORRECT ERROR -> MISSING ERROR LOCATION)");
- }
- break;*/
-
}
regression.Add (file);
Checker checker;
switch (mode) {
case "negative":
- checker = new NegativeChecker (tester, log_fname, issue_file, true);
+ checker = new NegativeChecker (tester, log_fname, issue_file);
break;
case "positive":
checker = new PositiveChecker (tester, log_fname, issue_file);
continue;
}
- if (filename.EndsWith ("-p2.cs"))
+ if (filename.EndsWith ("-p2.cs") || filename.EndsWith ("-lib.cs") || filename.EndsWith ("-mod.cs"))
continue;
checker.Do (filename);