Skip to content

Commit

Permalink
Stabilize tests by injecting no_app_path => 1 into yath() test runs.
Browse files Browse the repository at this point in the history
Injected a few .gitignores too.
  • Loading branch information
toddr committed Dec 28, 2023
1 parent 9345053 commit 8eff75d
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 47 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
*.o
*.pm.tdy
*.bs
*.ERR
*.bak

# Devel::Cover
cover_db/
Expand Down
1 change: 1 addition & 0 deletions Changes
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ Revision history for Test2-Harness-Renderer-JUnit
1.000005 2023-12-28 - Todd Rinaldo
- #15 - Fix POD Control sequence
- #17 - Allow for set_no_numbers format
- Stabilize tests by injecting no_app_path => 1 into yath() test runs.

1.000004 2021-05-13 - Todd Rinaldo
- Don't fail the whole run when you see a duplicate test. Just ammend the failure message.
Expand Down
99 changes: 52 additions & 47 deletions t/test.t
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ use App::Yath::Tester qw/yath/;
use Test2::Harness::Util::File::JSONL ();
use Test2::Harness::Renderer::JUnit ();

use Test2::Harness::Util qw/clean_path/;
use Test2::Harness::Util qw/clean_path/;
use Test2::Harness::Util::JSON qw/decode_json/;

#use Test2::Bundle::Extended;
Expand Down Expand Up @@ -43,11 +43,12 @@ my $env = { # env passed to yath
unlink $default_junit_xml if -e $default_junit_xml;

yath(
command => 'test',
args => [ $sdir, '--ext=tx', @renderers, '-v' ],
exit => 0,
env => $env,
test => sub {
command => 'test',
args => [ $sdir, '--ext=tx', @renderers, '-v' ],
exit => 0,
env => $env,
no_app_path => 1,
test => sub {
my $out = shift;

like(
Expand All @@ -72,19 +73,19 @@ my $env = { # env passed to yath
}

{
note
"all tests are ok - JUNIT_TEST_FILE not reachable - No such file or directory";
note "all tests are ok - JUNIT_TEST_FILE not reachable - No such file or directory";

my $sdir = $dir . '-ok';

$env->{JUNIT_TEST_FILE} = "$tmpdir/x/y/z/ok.xml";

yath(
command => 'test',
args => [ $sdir, '--ext=tx', @renderers, '-v' ],
exit => T(),
env => $env,
test => sub {
command => 'test',
args => [ $sdir, '--ext=tx', @renderers, '-v' ],
exit => T(),
env => $env,
no_app_path => 1,
test => sub {
my $out = shift;

like(
Expand Down Expand Up @@ -115,11 +116,12 @@ my $env = { # env passed to yath
$env->{JUNIT_TEST_FILE} = "$tmpdir/ok.xml";

yath(
command => 'test',
args => [ $sdir, '--ext=tx', @renderers, '-v' ],
exit => 0,
env => $env,
test => sub {
command => 'test',
args => [ $sdir, '--ext=tx', @renderers, '-v' ],
exit => 0,
env => $env,
no_app_path => 1,
test => sub {
my $out = shift;

like(
Expand Down Expand Up @@ -219,11 +221,12 @@ my $env = { # env passed to yath
$env->{JUNIT_TEST_FILE} = "$tmpdir/no-numbers.xml";

yath(
command => 'test',
args => [ $sdir, '--ext=tx', @renderers, '-v' ],
exit => 0,
env => $env,
test => sub {
command => 'test',
args => [ $sdir, '--ext=tx', @renderers, '-v' ],
exit => 0,
env => $env,
no_app_path => 1,
test => sub {
my $out = shift;

like(
Expand Down Expand Up @@ -285,11 +288,12 @@ my $env = { # env passed to yath
$env->{JUNIT_TEST_FILE} = "$tmpdir/failure.xml";

yath(
command => 'test',
args => [ $sdir, '--ext=tx', @renderers, '-v' ],
exit => T(),
env => $env,
test => sub {
command => 'test',
args => [ $sdir, '--ext=tx', @renderers, '-v' ],
exit => T(),
env => $env,
no_app_path => 1,
test => sub {
my $out = shift;

like(
Expand Down Expand Up @@ -326,8 +330,7 @@ my $env = { # env passed to yath
field classname => 'test-fail_fail_tx';
field time => D();
field failure => hash {
field content => match
qr{not ok 0002 - this is a failure};
field content => match qr{not ok 0002 - this is a failure};
field message => 'not ok 0002 - this is a failure';
field type => 'TestFailed';
};
Expand Down Expand Up @@ -363,11 +366,12 @@ my $env = { # env passed to yath
$env->{JUNIT_TEST_FILE} = "$tmpdir/plan.xml";

yath(
command => 'test',
args => [ $sdir, '--ext=tx', @renderers, '-v' ],
exit => T(),
env => $env,
test => sub {
command => 'test',
args => [ $sdir, '--ext=tx', @renderers, '-v' ],
exit => T(),
env => $env,
no_app_path => 1,
test => sub {
my $out = shift;

like(
Expand Down Expand Up @@ -414,8 +418,7 @@ my $env = { # env passed to yath
field 'Test Plan Failure' => hash {
field classname => 'test-plan_plan_tx';
field time => D();
field failure => match
q[Planned for 4 assertions, but saw 2];
field failure => match q[Planned for 4 assertions, but saw 2];
end;
};

Expand Down Expand Up @@ -443,11 +446,12 @@ my $env = { # env passed to yath
$env->{JUNIT_TEST_FILE} = "$tmpdir/die.xml";

yath(
command => 'test',
args => [ $sdir, '--ext=tx', @renderers, '-v' ],
exit => T(),
env => $env,
test => sub {
command => 'test',
args => [ $sdir, '--ext=tx', @renderers, '-v' ],
exit => T(),
env => $env,
no_app_path => 1,
test => sub {
my $out = shift;

like(
Expand Down Expand Up @@ -522,11 +526,12 @@ my $env = { # env passed to yath
$env->{FAIL_ONCE} = 1;

yath(
command => 'test',
args => [ $sdir, '--ext=tx', @renderers, '-v', '--retry=1', ],
exit => 0,
env => $env,
test => sub {
command => 'test',
args => [ $sdir, '--ext=tx', @renderers, '-v', '--retry=1', ],
exit => 0,
env => $env,
no_app_path => 1,
test => sub {
my $out = shift;

like( $out->{output}, qr{FAIL.*Should fail once}, "one failure" );
Expand Down

0 comments on commit 8eff75d

Please sign in to comment.