9 my @badtests = qw[System.Collections.HastableTest System.Collections.StackTest System.IO.PathTest];
11 die "Usage: $0 input output" unless $#ARGV == 1;
13 open INPUT, $ARGV[0] or croak "open ($ARGV[0]): $!";
14 while (defined ($_ = <INPUT>)) {
15 next unless /^\s*suite\.AddTest\s*\((.*)\.(.*?)\.Suite\)/;
17 push @alltests, [$1,$2];
21 open OUTPUT, "> $ARGV[1]" or croak "open (> $ARGV[1]): $!";
24 print qq[using NUnit.Framework;\n];
25 print qq[using System;\n];
26 print qq[using System.Threading;\n];
27 print qq[using System.Globalization;\n\n];
31 foreach $alltest (@alltests) {
35 my $testname = $alltest->[0];
36 my $filename = $alltest->[0]."/".$alltest->[1].".cs";
38 open ALLTEST, $filename or croak "open ($filename): $!";
39 while (defined ($_ = <ALLTEST>)) {
40 next unless /^\s*suite\.AddTest\s*\((.*)\.Suite\)/;
43 next if grep $name, @badtests;
46 push @allsuites, qq[$testname.Run$name];
50 print qq[namespace MonoTests.$testname\n\{\n];
53 foreach $suite (@suites) {
57 open SUITE, qq[$testname/$suite.cs] or
58 croak "open ($testname/$suite.cs): $!";
59 while (defined ($_ = <SUITE>)) {
60 next unless /^\s*public\s+void\s+(Test.*?)\s*\(\s*\)/;
65 print qq[\tpublic class Run$suite : $suite\n\t\{\n];
66 print qq[\t\tprotected override void RunTest ()\n\t\t\{\n];
68 print qq[\t\t\t$_ ();\n];
70 print qq[\t\t\}\n\t\}\n];
75 print qq[namespace MonoTests\n\{\n];
76 print qq[\tpublic class RunAllTests\n\t\{\n];
77 print qq[\t\tpublic static void AddAllTests (TestSuite suite)\n];
81 foreach $suite (@allsuites) {
82 print qq[\t\t\tsuite.AddTest (new MonoTests.$suite ());\n];
85 print qq[\t\t\}\n\t\}\n\}\n\n];
87 print qq[class MainApp\n\{\n];
88 print qq[\tpublic static void Main()\n\t\{\n];
89 print qq[\t\tThread.CurrentThread.CurrentCulture = new CultureInfo ("en-US");\n\n];
90 print qq[\t\tTestResult result = new TestResult ();\n];
91 print qq[\t\tTestSuite suite = new TestSuite ();\n];
92 print qq[\t\tMonoTests.RunAllTests.AddAllTests (suite);\n];
93 print qq[\t\tsuite.Run (result);\n];
94 print qq[\t\tMonoTests.MyTestRunner.Print (result);\n];
95 print qq[\t\}\n\}\n\n];