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