Skip to content

Commit

Permalink
ci: test empty string argument instead of number
Browse files Browse the repository at this point in the history
Giving an empty string instead of a number as option argument
was not reliably caught, see GH issue schweikert#324 and GH PR schweikert#323.
  • Loading branch information
auerswal committed Jun 23, 2024
1 parent 94de791 commit 51daca0
Showing 1 changed file with 15 additions and 10 deletions.
25 changes: 15 additions & 10 deletions ci/test-12-option-type.pl
Original file line number Diff line number Diff line change
@@ -1,22 +1,27 @@
#!/usr/bin/perl -w

use Test::Command tests => 42;
use Test::Command tests => 84;
use Test::More;

# some options require a numeric argument
for my $arg (qw(b B c C H i O p Q r t x X)) {
my $cmd = Test::Command->new(cmd => "fping -$arg xxx");
$cmd->exit_is_num(1);
$cmd->stdout_is_eq("");
$cmd->stderr_like(qr{Usage:});
for my $test_input (qw(xxx '')) {
my $cmd = Test::Command->new(cmd => "fping -$arg $test_input");
$cmd->exit_is_num(1);
$cmd->stdout_is_eq("");
$cmd->stderr_like(qr{Usage:});
}
}

# fping -k, only supported on Linux, requires a number
SKIP: {
if($^O ne 'linux') {
skip '-k option is only supported on Linux', 3;
skip '-k option is only supported on Linux', 6;
}
for my $test_input (qw(xxx '')) {
my $cmd = Test::Command->new(cmd => "fping -k $test_input 127.0.0.1");
$cmd->exit_is_num(1);
$cmd->stdout_is_eq("");
$cmd->stderr_like(qr{Usage:});
}
my $cmd = Test::Command->new(cmd => 'fping -k xxx 127.0.0.1');
$cmd->exit_is_num(1);
$cmd->stdout_is_eq("");
$cmd->stderr_like(qr{Usage:});
}

0 comments on commit 51daca0

Please sign in to comment.