Author: sudha
Date: 2005-03-30 06:58:24 -0500 (Wed, 30 Mar 2005)
New Revision: 42366
Added:
trunk/mcs/mbas/Test/errors/test-mbas.make
trunk/mcs/mbas/Test/errors/test-mbas.pl
trunk/mcs/mbas/Test/tests/test-mbas.make
trunk/mcs/mbas/Test/tests/test-mbas.pl
Modified:
trunk/mcs/mbas/Test/ChangeLog
trunk/mcs/mbas/Test/errors/Makefile
trunk/mcs/mbas/Test/tests/Makefile
Log:
Some fixes to 'test-mbas.pl' script
Modified: trunk/mcs/mbas/Test/ChangeLog
===================================================================
--- trunk/mcs/mbas/Test/ChangeLog 2005-03-30 08:40:13 UTC (rev 42365)
+++ trunk/mcs/mbas/Test/ChangeLog 2005-03-30 11:58:24 UTC (rev 42366)
@@ -1,3 +1,9 @@
+2005-03-30 Satya Sudha K <[EMAIL PROTECTED]>
+ Sudharsan V <[EMAIL PROTECTED]>
+
+ * Separate 'test-mbas.pl' scripts for 'tests' and 'errors'
+ * Under 'errors': taking the line no also into account while verifying
errors
+
2005-03-29 Satya Sudha K <[EMAIL PROTECTED]>
Sudharsan V <[EMAIL PROTECTED]>
Modified: trunk/mcs/mbas/Test/errors/Makefile
===================================================================
--- trunk/mcs/mbas/Test/errors/Makefile 2005-03-30 08:40:13 UTC (rev 42365)
+++ trunk/mcs/mbas/Test/errors/Makefile 2005-03-30 11:58:24 UTC (rev 42366)
@@ -2,9 +2,8 @@
include ../../../build/rules.make
-include ../test-mbas.make
+include ./test-mbas.make
-
Added: trunk/mcs/mbas/Test/errors/test-mbas.make
===================================================================
--- trunk/mcs/mbas/Test/errors/test-mbas.make 2005-03-30 08:40:13 UTC (rev
42365)
+++ trunk/mcs/mbas/Test/errors/test-mbas.make 2005-03-30 11:58:24 UTC (rev
42366)
@@ -0,0 +1,27 @@
+ifndef COMPILER
+COMPILER = $(BASCOMPILE)
+endif
+
+ifndef PATTERN
+PATTERN = *.vb
+endif
+
+COMPILER_FLAGS = /libpath:../../../../class/lib/default /imports:System
+LIBRARY_OPT = /target:library
+DISTFILES = $(wildcard README.tests) $(wildcard *.vb)
+
+run-test-local:
+ $(MAKE) clean-local
+ ./test-mbas.pl --compiler='$(COMPILER)'
--compilerflags='$(COMPILER_FLAGS)' --pattern='$(PATTERN)'
--runtime='$(TEST_RUNTIME)'
+
+run-test-ondotnet-local:
+ $(MAKE) clean-local
+ ./test-mbas.pl --compiler='$(COMPILER)'
--compilerflags='$(COMPILER_FLAGS)' --pattern='$(PATTERN)' --runtime=
+
+clean-local:
+ rm -f *.exe *.log *.results
+
+all-local test-local install-local uninstall-local:
+ @:
+
+dist-local: dist-default
Added: trunk/mcs/mbas/Test/errors/test-mbas.pl
===================================================================
--- trunk/mcs/mbas/Test/errors/test-mbas.pl 2005-03-30 08:40:13 UTC (rev
42365)
+++ trunk/mcs/mbas/Test/errors/test-mbas.pl 2005-03-30 11:58:24 UTC (rev
42366)
@@ -0,0 +1,252 @@
+#!/usr/bin/perl -w
+use Cwd;
+use File::Basename;
+use File::Find;
+use Getopt::Long;
+
+
+my $Compiler = "mbas";
+my $Runtime;
+my $CompilerFlags = "";
+
+my $Execute = 1;
+my $CompileCmd;
+my $RunCmd;
+my $RetVal=-1;
+
+my $VBFile="";
+my $VBExeFile;
+my $VBLogFile;
+my $TestResultsFile = "TestResults.log";
+my $ExpectedResult="SUCCESS";
+#my @ActualResults = ();
+
+
+my $VerboseMode=1;
+my $FilePattern = "*.vb";
+my $PrintHelp;
+
+
+
+
+sub ParseTestFile
+{
+ my $hash = shift;
+ my $testAnnotation;
+ %$hash = ();
+ my $lineNo;
+ my $fileName;
+ my $expectedError;
+
+ my $target = "";
+ my $compilerOptions = "";
+
+ my $cmdLine;
+ my $got_line_no = 0;
+
+ open(VB_FILE, $VBFile);
+ while(<VB_FILE>)
+ {
+ next unless length;
+
+ if(/^\s*REM(.*)/) {
+ $testAnnotation = $1;
+ }
+ else {
+ next;
+ }
+
+ if($testAnnotation =~ /\s*LineNo\s*:\s*(\d+)/) {
+ $got_line_no = 1;
+ $lineNo = $1;
+ }
+ elsif($testAnnotation =~ /\s*ExpectedError\s*:\s*(BC\d+)/) {
+ if (!$got_line_no ) {
+ print "Invalid format - No line number specified!!\n Ignoring
this error\n";
+ next;
+ }
+ $got_line_no = 0;
+ $expectedError = $1;
+ $hash->{$lineNo}{$expectedError} = 1;
+ }
+ elsif($testAnnotation =~ /\s*Target\s*:\s*(.*)/) {
+ $target = $1;
+
+ if($target =~ /library/ || $target =~ /module/) {
+ $Execute = 0;
+ }
+ else {
+ $Execute = 1;
+ }
+
+ if($target ne "") {
+ $target = "/target:" . $target;
+ }
+ }
+ elsif($testAnnotation =~ /\s*CompilerOptions\s*:\s*(.*)/) {
+ $compilerOptions = $1;
+ }
+ }
+ close(VB_FILE);
+
+ $cmdLine = $Compiler . " " . $CompilerFlags . " " . $target . " " .
$compilerOptions . " " . $VBFile;
+
+ $ExpectedResult = {
+ FILE => $VBFile,
+ LINENO => $lineNo,
+ ERRORNO => $expectedError,
+ };
+
+ return ($cmdLine);
+}
+
+sub Command
+{
+ my $retVal;
+ my $cmdLine = shift(@_);
+
+ open SAVEOUT, ">&STDOUT";
+ open SAVEERR, ">&STDERR";
+
+ print SAVEOUT "";
+ print SAVEERR "";
+
+ open STDOUT, ">>$VBLogFile";
+ open STDERR, ">&STDOUT";
+
+ print "\n";
+ print $cmdLine . "\n";
+ system($cmdLine);
+
+ $retVal = $?;
+
+ close STDOUT;
+ close STDERR;
+
+ open STDOUT, ">&SAVEOUT";
+ open STDERR, ">&SAVEERR";
+
+ return $retVal;
+}
+
+sub ExtractResults
+{
+ my %ActualResults = ();
+
+ open(VBLOGFILE, $VBLogFile);
+ while(<VBLOGFILE>)
+ {
+ if($_ =~
/\s*((.*)\((\d+).*\)\s*)?:?\s*(error|warning)\s*(BC\d+)\s*:\s*(.*)/)
+ {
+ if (defined $3 && defined $5) {
+ $ActualResults{$3}{$5} = 1;
+ }
+ }
+ }
+ close(VBLOGFILE);
+ return %ActualResults;
+}
+
+sub ValidateResults
+{
+ my ($expected, $actual) = (@_);
+ my $retval = 0;
+ my @matching = ();
+
+ if($ExpectedResult eq "SUCCESS")
+ {
+ if((keys %$actual) == 0) {
+ return 0;
+ }
+ else {
+ return -1;
+ }
+ }
+
+ foreach my $lineno (keys %$expected) {
+ foreach my $errno (keys %{$expected->{$lineno}}) {
+ if (!defined $actual->{$lineno}{$errno}) {
+ return -1;
+ }
+ }
+ }
+
+ return 0;
+}
+
+sub LogResults
+{
+ my($retVal, $msg) = @_;
+
+ LogMessage("========================");
+ if($retVal == 0) {
+ LogMessage($VBFile . ": OK");
+ }
+ else {
+ LogMessage($VBFile . ": FAILED " . $msg);
+ }
+}
+
+
+
+sub LogMessage
+{
+ my $msg = shift(@_);
+
+ if($VerboseMode) {
+ print $msg . "\n";
+ }
+
+ print TEST_RESULTS_FILE $msg . "\n";
+}
+
+sub PrintUsage() {
+ print "\nUsage: test-mbas_errors.pl [options]";
+ print "\nTypical Usage: test-mbas_errors.pl --p=Accessibility*.vb
--res=test-results.log";
+ print "\n\noptions:";
+ print "\n\t--help\t\tprints this help";
+ print "\n\t--verbose\tprints the results on the screen";
+ print "\n\t--compiler\tspecify mbas or vbc";
+ print "\n\t--compilerflags\tuse this to pass additional flags to the
compiler";
+ print "\n\t--runtime\tspecify mono or dotnet";
+ print "\n\t--results\tname of the logfile";
+ print "\n\t--pattern\tshell pattern for test case files\n\n";
+}
+
+# Process the command line
+
+$result = GetOptions( "verbose!"=>\$VerboseMode,
+ "help"=>\$PrintHelp,
+ "compiler:s"=>\$Compiler,
+ "compilerflags:s"=>\$CompilerFlags,
+ "runtime:s"=>\$Runtime,
+ "results:s"=>\$TestResultsFile,
+ "pattern:s"=>\$FilePattern);
+
+if(!$result || $PrintHelp) {
+ PrintUsage();
+ exit 1;
+}
+
+# Build the list of tests to run
+
+open(TEST_RESULTS_FILE, ">$TestResultsFile");
+while(defined ($vbFile = glob($FilePattern))) {
+ $VBFile = $vbFile;
+ $VBLogFile = $VBFile . ".log";
+ my %hash = ();
+
+ $CompileCmd = ParseTestFile(\%hash);
+
+ $RetVal = Command($CompileCmd);
+ my %actualResults = ExtractResults();
+ $RetVal = ValidateResults(\%hash, \%actualResults);
+ LogResults($RetVal, "");
+
+ if($RetVal == 0) {
+ unlink($VBLogFile);
+ }
+}
+
+close TEST_RESULTS_FILE;
+
Property changes on: trunk/mcs/mbas/Test/errors/test-mbas.pl
___________________________________________________________________
Name: svn:executable
+ *
Modified: trunk/mcs/mbas/Test/tests/Makefile
===================================================================
--- trunk/mcs/mbas/Test/tests/Makefile 2005-03-30 08:40:13 UTC (rev 42365)
+++ trunk/mcs/mbas/Test/tests/Makefile 2005-03-30 11:58:24 UTC (rev 42366)
@@ -1,5 +1,4 @@
thisdir = mbas/Test/tests
include ../../../build/rules.make
-include ../test-mbas.make
-
+include test-mbas.make
Added: trunk/mcs/mbas/Test/tests/test-mbas.make
===================================================================
--- trunk/mcs/mbas/Test/tests/test-mbas.make 2005-03-30 08:40:13 UTC (rev
42365)
+++ trunk/mcs/mbas/Test/tests/test-mbas.make 2005-03-30 11:58:24 UTC (rev
42366)
@@ -0,0 +1,27 @@
+ifndef COMPILER
+COMPILER = $(BASCOMPILE)
+endif
+
+ifndef PATTERN
+PATTERN = *.vb
+endif
+
+COMPILER_FLAGS = /libpath:../../../../class/lib/default /imports:System
+LIBRARY_OPT = /target:library
+DISTFILES = $(wildcard README.tests) $(wildcard *.vb)
+
+run-test-local:
+ $(MAKE) clean-local
+ ./test-mbas.pl --compiler='$(COMPILER)'
--compilerflags='$(COMPILER_FLAGS)' --pattern='$(PATTERN)'
--runtime='$(TEST_RUNTIME)'
+
+run-test-ondotnet-local:
+ $(MAKE) clean-local
+ ./test-mbas.pl --compiler='$(COMPILER)'
--compilerflags='$(COMPILER_FLAGS)' --pattern='$(PATTERN)' --runtime=
+
+clean-local:
+ rm -f *.exe *.log *.results
+
+all-local test-local install-local uninstall-local:
+ @:
+
+dist-local: dist-default
Added: trunk/mcs/mbas/Test/tests/test-mbas.pl
===================================================================
--- trunk/mcs/mbas/Test/tests/test-mbas.pl 2005-03-30 08:40:13 UTC (rev
42365)
+++ trunk/mcs/mbas/Test/tests/test-mbas.pl 2005-03-30 11:58:24 UTC (rev
42366)
@@ -0,0 +1,146 @@
+#!/usr/bin/perl -w
+use Cwd;
+use File::Basename;
+use File::Find;
+use Getopt::Long;
+
+
+my $Compiler = "mbas";
+my $Runtime;
+my $CompilerFlags = "";
+
+my $Execute = 1;
+my $CompileCmd;
+my $RunCmd;
+my $RetVal=-1;
+
+my $VBFile="";
+my $VBExeFile;
+my $VBLogFile;
+my $TestResultsFile = "TestResults.log";
+my $ExpectedResult="SUCCESS";
+my @ActualResults = ();
+
+
+my $VerboseMode=1;
+my $FilePattern = "*.vb";
+my $PrintHelp;
+
+sub Command
+{
+ my $retVal;
+ my $cmdLine = shift(@_);
+
+ open SAVEOUT, ">&STDOUT";
+ open SAVEERR, ">&STDERR";
+
+ print SAVEOUT "";
+ print SAVEERR "";
+
+ open STDOUT, ">>$VBLogFile";
+ open STDERR, ">&STDOUT";
+
+ print "\n";
+ print $cmdLine . "\n";
+ system($cmdLine);
+
+ $retVal = $?;
+
+ close STDOUT;
+ close STDERR;
+
+ open STDOUT, ">&SAVEOUT";
+ open STDERR, ">&SAVEERR";
+
+ return $retVal;
+}
+
+sub LogResults
+{
+ my($retVal, $msg) = @_;
+
+ LogMessage("========================");
+ if($retVal == 0) {
+ LogMessage($VBFile . ": OK");
+ }
+ else {
+ LogMessage($VBFile . ": FAILED " . $msg);
+ }
+}
+
+
+
+sub LogMessage
+{
+ my $msg = shift(@_);
+
+ if($VerboseMode) {
+ print $msg . "\n";
+ }
+
+ print TEST_RESULTS_FILE $msg . "\n";
+}
+
+sub PrintUsage() {
+ print "\nUsage: test-mbas.pl [options]";
+ print "\nTypical Usage: test-mbas.pl --p=Accessibility*.vb
--res=test-results.log";
+ print "\n\noptions:";
+ print "\n\t--help\t\tprints this help";
+ print "\n\t--verbose\tprints the results on the screen";
+ print "\n\t--compiler\tspecify mbas or vbc";
+ print "\n\t--compilerflags\tuse this to pass additional flags to the
compiler";
+ print "\n\t--runtime\tspecify mono or dotnet";
+ print "\n\t--results\tname of the logfile";
+ print "\n\t--pattern\tshell pattern for test case files\n\n";
+}
+
+# Process the command line
+
+$result = GetOptions( "verbose!"=>\$VerboseMode,
+ "help"=>\$PrintHelp,
+ "compiler:s"=>\$Compiler,
+ "compilerflags:s"=>\$CompilerFlags,
+ "runtime:s"=>\$Runtime,
+ "results:s"=>\$TestResultsFile,
+ "pattern:s"=>\$FilePattern);
+
+if(!$result || $PrintHelp) {
+ PrintUsage();
+ exit 1;
+}
+
+# Build the list of tests to run
+
+open(TEST_RESULTS_FILE, ">$TestResultsFile");
+while(defined ($vbFile = glob($FilePattern))) {
+ $VBFile = $vbFile;
+ $VBLogFile = $VBFile . ".log";
+
+ $CompileCmd = $Compiler . " " . $CompilerFlags . " " . $VBFile;
+ $RetVal = Command($CompileCmd);
+
+ if($ExpectedResult eq "SUCCESS") {
+ if($RetVal != 0) {
+ LogResults($RetVal, "COMPILATION");
+ next;
+ }
+ else {
+ if($Execute == 1) {
+ $VBExeFile = $VBFile;
+ $VBExeFile =~ s/\.vb$/\.exe/;
+ $RunCmd = "$Runtime ./$VBExeFile";
+ $RetVal = Command($RunCmd);
+ LogResults($RetVal, "EXECUTION");
+ }
+ else {
+ LogResults($RetVal, "");
+ }
+ }
+ }
+
+ if($RetVal == 0) {
+ unlink($VBLogFile);
+ }
+}
+close TEST_RESULTS_FILE;
+
Property changes on: trunk/mcs/mbas/Test/tests/test-mbas.pl
___________________________________________________________________
Name: svn:executable
+ *
_______________________________________________
Mono-patches maillist - [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches