This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Avoid unnecessarily skipping a test to set $0
authorTom Hukins <tom@eborcom.com>
Wed, 2 Dec 2020 17:39:35 +0000 (17:39 +0000)
committerKarl Williamson <khw@cpan.org>
Sat, 5 Dec 2020 18:57:24 +0000 (11:57 -0700)
The absence of /proc/$$/cmdline doesn't mean running ps(1) won't work.

t/op/magic.t

index 3f23648..1fceded 100644 (file)
@@ -798,13 +798,17 @@ SKIP: {
 
     SKIP: {
            skip("\$0 check only on Linux, Dragonfly BSD and FreeBSD", 2)
-               unless $^O =~ /^(linux|android|dragonfly|freebsd)$/
-                   && open CMDLINE, "/proc/$$/cmdline";
+               unless $^O =~ /^(linux|android|dragonfly|freebsd)$/;
 
-           chomp(my $line = scalar <CMDLINE>);
-           my $me = (split /\0/, $line)[0];
-           is $me, $0, 'altering $0 is effective (testing with /proc/)';
-           close CMDLINE;
+            SKIP: {
+                skip("No procfs cmdline support", 1)
+                    unless open CMDLINE, "/proc/$$/cmdline";
+
+                chomp(my $line = scalar <CMDLINE>);
+                my $me = (split /\0/, $line)[0];
+                is $me, $0, 'altering $0 is effective (testing with /proc/)';
+                close CMDLINE;
+            }
             skip("No \$0 check with 'ps' on Android", 1) if $^O eq 'android';
             # perlbug #22811
             my $mydollarzero = sub {