Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
bisectable: more magic and rainbows
* More detailed bisect log (show exit codes, script output, etc.)
* If the output is identical, then show it. Gist it if it does not fit.
  • Loading branch information
AlexDaniel committed Jul 15, 2016
1 parent 7c22ea4 commit c763c0c
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 12 deletions.
18 changes: 13 additions & 5 deletions bisectable.pl
Expand Up @@ -24,6 +24,7 @@
package Bisectable;
use parent 'Perl6IRCBotable';

use Encode qw(decode_utf8);
use File::Temp qw(tempfile tempdir);
use Cwd qw(cwd abs_path);

Expand Down Expand Up @@ -95,7 +96,8 @@ sub process_message {
$out_bad //= '';

if ($exit_good == $exit_bad and $out_good eq $out_bad) {
return "On both starting points the exit code is $exit_bad and the output is identical as well";
$self->tell($message, "On both starting points the exit code is $exit_bad and the output is identical as well");
return "Output on both points: $out_good"; # will be gisted automatically if required
}
my $output_file = '';
if ($exit_good == $exit_bad) {
Expand All @@ -113,9 +115,15 @@ sub process_message {
system('git', 'clone', $self->RAKUDO, $dir);
chdir($dir);

system('git', 'bisect', 'start');
system('git', 'bisect', 'good', $full_good);
system('git', 'bisect', 'bad', $full_bad);
$self->get_output('git', 'bisect', 'start');
$self->get_output('git', 'bisect', 'good', $full_good);
my ($init_output, $init_status) = $self->get_output('git', 'bisect', 'bad', $full_bad);
if ($init_status != 0) {
chdir($oldDir);
$self->tell($message, 'bisect log: ' . $self->upload({ 'query' => $body,
'result' => decode_utf8($init_output) }));
return 'bisect init failure';
}
my ($bisect_output, $bisect_status);
if ($output_file) {
($bisect_output, $bisect_status) = $self->get_output('git', 'bisect', 'run',
Expand All @@ -130,7 +138,7 @@ sub process_message {
}
}
$self->tell($message, 'bisect log: ' . $self->upload({ 'query' => $body,
'result' => $bisect_output }));
'result' => decode_utf8("$init_output\n$bisect_output") }));
if ($bisect_status != 0) {
chdir($oldDir);
return "'bisect run' failure";
Expand Down
39 changes: 32 additions & 7 deletions test-commit
Expand Up @@ -4,30 +4,55 @@ code_file=$2
current_commit=$(git rev-parse HEAD)
perl6="$builds/$current_commit/bin/perl6"

[[ -e $perl6 ]] || exit 125 # skip failed builds
function finish {
echo "»»»»» -------------------------------------------------------------------------"
}
trap finish EXIT # looks a bit nicer this way

echo "»»»»» Testing $current_commit"
if [[ ! -e $perl6 ]]; then
echo '»»»»» perl6 executable does not exist, skip this commit'
echo "»»»»» Final exit code: 125"
exit 125 # skip failed builds
fi

output=$("$perl6" --setting=RESTRICTED -- "$code_file" 2>&1)
exit_code=$?
echo "»»»»» Script output:"
printf "%s\n" "$output"
echo "»»»»» Script exit code: $exit_code"

# plain bisect
if (( $# < 3 )); then
"$perl6" --setting=RESTRICTED -- "$code_file"
exit $?
echo "»»»»» Plain bisect, using the same exit code"
echo "»»»»» Final exit code: $exit_code"
exit "$exit_code"
fi

# inverted exit code
if [[ $3 =~ ^[0-9]+$ ]]; then # invert exit code
"$perl6" --setting=RESTRICTED -- "$code_file"
exit_code=$?
echo "»»»»» Inverted logic, comparing $exit_code to $3"
if (( $exit_code == $3 )); then
echo '»»»»» Final exit code: 0'
exit 0
else
exit $(( $exit_code == 0 ? 1 : $exit_code ))
final_exit_code=$(( $exit_code == 0 ? 1 : $exit_code ))
echo "»»»»» Final exit code: $final_exit_code"
exit "$final_exit_code"
fi
fi

# compare the output
output=$("$perl6" --setting=RESTRICTED -- "$code_file" 2>&1)
echo "»»»»» Bisecting by using the output"
output_good=$(<"$3")
echo "»»»»» Comparing the output to:"
printf "%s\n" "$output_good"
if [[ $output == "$output_good" ]]; then
echo '»»»»» The output is identical'
echo '»»»»» Final exit code: 0'
exit 0
else
echo '»»»»» The output is different'
echo '»»»»» Final exit code: 1'
exit 1
fi

0 comments on commit c763c0c

Please sign in to comment.