Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/mono.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarek Safar <marek.safar@gmail.com>2012-12-03 20:56:08 +0400
committerMarek Safar <marek.safar@gmail.com>2012-12-03 21:01:23 +0400
commit3c27fcd2bb00fe9c55768c5bf859506175619aad (patch)
tree3102329cc2eba153736a7c984410c881e0956cae
parente80b95e5eb58be8ce1b601765d6dbefe263ae9a0 (diff)
Add MonoTouch compatible run mode
-rw-r--r--mcs/tools/compiler-tester/App.config6
-rw-r--r--mcs/tools/compiler-tester/CompilerTester.csproj3
-rw-r--r--mcs/tools/compiler-tester/compiler-tester.cs166
3 files changed, 166 insertions, 9 deletions
diff --git a/mcs/tools/compiler-tester/App.config b/mcs/tools/compiler-tester/App.config
new file mode 100644
index 00000000000..cad84466e22
--- /dev/null
+++ b/mcs/tools/compiler-tester/App.config
@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="utf-8" ?>
+<configuration>
+ <runtime>
+ <loadFromRemoteSources enabled="true"/>
+ </runtime>
+</configuration> \ No newline at end of file
diff --git a/mcs/tools/compiler-tester/CompilerTester.csproj b/mcs/tools/compiler-tester/CompilerTester.csproj
index 97e1e42b7de..17241e7d046 100644
--- a/mcs/tools/compiler-tester/CompilerTester.csproj
+++ b/mcs/tools/compiler-tester/CompilerTester.csproj
@@ -84,5 +84,8 @@
<Compile Include="compiler-tester.cs" />
<Compile Include="xmldocdiff.cs" />
</ItemGroup>
+ <ItemGroup>
+ <None Include="App.config" />
+ </ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
</Project> \ No newline at end of file
diff --git a/mcs/tools/compiler-tester/compiler-tester.cs b/mcs/tools/compiler-tester/compiler-tester.cs
index d0a7b06f0d5..7f802bcf9e9 100644
--- a/mcs/tools/compiler-tester/compiler-tester.cs
+++ b/mcs/tools/compiler-tester/compiler-tester.cs
@@ -151,6 +151,130 @@ namespace TestRunner {
}
}
+ class NUnitChecker : PositiveChecker
+ {
+ class TestCaseEntry
+ {
+ string name;
+ string referenceFile;
+ string executedMethod;
+ bool has_return;
+
+ public TestCaseEntry (string name, string referenceFile, MethodInfo executedMethod)
+ {
+ this.name = name.Replace ('-', '_');
+ this.referenceFile = referenceFile;
+ this.executedMethod = ConvertMethodInfoToText (executedMethod, out has_return);
+ }
+
+ public string Name
+ {
+ get
+ {
+ return name;
+ }
+ }
+
+ public string ReferenceFile {
+ get {
+ return referenceFile;
+ }
+ }
+
+ static string ConvertMethodInfoToText (MethodInfo mi, out bool hasReturn)
+ {
+ hasReturn = mi.ReturnType != typeof (void);
+ string declaring = mi.DeclaringType.FullName.Replace ('+', '.');
+ var param = mi.GetParameters ();
+ if (param.Length == 0)
+ return declaring + "." + mi.Name + " ()";
+
+ return declaring + "." + mi.Name + " (null)";
+ }
+
+ public string GetTestFixture ()
+ {
+ var call = name + "::" + executedMethod;
+ if (!has_return)
+ return call;
+
+ return string.Format ("Assert.AreEqual (0, {0})", call);
+ }
+ }
+
+ List<TestCaseEntry> entries = new List<TestCaseEntry> ();
+
+ public NUnitChecker (ITester tester)
+ : base (tester, null)
+ {
+ }
+
+ public override void CleanUp ()
+ {
+ base.CleanUp ();
+
+ StringBuilder aliases = new StringBuilder ();
+ var src_dir = Path.Combine ("projects", "MonoTouch");
+ string src_file = Path.Combine (src_dir, "tests.cs");
+
+ using (var file = new StreamWriter (src_file, false)) {
+ foreach (var e in entries) {
+ file.WriteLine ("extern alias {0};", e.Name);
+ aliases.AppendFormat (" <Reference Include=\"{0}\">", Path.GetFileNameWithoutExtension (e.ReferenceFile));
+ aliases.Append (Environment.NewLine);
+ aliases.AppendFormat (" <Aliases>{0}</Aliases>", e.Name);
+ aliases.Append (Environment.NewLine);
+ aliases.AppendFormat (" <HintPath>..\\..\\{0}</HintPath>", Path.GetFileName (e.ReferenceFile));
+ aliases.Append (Environment.NewLine);
+ aliases.AppendLine (" </Reference>");
+ }
+
+ file.WriteLine ();
+ file.WriteLine ("using NUnit.Framework;");
+ file.WriteLine ();
+ file.WriteLine ("[TestFixture]");
+ file.WriteLine ("public class Tests {");
+
+ foreach (var e in entries) {
+ file.WriteLine ("\t[Test]");
+ file.WriteLine ("\tpublic void TestFile_{0} ()", e.Name);
+ file.WriteLine ("\t{");
+ file.WriteLine ("\t\t{0};", e.GetTestFixture ());
+ file.WriteLine ("\t}");
+ file.WriteLine ();
+ }
+
+ file.WriteLine ("}");
+ }
+
+ var input = File.ReadAllText (Path.Combine (src_dir, "MonoTouch.csproj.template"));
+ input = input.Replace ("@GENERATED_REFERENCES", aliases.ToString ());
+ input = input.Replace ("@TEST_SOURCEFILE", Path.GetFileName (src_file));
+
+ File.WriteAllText (Path.Combine (src_dir, "MonoTouch.csproj"), input);
+ return;
+ }
+
+ protected override bool ExecuteTestFile (TestCase test, string binaryFileName)
+ {
+ Assembly assembly = Assembly.LoadFile (binaryFileName);
+ var ep = assembly.EntryPoint;
+ if (!ep.IsPublic) {
+ HandleFailure (test.FileName, TestResult.LoadError, "Entry method is private");
+ return false;
+ }
+
+ if (ep.DeclaringType.IsNestedPrivate || ep.DeclaringType.IsNestedFamily) {
+ HandleFailure (test.FileName, TestResult.LoadError, "Entry method in hidden nested type");
+ return false;
+ }
+
+ entries.Add (new TestCaseEntry (Path.GetFileNameWithoutExtension (test.FileName), binaryFileName, ep));
+ HandleFailure (test.FileName, TestResult.Success, null);
+ return true;
+ }
+ }
+
class PositiveTestCase : TestCase
{
public class VerificationData : MarshalByRefObject
@@ -315,6 +439,7 @@ namespace TestRunner {
protected ArrayList know_issues = new ArrayList ();
protected ArrayList ignore_list = new ArrayList ();
protected ArrayList no_error_list = new ArrayList ();
+ ArrayList skip = new ArrayList ();
protected bool verbose;
protected bool safe_execution;
@@ -414,6 +539,10 @@ namespace TestRunner {
if (verbose)
Log (filename + "...\t");
+ if (skip.Contains (filename)) {
+ return false;
+ }
+
if (ignore_list.Contains (filename)) {
++ignored;
LogFileLine (filename, "NOT TESTED");
@@ -460,13 +589,14 @@ namespace TestRunner {
string[] test_args;
if (test.CompilerOptions != null) {
- test_args = new string [2 + test.CompilerOptions.Length];
+ test_args = new string[2 + test.CompilerOptions.Length];
test.CompilerOptions.CopyTo (test_args, 0);
} else {
- test_args = new string [2];
+ test_args = new string[2];
}
- test_args [test_args.Length - 2] = test.FileName;
- test_args [test_args.Length - 1] = "-debug";
+ test_args[test_args.Length - 2] = test_args[0];
+ test_args[test_args.Length - 1] = "-debug";
+ test_args[0] = test.FileName;
return tester.Invoke (test_args);
}
@@ -480,6 +610,7 @@ namespace TestRunner {
{
const string ignored = "IGNORE";
const string no_error = "NO ERROR";
+ const string skip_tag = "SKIP";
using (StreamReader sr = new StreamReader (file)) {
string line;
@@ -493,6 +624,8 @@ namespace TestRunner {
active_cont = ignore_list;
else if (line.IndexOf (no_error) > 0)
active_cont = no_error_list;
+ else if (line.Contains (skip_tag))
+ active_cont = skip;
string file_name = line.Split (' ')[0];
if (file_name.Length == 0)
@@ -827,6 +960,13 @@ namespace TestRunner {
return true;
}
+ return ExecuteTestFile (test, file);
+ }
+
+ protected virtual bool ExecuteTestFile (TestCase test, string binaryFileName)
+ {
+ string filename = test.FileName;
+
AppDomain domain = null;
#if !NET_2_1
if (safe_execution) {
@@ -834,7 +974,7 @@ namespace TestRunner {
AppDomainSetup setupInfo = new AppDomainSetup ();
setupInfo.ApplicationBase = AppDomain.CurrentDomain.BaseDirectory;
setupInfo.LoaderOptimization = LoaderOptimization.SingleDomain;
- domain = AppDomain.CreateDomain (Path.GetFileNameWithoutExtension (file), null, setupInfo);
+ domain = AppDomain.CreateDomain (Path.GetFileNameWithoutExtension (binaryFileName), null, setupInfo);
}
#endif
try {
@@ -847,7 +987,7 @@ namespace TestRunner {
#endif
tester = new DomainTester ();
- if (!tester.Test (file))
+ if (!tester.Test (binaryFileName))
return false;
} catch (ApplicationException e) {
@@ -873,12 +1013,12 @@ namespace TestRunner {
PositiveTestCase pt = (PositiveTestCase) test;
pt.VerificationProvider = (PositiveTestCase.VerificationData) verif_data[filename];
- if (!tester.CheckILSize (pt, this, file))
+ if (!tester.CheckILSize (pt, this, binaryFileName))
return false;
}
if (filename.StartsWith ("test-debug", StringComparison.OrdinalIgnoreCase)) {
- var mdb_file_name = file + ".mdb";
+ var mdb_file_name = binaryFileName + ".mdb";
MonoSymbolFile mdb_file = MonoSymbolFile.ReadSymbolFile (mdb_file_name);
var mdb_xml_file = mdb_file_name + ".xml";
ConvertSymbolFileToXml (mdb_file, mdb_xml_file);
@@ -1038,7 +1178,11 @@ namespace TestRunner {
break;
case TestResult.LoadError:
- LogFileLine (file, "REGRESSION (SUCCESS -> LOAD ERROR)");
+ if (extra != null)
+ extra = ": " + extra;
+
+ LogFileLine (file, "REGRESSION (SUCCESS -> LOAD ERROR)" + extra);
+ extra = null;
break;
case TestResult.MethodAttributesError:
@@ -1452,6 +1596,10 @@ namespace TestRunner {
}
break;
+ case "nunit":
+ positive = true;
+ checker = new NUnitChecker (tester);
+ break;
default:
Console.Error.WriteLine ("Invalid -mode argument");
return 1;