From: Martin Baulig Date: Wed, 27 Feb 2002 09:56:15 +0000 (-0000) Subject: 2002-02-27 Martin Baulig X-Git-Url: http://wien.tomnetworks.com/gitweb/?a=commitdiff_plain;h=7e16486f3116025982e11e8e095b66df9302744d;p=mono.git 2002-02-27 Martin Baulig * scan-tests.pl: Moved this script here from ../class/corlib/Test. svn path=/trunk/mcs/; revision=2719 --- diff --git a/mcs/tools/ChangeLog b/mcs/tools/ChangeLog index f76f8fb896d..76c0f367b89 100644 --- a/mcs/tools/ChangeLog +++ b/mcs/tools/ChangeLog @@ -1,3 +1,7 @@ +2002-02-27 Martin Baulig + + * scan-tests.pl: Moved this script here from ../class/corlib/Test. + 2002-02-22 Nick Drochak * makefile: move corcompare to it's own directory to hold multiple diff --git a/mcs/tools/scan-tests.pl b/mcs/tools/scan-tests.pl new file mode 100755 index 00000000000..9a1600bd476 --- /dev/null +++ b/mcs/tools/scan-tests.pl @@ -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 ($_ = )) { + 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 ($_ = )) { + 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 ($_ = )) { + 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; +