From 35ef3e5ce21a7af847464f7c164dacb59fbe28bc Mon Sep 17 00:00:00 2001 From: Brad Fitzpatrick Date: Sat, 26 Feb 2011 13:29:04 -0800 Subject: [PATCH] New build.pl --test for running tests. --- build.pl | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/build.pl b/build.pl index ca168d372..01c019a0d 100755 --- a/build.pl +++ b/build.pl @@ -27,12 +27,14 @@ use FindBin; my $opt_list; my $opt_eachclean; my $opt_verbose; +my $opt_test; chdir($FindBin::Bin) or die "Couldn't chdir to $FindBin::Bin: $!"; GetOptions("list" => \$opt_list, "eachclean" => \$opt_eachclean, "verbose" => \$opt_verbose, + "test" => \$opt_test, ) or usage(); sub usage { @@ -48,6 +50,7 @@ Usage: Other options: --verbose|-v Verbose + --test|-t Run tests where found EOM ; } @@ -182,6 +185,17 @@ sub build { die "Error building $target $chain\n"; } v("Built '$target'"); + + if ($opt_test) { + opendir(my $dh, $target); + my @test_files = grep { /_test\.go/ } grep { !/~$/ } readdir($dh); + closedir($dh); + if (@test_files) { + if (system("make", @quiet, "-C", $target, "test") != 0) { + die "Tests failed for $target\n"; + } + } + } } sub read_targets {