This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
t/op/caller.t: add a TODO test for RT #129239
[perl5.git] / t / win32 / system.t
index bd65412..939a02d 100644 (file)
@@ -2,12 +2,17 @@
 
 BEGIN {
     chdir 't' if -d 't';
-    @INC = '../lib';
+    # We need '../../lib' as well as '../lib' because parts of Config are
+    # delay-loaded, after we've chdir()'ed into $testdir.
+    @INC = ('../lib', '../../lib');
     # XXX this could be further munged to enable some parts on other
     # platforms
+    require './test.pl';
+}
+
+BEGIN {
     unless ($^O =~ /^MSWin/) {
-       print "1..0 # skipped: windows specific test\n";
-       exit 0;
+        skip_all 'windows specific test';
     }
 }
 
@@ -78,8 +83,8 @@ chdir($testdir);
 END {
     chdir($cwd) && rmtree("$cwd/$testdir") if -d "$cwd/$testdir";
 }
-if (open(my $EIN, "$cwd/op/${exename}_exe.uu")) {
-    print "# Unpacking $exename.exe\n";
+if (open(my $EIN, "$cwd/win32/${exename}_exe.uu")) {
+    note "Unpacking $exename.exe";
     my $e;
     {
        local $/;
@@ -93,22 +98,22 @@ if (open(my $EIN, "$cwd/op/${exename}_exe.uu")) {
 }
 else {
     my $minus_o = '';
-    if ($Config{cc} eq 'gcc')
+    if ($Config{cc} =~ /\bgcc/i)
      {
       $minus_o = "-o $exename.exe";
      }
-    print "# Compiling $exename.c\n# $Config{cc} $Config{ccflags} $exename.c\n";
+    note "Compiling $exename.c";
+    note "$Config{cc} $Config{ccflags} $exename.c";
     if (system("$Config{cc} $Config{ccflags} $minus_o $exename.c >log 2>&1") != 0) {
-       print "# Could not compile $exename.c, status $?\n"
-            ."# Where is your C compiler?\n"
-            ."1..0 # skipped: can't build test executable\n";
-       exit(0);
+       note "Could not compile $exename.c, status $?";
+    note "Where is your C compiler?";
+    skip_all "can't build test executable";
     }
     unless (-f "$exename.exe") {
        if (open(LOG,'<log'))
          {
           while(<LOG>) {
-            print "# ",$_;
+              note $_;
           } 
          }
         else {
@@ -119,20 +124,18 @@ else {
 copy("$plxname.bat","$plxname.cmd");
 chdir($cwd);
 unless (-x "$testdir/$exename.exe") {
-    print "# Could not build $exename.exe\n"
-        ."1..0 # skipped: can't build test executable\n";
-    exit(0);
+    note "Could not build $exename.exe";
+    skip_all "can't build test executable";
 }
 
-open my $T, "$^X -I../lib -w op/system_tests |"
-    or die "Can't spawn op/system_tests: $!";
+open my $T, "$^X -I../lib -w win32/system_tests |"
+    or die "Can't spawn win32/system_tests: $!";
 my $expect;
 my $comment = "";
-my $test = 0;
 while (<$T>) {
     chomp;
-    if (/^1\.\./) {
-       print "$_\n";
+    if (s/^1\.\.//) {
+       plan $_;
     }
     elsif (/^#+\s(.*)$/) {
        $comment = $1;
@@ -144,13 +147,11 @@ while (<$T>) {
     }
     else {
        if ($expect ne $_) {
-           print "# $comment\n" if $comment;
-           print "# want: $expect\n";
-           print "# got : $_\n";
-           print "not ";
+           note $comment if $comment;
+           note "want: $expect";
+           note "got : $_";
        }
-       ++$test;
-       print "ok $test\n";
+       ok($expect eq $_, $comment // '');
     }
 }
 close $T;