New build.pl --test for running tests.

This commit is contained in:
Brad Fitzpatrick 2011-02-26 13:29:04 -08:00
parent ac7b64eb56
commit 35ef3e5ce2
1 changed files with 14 additions and 0 deletions

View File

@ -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 {