Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion lib/App/Yath/Options/Finder.pm
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,10 @@ sub _post_process {

push @{$finder->rerun_modes} => $mode;

next if $val eq '1';
if ($val eq '1') {
$rerun //= '1';
next;
}

$rerun //= $val;
$rerun = $val if $rerun eq '1';
Expand Down
48 changes: 48 additions & 0 deletions t/integration/rerun_failed.t
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
use Test2::V0;
use File::Temp qw/tempdir/;
use File::Spec;
use Cwd qw/getcwd/;

use App::Yath::Tester qw/yath/;

my $dir = __FILE__;
$dir =~ s{\.t$}{}g;
$dir =~ s{^\./}{};

# GH #283: yath --rerun-failed should use the default lastlog.jsonl location
# when no explicit log path is given.

my $workdir = tempdir(CLEANUP => 1);

# Step 1: Run tests with logging enabled to generate a lastlog.jsonl
yath(
command => 'test',
args => [$dir, '--ext=tx', '-L', '--log-dir' => $workdir],
exit => T(),
test => sub {
my $out = shift;
like($out->{output}, qr{fail\.tx}, "first run saw the failing test");
like($out->{output}, qr{pass\.tx}, "first run saw the passing test");
like($out->{output}, qr{lastlog\.jsonl}, "first run created lastlog symlink");
},
);

# Step 2: Verify the lastlog.jsonl symlink exists
ok(-e './lastlog.jsonl', 'lastlog.jsonl symlink exists after first run');

# Step 3: Run --rerun-failed without specifying a log path
yath(
command => 'test',
args => ['--rerun-failed', '--ext=tx'],
exit => T(),
test => sub {
my $out = shift;
like($out->{output}, qr{fail\.tx}, "rerun-failed ran the failed test");
unlike($out->{output}, qr{pass\.tx}, "rerun-failed did not run the passing test");
},
);

# Cleanup the lastlog symlink we created
unlink('./lastlog.jsonl');

done_testing;
5 changes: 5 additions & 0 deletions t/integration/rerun_failed/fail.tx
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
use Test2::V0;

ok(0, "Fail");

done_testing;
5 changes: 5 additions & 0 deletions t/integration/rerun_failed/pass.tx
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
use Test2::V0;

ok(1, "Pass");

done_testing;
Loading