2002-02-27 Martin Baulig <martin@gnome.org>
authorMartin Baulig <martin@novell.com>
Wed, 27 Feb 2002 09:56:15 +0000 (09:56 -0000)
committerMartin Baulig <martin@novell.com>
Wed, 27 Feb 2002 09:56:15 +0000 (09:56 -0000)
* scan-tests.pl: Moved this script here from ../class/corlib/Test.

svn path=/trunk/mcs/; revision=2719

mcs/tools/ChangeLog
mcs/tools/scan-tests.pl [new file with mode: 0755]

index f76f8fb896d8f654555562e3bf0192cc007b252a..76c0f367b897a8ec38bdaf57f1143e7ebf230ca0 100644 (file)
@@ -1,3 +1,7 @@
+2002-02-27  Martin Baulig  <martin@gnome.org>\r
+\r
+       * scan-tests.pl: Moved this script here from ../class/corlib/Test.\r
+\r
 2002-02-22  Nick Drochak  <ndrochak@gol.com>\r
 \r
        * makefile: move corcompare to it's own directory to hold multiple\r
diff --git a/mcs/tools/scan-tests.pl b/mcs/tools/scan-tests.pl
new file mode 100755 (executable)
index 0000000..9a1600b
--- /dev/null
@@ -0,0 +1,98 @@
+#!/usr/bin/perl -w
+
+use strict;
+use Carp;
+
+my @alltests;
+my @allsuites;
+
+my @badtests = qw[System.Collections.HastableTest System.Collections.StackTest System.IO.PathTest];
+
+die "Usage: $0 input output" unless $#ARGV == 1;
+
+open INPUT, $ARGV[0] or croak "open ($ARGV[0]): $!";
+while (defined ($_ = <INPUT>)) {
+    next unless /^\s*suite\.AddTest\s*\((.*)\.(.*?)\.Suite\)/;
+
+    push @alltests, [$1,$2];
+}
+close INPUT;
+
+open OUTPUT, "> $ARGV[1]" or croak "open (> $ARGV[1]): $!";
+select OUTPUT;
+
+print qq[using NUnit.Framework;\n];
+print qq[using System;\n];
+print qq[using System.Threading;\n];
+print qq[using System.Globalization;\n\n];
+
+
+my $alltest;
+foreach $alltest (@alltests) {
+
+    my @suites;
+
+    my $testname = $alltest->[0];
+    my $filename = $alltest->[0]."/".$alltest->[1].".cs";
+
+    open ALLTEST, $filename or croak "open ($filename): $!";
+    while (defined ($_ = <ALLTEST>)) {
+       next unless /^\s*suite\.AddTest\s*\((.*)\.Suite\)/;
+       my $name = $1;
+
+       next if grep $name, @badtests;
+
+       push @suites, $name;
+       push @allsuites, qq[$testname.Run$name];
+    }
+    close ALLTEST;
+
+    print qq[namespace MonoTests.$testname\n\{\n];
+
+    my $suite;
+    foreach $suite (@suites) {
+
+       my @tests;
+
+       open SUITE, qq[$testname/$suite.cs] or
+           croak "open ($testname/$suite.cs): $!";
+       while (defined ($_ = <SUITE>)) {
+           next unless /^\s*public\s+void\s+(Test.*?)\s*\(\s*\)/;
+           push @tests, $1;
+       }
+       close SUITE;
+
+       print qq[\tpublic class Run$suite : $suite\n\t\{\n];
+       print qq[\t\tprotected override void RunTest ()\n\t\t\{\n];
+       foreach (@tests) {
+           print qq[\t\t\t$_ ();\n];
+       }
+       print qq[\t\t\}\n\t\}\n];
+    }
+    print qq[\}\n\n];
+}
+
+print qq[namespace MonoTests\n\{\n];
+print qq[\tpublic class RunAllTests\n\t\{\n];
+print qq[\t\tpublic static void AddAllTests (TestSuite suite)\n];
+print qq[\t\t\{\n];
+
+my $suite;
+foreach $suite (@allsuites) {
+    print qq[\t\t\tsuite.AddTest (new MonoTests.$suite ());\n];
+}
+
+print qq[\t\t\}\n\t\}\n\}\n\n];
+
+print qq[class MainApp\n\{\n];
+print qq[\tpublic static void Main()\n\t\{\n];
+print qq[\t\tThread.CurrentThread.CurrentCulture = new CultureInfo ("en-US");\n\n];
+print qq[\t\tTestResult result = new TestResult ();\n];
+print qq[\t\tTestSuite suite = new TestSuite ();\n];
+print qq[\t\tMonoTests.RunAllTests.AddAllTests (suite);\n];
+print qq[\t\tsuite.Run (result);\n];
+print qq[\t\tMonoTests.MyTestRunner.Print (result);\n];
+print qq[\t\}\n\}\n\n];
+
+close OUTPUT;
+