From: Ben Pfaff Date: Mon, 6 Dec 2004 20:03:56 +0000 (+0000) Subject: Start factoring out common pieces of run-tests scripts. X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=64af9d43cb2e90ee34f4bccce7bd38408a51feca;p=pintos-anon Start factoring out common pieces of run-tests scripts. --- diff --git a/grading/lib/Pintos/Grading.pm b/grading/lib/Pintos/Grading.pm new file mode 100644 index 0000000..91b0ab4 --- /dev/null +++ b/grading/lib/Pintos/Grading.pm @@ -0,0 +1,12 @@ +package Pintos::Grading; +use Exporter 'import'; + +@EXPORT = qw($verbose $action); + +use warnings; +use strict; +use Getopt::Long; + + + +1; diff --git a/grading/threads/run-tests b/grading/threads/run-tests index d5f5870..1a869fa 100755 --- a/grading/threads/run-tests +++ b/grading/threads/run-tests @@ -1,5 +1,15 @@ #! /usr/bin/perl +# Find the directory that contains the grading files. +our ($GRADES_DIR); + +# Add our Perl library directory to the include path. +BEGIN { + ($GRADES_DIR = $0) =~ s#/[^/]+$##; + -d $GRADES_DIR or die "$GRADES_DIR: stat: $!\n"; + unshift @INC, "$GRADES_DIR/../lib"; +} + use warnings; use strict; use POSIX; @@ -24,7 +34,7 @@ sub usage { my ($exitcode) = @_; print "run-tests, for grading Pintos thread projects.\n\n"; print "Invoke from a directory containing a student tarball named by\n"; - print "the submit script, e.g. username.Oct.12.04.20.04.09.tar.gz.\n"; + print "the submit script, e.g. username.MMM.DD.YY.hh.mm.ss.tar.gz.\n"; print "In normal usage, no options are needed.\n\n"; print "Output is produced in tests.out and details.out.\n\n"; print "Options:\n"; @@ -98,11 +108,6 @@ if ($grade) { exit 0; } -# Find the directory that contains the grading files. -our ($GRADES_DIR); -($GRADES_DIR = $0) =~ s#/[^/]+$##; --d $GRADES_DIR or die "$GRADES_DIR: stat: $!\n"; - if ($clean) { # Verify that we're roughly in the correct directory # before we go blasting away files. diff --git a/grading/userprog/run-tests b/grading/userprog/run-tests index 4f4bb10..8104a7f 100755 --- a/grading/userprog/run-tests +++ b/grading/userprog/run-tests @@ -1,5 +1,15 @@ #! /usr/bin/perl +# Find the directory that contains the grading files. +our ($GRADES_DIR); + +# Add our Perl library directory to the include path. +BEGIN { + ($GRADES_DIR = $0) =~ s#/[^/]+$##; + -d $GRADES_DIR or die "$GRADES_DIR: stat: $!\n"; + unshift @INC, "$GRADES_DIR/../lib"; +} + use warnings; use strict; use POSIX; @@ -116,11 +126,6 @@ if ($grade) { exit 0; } -# Find the directory that contains the grading files. -our ($GRADES_DIR); -($GRADES_DIR = $0) =~ s#/[^/]+$##; --d $GRADES_DIR or die "$GRADES_DIR: stat: $!\n"; - if ($clean) { # Verify that we're roughly in the correct directory # before we go blasting away files. diff --git a/grading/vm/run-tests b/grading/vm/run-tests index 11fe3e2..108821f 100755 --- a/grading/vm/run-tests +++ b/grading/vm/run-tests @@ -3,6 +3,7 @@ # Find the directory that contains the grading files. our ($GRADES_DIR); +# Add our Perl library directory to the include path. BEGIN { ($GRADES_DIR = $0) =~ s#/[^/]+$##; -d $GRADES_DIR or die "$GRADES_DIR: stat: $!\n"; @@ -15,12 +16,12 @@ use POSIX; use Algorithm::Diff; use Getopt::Long; -our ($VERBOSE) = 0; # Verbosity of output +our ($verbose) = 0; # Verbosity of output our (@TESTS); # Tests to run. my ($clean) = 0; my ($grade) = 0; -GetOptions ("v|verbose+" => \$VERBOSE, +GetOptions ("v|verbose+" => \$verbose, "h|help" => sub { usage (0) }, "t|test=s" => \@TESTS, "c|clean" => \$clean, @@ -620,7 +621,7 @@ sub write_details { sub xsystem { my ($command, %options) = @_; - print "$command\n" if $VERBOSE || $options{VERBOSE}; + print "$command\n" if $verbose || $options{VERBOSE}; my ($log) = $options{LOG};