This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Update Pod::Simple from version 3.38 to 3.39
[perl5.git] / t / test.pl
index 1782dcf..25eae40 100644 (file)
--- a/t/test.pl
+++ b/t/test.pl
@@ -19,6 +19,7 @@
 # In this file, we use the latter "Baby Perl" approach, and increment
 # will be worked over by t/op/inc.t
 
+$| = 1;
 $Level = 1;
 my $test = 1;
 my $planned;
@@ -199,7 +200,9 @@ sub find_git_or_skip {
            $source_dir = '.'
        }
     }
-    if ($source_dir) {
+    if ($ENV{'PERL_BUILD_PACKAGING'}) {
+       $reason = 'PERL_BUILD_PACKAGING is set';
+    } elsif ($source_dir) {
        my $version_string = `git --version`;
        if (defined $version_string
              && $version_string =~ /\Agit version (\d+\.\d+\.\d+)(.*)/) {
@@ -212,9 +215,6 @@ sub find_git_or_skip {
     } else {
        $reason = 'not being run from a git checkout';
     }
-    if ($ENV{'PERL_BUILD_PACKAGING'}) {
-       $reason = 'PERL_BUILD_PACKAGING is set';
-    }
     skip_all($reason) if $_[0] && $_[0] eq 'all';
     skip($reason, @_);
 }
@@ -917,7 +917,7 @@ $::tempfile_regexp = 'tmp\d+[A-Z][A-Z]?';
 my $tempfile_count = 0;
 sub tempfile {
     while(1){
-       my $try = "tmp$$";
+       my $try = (-d "t" ? "t/" : "")."tmp$$";
         my $alpha = _num_to_alpha($tempfile_count,2);
         last unless defined $alpha;
         $try = $try . $alpha;
@@ -1519,6 +1519,7 @@ sub capture_warnings {
 
     local @::__capture;
     local $SIG {__WARN__} = \&__capture;
+    local $Level = 1;
     &$code;
     return @::__capture;
 }
@@ -1745,4 +1746,18 @@ WATCHDOG_VIA_ALARM:
     }
 }
 
+# Orphaned Docker or Linux containers do not necessarily attach to PID 1. They might attach to 0 instead.
+sub is_linux_container {
+
+    if ($^O eq 'linux' && open my $fh, '<', '/proc/1/cgroup') {
+        while(<$fh>) {
+            if (m{^\d+:pids:(.*)} && $1 ne '/init.scope') {
+                return 1;
+            }
+        }
+    }
+
+    return 0;
+}
+
 1;