| 1 |
use Test2::V0; |
| 2 |
|
| 3 |
use File::Temp qw/tempdir/; |
| 4 |
use File::Spec; |
| 5 |
|
| 6 |
use App::Yath::Tester qw/yath/; |
| 7 |
use Test2::Harness::Util::File::JSONL; |
| 8 |
|
| 9 |
use Test2::Harness::Util::JSON qw/decode_json/; |
| 10 |
|
| 11 |
my $dir = __FILE__; |
| 12 |
$dir =~ s{\.t$}{}g; |
| 13 |
$dir =~ s{^\./}{}; |
| 14 |
|
| 15 |
sub clean_output { |
| 16 |
my $out = shift; |
| 17 |
|
| 18 |
$out->{output} =~ s/^.*duration.*$//m; |
| 19 |
$out->{output} =~ s/^.*Wrote log file:.*$//m; |
| 20 |
$out->{output} =~ s/^.*Symlinked to:.*$//m; |
| 21 |
$out->{output} =~ s/^\s*Wall Time:.*seconds//m; |
| 22 |
$out->{output} =~ s/^\s*CPU Time:.*s\)//m; |
| 23 |
$out->{output} =~ s/^\s*CPU Usage:.*%//m; |
| 24 |
$out->{output} =~ s/^\s*-+$//m; |
| 25 |
$out->{output} =~ s/^\s+$//m; |
| 26 |
$out->{output} =~ s/\n+/\n/g; |
| 27 |
$out->{output} =~ s/^\s+//mg; |
| 28 |
} |
| 29 |
|
| 30 |
my $out1 = yath( |
| 31 |
command => 'test', |
| 32 |
args => [$dir, '--ext=tx'], |
| 33 |
log => 1, |
| 34 |
exit => T(), |
| 35 |
test => sub { |
| 36 |
my $out = shift; |
| 37 |
clean_output($out); |
| 38 |
|
| 39 |
like($out->{output}, qr{FAILED.*fail\.tx}, "'fail.tx' was seen as a failure when reading the log"); |
| 40 |
like($out->{output}, qr{PASSED.*pass\.tx}, "'pass.tx' was not seen as a failure when reading the log"); |
| 41 |
|
| 42 |
}, |
| 43 |
); |
| 44 |
|
| 45 |
my $logfile = $out1->{log}->name; |
| 46 |
|
| 47 |
yath( |
| 48 |
command => 'replay', |
| 49 |
args => [$logfile], |
| 50 |
exit => $out1->{exit}, |
| 51 |
test => sub { |
| 52 |
my $out2 = shift; |
| 53 |
clean_output($out2); |
| 54 |
clean_output($out1); |
| 55 |
|
| 56 |
is($out2->{output}, $out1->{output}, "Replay has identical output to original"); |
| 57 |
}, |
| 58 |
); |
| 59 |
|
| 60 |
done_testing; |