converted t/win32.t/system* to test.pl style
authorMarcel Gruenauer <hanekomu@gmail.com>
Tue, 22 Jan 2013 19:15:08 +0000 (20:15 +0100)
committerSteve Hay <steve.m.hay@googlemail.com>
Wed, 12 Jun 2013 17:11:52 +0000 (18:11 +0100)
t/win32/system.t
t/win32/system_tests

index ba09210..b81c7ab 100644 (file)
@@ -7,9 +7,12 @@ BEGIN {
     @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';
     }
 }
 
@@ -81,7 +84,7 @@ END {
     chdir($cwd) && rmtree("$cwd/$testdir") if -d "$cwd/$testdir";
 }
 if (open(my $EIN, "$cwd/win32/${exename}_exe.uu")) {
-    print "# Unpacking $exename.exe\n";
+    note "Unpacking $exename.exe";
     my $e;
     {
        local $/;
@@ -99,18 +102,18 @@ else {
      {
       $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 {
@@ -121,16 +124,14 @@ 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 win32/system_tests |"
     or die "Can't spawn win32/system_tests: $!";
 my $expect;
 my $comment = "";
-my $test = 0;
 while (<$T>) {
     chomp;
     if (/^1\.\./) {
@@ -146,13 +147,11 @@ while (<$T>) {
     }
     else {
        if ($expect ne $_) {
-           print "# $comment\n" if $comment;
-           print "# want: $expect\n";
-           print "# got : $_\n";
-           print "not ";
-       }
-       ++$test;
-       print "ok $test\n";
+           note $comment if $comment;
+           note "want: $expect";
+           note "got : $_";
+    }
+    ok($expect eq $_);
     }
 }
 close $T;
index f73745a..7d2eb1c 100644 (file)
@@ -3,6 +3,7 @@
 use Config;
 use Cwd;
 use strict;
+use './test.pl';
 
 $| = 1;
 
@@ -84,13 +85,13 @@ my @av = (
   ['" "', 'a" "b" "c', "abc"],
 );
 
-print "1.." . (@commands * @av * 2) . "\n";
+plan @commands * @av * 2;
 for my $cmds (@commands) {
     for my $args (@av) {
        my @all_args;
        my @cmds = defined($cmds) ? (ref($cmds) ? @$cmds : $cmds) : ();
        my @args = defined($args) ? (ref($args) ? @$args : $args) : ();
-       print "######## [@cmds]\n";
+       note "####### [@cmds]";
        print "<", join('><',
                        $cmds[$#cmds],
                        map { my $x = $_; $x =~ s/"//g; $x } @args),
@@ -106,7 +107,7 @@ for my $cmds (@commands) {
        $^D = 0;
        my $cmdstr = join " ", map { /\s|^$/ && !/\"/
                                    ? qq["$_"] : $_ } @cmds, @args;
-       print "######## '$cmdstr'\n";
+       note "####### '$cmdstr'";
        if (system($cmdstr) != 0) {
            print "Failed, status($?)\n";
            if ($Config{ccflags} =~ /\bDDEBUGGING\b/) {