Skip to content

Commit

Permalink
build script: Make exceptions the default error handling mechanism (#208
Browse files Browse the repository at this point in the history
)

* Convert warning to exception in utils::upload

* Rethrow exception in testsuite::run

This prevents failures from being suppressed.

* Throw instead of exiting in restart::setup

* Replace return value with exception in dyninst::run

This prevents errors from being ignored.

Co-authored-by: Tim Haines <[email protected]>
  • Loading branch information
hainest and Tim Haines authored Jan 7, 2022
1 parent c1dad54 commit f3dcda5
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 16 deletions.
12 changes: 4 additions & 8 deletions scripts/build/Dyninst/dyninst.pm
Original file line number Diff line number Diff line change
Expand Up @@ -88,16 +88,14 @@ sub run {
# Always set up logs, even if doing a restart
my ($base_dir, $build_dir) = setup($root_dir, $args);

my $should_proceed = 1;
return unless $args->{'build-dyninst'};

return $should_proceed unless $args->{'build-dyninst'};

$should_proceed = eval {
eval {
$logger->write("Configuring Dyninst... ", 'eol' => '');
configure($args, $base_dir, $build_dir);
$logger->write("done.");

return 0 if $args->{'only-config'};
return if $args->{'only-config'};

save_compiler_config("$build_dir/config.out", "$base_dir/build/compilers.conf");

Expand All @@ -108,10 +106,8 @@ sub run {
if($@) {
$logger->write($@);
open my $fdOut, '>', "$root_dir/dyninst/Build.FAILED";
$should_proceed = 0;
die $@;
}

return $should_proceed;
}

1;
3 changes: 1 addition & 2 deletions scripts/build/Dyninst/restart.pm
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,7 @@ sub setup {
# wants to run the tests, but the user requested not
# to build the Testsuite, then we can't continue
if (!$testsuite_ok && $args->{'run-tests'} && !$user_wants_to_build_tests) {
print "The Testsuite in '$args->{'restart'}' must be rebuilt\n";
exit 1;
die "The Testsuite in '$args->{'restart'}' must be rebuilt\n";
}

# Remove the FAILED files (if present)
Expand Down
1 change: 1 addition & 0 deletions scripts/build/Dyninst/testsuite.pm
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,7 @@ sub run {
} catch {
$logger->write($_);
open my $fdOut, '>', "$root_dir/testsuite/Build.FAILED";
die $_;
}
}

Expand Down
2 changes: 1 addition & 1 deletion scripts/build/Dyninst/utils.pm
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ sub upload {
. "-F \"token=$token\" "
. "https://bottle.cs.wisc.edu/upload");
} catch {
warn "An error occurred when uploading the results\n$_\n";
die "An error occurred when uploading the results\n$_\n";
}
}

Expand Down
9 changes: 4 additions & 5 deletions scripts/build/build.pl
Original file line number Diff line number Diff line change
Expand Up @@ -60,12 +60,11 @@

$logger->write("root_dir: $root_dir");

# Build Dyninst and the test suite.
if (Dyninst::dyninst::run($args, $root_dir, $logger)) {
# Build Dyninst
Dyninst::dyninst::run($args, $root_dir, $logger);

# This also runs the test suite if everything is good.
Dyninst::testsuite::run($args, $root_dir, $logger);
}
# Build and execute test suite
Dyninst::testsuite::run($args, $root_dir, $logger);

# Save the results in a tarball
my $tarball_name = Dyninst::results::save($args, $root_dir);
Expand Down

0 comments on commit f3dcda5

Please sign in to comment.