3 using System.Reflection;
5 public class TestRunner : MarshalByRefObject
7 public void RunTest (String test) {
10 Assembly a = Assembly.LoadFrom (test);
12 MethodInfo mi = a.EntryPoint;
15 Console.WriteLine (" FAILED (no entry point found)");
20 mi.Invoke (null, null);
21 Console.WriteLine (" FAILED (silent success)");
23 catch (TargetInvocationException ex) {
24 if (ex.InnerException is InvalidProgramException)
25 Console.WriteLine (" OK");
27 Console.WriteLine (" FAILED -> " + ex.InnerException);
29 catch (Exception ex) {
30 Console.WriteLine (" FAILED -> " + ex);
34 public static void Main (String[] args) {
35 if (args.Length < 1) {
36 Console.WriteLine ("Usage: TestRunner <file pattern>");
41 String[] tests = Directory.GetFiles (".", args [0]);
43 AppDomain domain = null;
44 TestRunner runner = null;
47 foreach (String test in tests) {
49 * Run each bunch of tests in a new appdomain, then unload it to
50 * avoid too many open files exceptions.
52 if ((count % 500) == 0) {
54 AppDomain.Unload (domain);
55 domain = AppDomain.CreateDomain ("domain-" + count);
57 runner = (TestRunner)domain.CreateInstanceAndUnwrap (typeof (TestRunner).Assembly.FullName, typeof (TestRunner).FullName);
60 runner.RunTest (test);