fanout tests: capture warnings and test their relevance

This commit is contained in:
Graham Christensen 2022-01-24 16:07:42 -05:00
parent bc1630bd27
commit 38514ae494

View file

@ -121,47 +121,61 @@ subtest "isBuildEligibleForDynamicRunCommand" => sub {
}; };
subtest "On outputs ..." => sub { subtest "On outputs ..." => sub {
is( ok(!warns {
Hydra::Plugin::RunCommand::isBuildEligibleForDynamicRunCommand($builds->{"runCommandHook.example"}), is(
1, Hydra::Plugin::RunCommand::isBuildEligibleForDynamicRunCommand($builds->{"runCommandHook.example"}),
"out is an executable file" 1,
); "out is an executable file"
);
}, "No warnings for an executable file.");
is( ok(!warns {
Hydra::Plugin::RunCommand::isBuildEligibleForDynamicRunCommand($builds->{"runCommandHook.symlink"}), is(
1, Hydra::Plugin::RunCommand::isBuildEligibleForDynamicRunCommand($builds->{"runCommandHook.symlink"}),
"out is a symlink to an executable file" 1,
); "out is a symlink to an executable file"
);
}, "No warnings for a symlink to an executable file.");
is( like(warning {
Hydra::Plugin::RunCommand::isBuildEligibleForDynamicRunCommand($builds->{"runCommandHook.no-out"}), is(
0, Hydra::Plugin::RunCommand::isBuildEligibleForDynamicRunCommand($builds->{"runCommandHook.no-out"}),
"No output named out" 0,
); "No output named out"
);
}, qr/rejected: no output named 'out'/, "A relevant warning is provided for a missing output");
is( like(warning {
Hydra::Plugin::RunCommand::isBuildEligibleForDynamicRunCommand($builds->{"runCommandHook.out-is-directory"}), is(
0, Hydra::Plugin::RunCommand::isBuildEligibleForDynamicRunCommand($builds->{"runCommandHook.out-is-directory"}),
"out is a directory" 0,
); "out is a directory"
);
}, qr/output is not a regular file or symlink/, "A relevant warning is provided for a directory output");
is( like(warning {
Hydra::Plugin::RunCommand::isBuildEligibleForDynamicRunCommand($builds->{"runCommandHook.out-is-not-executable-file"}), is(
0, Hydra::Plugin::RunCommand::isBuildEligibleForDynamicRunCommand($builds->{"runCommandHook.out-is-not-executable-file"}),
"out is a file which is not not executable" 0,
); "out is a file which is not a regular file or symlink"
);
}, qr/output is not executable/, "A relevant warning is provided if the file isn't executable");
is( like(warning {
Hydra::Plugin::RunCommand::isBuildEligibleForDynamicRunCommand($builds->{"runCommandHook.symlink-non-executable"}), is(
0, Hydra::Plugin::RunCommand::isBuildEligibleForDynamicRunCommand($builds->{"runCommandHook.symlink-non-executable"}),
"out is a symlink to a non-executable file" 0,
); "out is a symlink to a non-executable file"
);
}, qr/output is not executable/, "A relevant warning is provided for symlinks to non-executables");
is( like(warning {
Hydra::Plugin::RunCommand::isBuildEligibleForDynamicRunCommand($builds->{"runCommandHook.symlink-directory"}), is(
0, Hydra::Plugin::RunCommand::isBuildEligibleForDynamicRunCommand($builds->{"runCommandHook.symlink-directory"}),
"out is a symlink to a directory" 0,
); "out is a symlink to a directory"
);
}, qr/output is not a regular file or symlink/, "A relevant warning is provided for symlinks to directories");
}; };
subtest "On build status ..." => sub { subtest "On build status ..." => sub {