diff options
author | David Mitchell <davem@iabyn.com> | 2017-06-10 14:54:11 +0100 |
---|---|---|
committer | David Mitchell <davem@iabyn.com> | 2017-06-21 10:56:23 +0100 |
commit | d9b91f7969bc252f244dfaf28f31980e50fc7fe5 (patch) | |
tree | 903e0b06fcbb7268ba56439e95a74d2b5ab14dc4 | |
parent | 6568b26dddaf1bc89610d859ebe908bebdeb714c (diff) | |
download | perl-d9b91f7969bc252f244dfaf28f31980e50fc7fe5.tar.gz |
Porting/bench.pl: fix broken --bisect option
This option had bit-rotted: checks for the right number of perl executables
weren't taking account of --bisect.
Fix, and add tests.
-rwxr-xr-x | Porting/bench.pl | 4 | ||||
-rw-r--r-- | t/porting/bench.t | 13 |
2 files changed, 14 insertions, 3 deletions
diff --git a/Porting/bench.pl b/Porting/bench.pl index 333835e3d9..bf1e32beb3 100755 --- a/Porting/bench.pl +++ b/Porting/bench.pl @@ -740,7 +740,7 @@ sub do_grind { my @run_perls= process_puts($perls, @$perl_args); push @$perls, @run_perls; die "Error: Not enough perls to run a report, and --write not specified.\n" - if @$perls < 2 and !$OPTS{write}; + if @$perls < 2 and !($OPTS{write} || $OPTS{bisect}); $results = grind_run($tests, $order, \@run_perls, $loop_counts, $results); } @@ -776,7 +776,7 @@ sub do_grind { close $out or die "Error: closing file '$OPTS{write}': $!\n"; } if (!$OPTS{write} or $OPTS{show}) { - if (@$perls < 2 && !$OPTS{raw}) { + if (@$perls < 2 && !($OPTS{raw} || $OPTS{bisect})) { die "Error: need more than one perl to do a report.\n"; } my ($processed, $averages) = diff --git a/t/porting/bench.t b/t/porting/bench.t index 46a293781b..2aa7d06245 100644 --- a/t/porting/bench.t +++ b/t/porting/bench.t @@ -93,7 +93,8 @@ ok -s $resultfile1, "--write should create a non-empty results file (1 perl)"; note("running cachegrind for 2nd perl; may be slow..."); $out = qx($bench_cmd -j 2 --read=$resultfile1 --write=$resultfile2 $^X=p1 2>&1); -is length($out), 0, "--write should produce no output (2 perls)"; +is length($out), 0, "--write should produce no output (2 perls)" + or diag("got: $out"); ok -s $resultfile2, "--write should create a non-empty results file (2 perls)"; # 1 perl: @@ -126,6 +127,16 @@ $out = qx($bench_cmd --read=$resultfile2 --compact=1 2>&1); like $out, $format_qrs{compact}, "basic cachegrind compact format; 2 perls"; +# bisect + +note("running cachegrind bisect on 1 perl; may be slow..."); + +# the Ir range here is intended such that the bisect will always fail +$out = qx($bench_cmd --tests=call::sub::empty --bisect=Ir,100000,100001 $^X=p0 2>&1); + +is $?, 1 << 8, "--bisect should not match"; +is length($out), 0, "--bisect should produce no output" + or diag("got: $out"); done_testing(); |