]> git.gsnw.org Git - fping.git/commitdiff
ci: test empty string argument instead of number
authorErik Auerswald <auerswal@unix-ag.uni-kl.de>
Sun, 23 Jun 2024 15:04:48 +0000 (17:04 +0200)
committerErik Auerswald <auerswal@unix-ag.uni-kl.de>
Fri, 28 Jun 2024 17:18:22 +0000 (19:18 +0200)
Giving an empty string instead of a number as option argument
was not reliably caught, see GH issue #324 and GH PR #323.

ci/test-12-option-type.pl

index c3ca51f63bae47adcad4267a8f566214df8b5414..6514425af01a8dc1c0c3daa42c7562a2d9e25d04 100755 (executable)
@@ -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:});
 }