Re: Why *not* use UNIVERSAL qw( isa can ) ; ??
[p5sagit/p5-mst-13.2.git] / t / op / system_tests
1 #!perl
2
3 use Cwd;
4 use strict;
5
6 $| = 1;
7
8 my $cwdb = my $cwd = cwd();
9 $cwd =~ s,\\,/,g;
10 $cwdb =~ s,/,\\,g;
11
12 my $testdir = "t e s t";
13 my $exename = "showav";
14 my $plxname = "showargv";
15
16 my $exe = "$testdir/$exename";
17 my $exex = $exe . ".exe";
18 (my $exeb = $exe) =~ s,/,\\,g;
19 my $exebx = $exeb . ".exe";
20
21 my $bat = "$testdir/$plxname";
22 my $batx = $bat . ".bat";
23 (my $batb = $bat) =~ s,/,\\,g;
24 my $batbx = $batb . ".bat";
25
26 my $cmdx = $bat . ".cmd";
27 my $cmdb = $batb;
28 my $cmdbx = $cmdb . ".cmd";
29
30 my @commands = (
31   $exe,
32   $exex,
33   $exeb,
34   $exebx,
35   "./$exe",
36   "./$exex",
37   ".\\$exeb",
38   ".\\$exebx",
39   "$cwd/$exe",
40   "$cwd/$exex",
41   "$cwdb\\$exeb",
42   "$cwdb\\$exebx",
43   $bat,
44   $batx,
45   $batb,
46   $batbx,
47   "./$bat",
48   "./$batx",
49   ".\\$batb",
50   ".\\$batbx",
51   "$cwd/$bat",
52   "$cwd/$batx",
53   "$cwdb\\$batb",
54   "$cwdb\\$batbx",
55   $cmdx,
56   $cmdbx,
57   "./$cmdx",
58   ".\\$cmdbx",
59   "$cwd/$cmdx",
60   "$cwdb\\$cmdbx",
61   [$^X, $batx],
62   [$^X, $batbx],
63   [$^X, "./$batx"],
64   [$^X, ".\\$batbx"],
65   [$^X, "$cwd/$batx"],
66   [$^X, "$cwdb\\$batbx"],
67 );
68
69 my @av = (
70   undef,
71   "",
72   " ",
73   "abc",
74   "a b\tc",
75   "\tabc",
76   "abc\t",
77   " abc\t",
78   "\ta b c ",
79   ["\ta b c ", ""],
80   ["\ta b c ", " "],
81   ["", "\ta b c ", "abc"],
82   [" ", "\ta b c ", "abc"],
83 );
84
85 print "1.." . (@commands * @av * 2) . "\n";
86 for my $cmds (@commands) {
87     for my $args (@av) {
88         my @all_args;
89         my @cmds = defined($cmds) ? (ref($cmds) ? @$cmds : $cmds) : ();
90         my @args = defined($args) ? (ref($args) ? @$args : $args) : ();
91         print "######## [@cmds]\n";
92         print "<", join('><', $cmds[$#cmds], @args), ">\n";
93         if (system(@cmds,@args) != 0) {
94             print "Failed, status($?)\n";
95 #           print "Running again in debug mode\n";
96 #           $^D = 1; # -Dp
97 #           system(@cmds,@args);
98         }
99         $^D = 0;
100         my $cmdstr = join " ", map { /\s|^$/ ? qq["$_"] : $_ } @cmds, @args;
101         print "######## '$cmdstr'\n";
102         if (system($cmdstr) != 0) {
103             print "Failed, status($?)\n";
104 #           print "Running again in debug mode\n";
105 #           $^D = 1; # -Dp
106 #           system($cmdstr);
107         }
108         $^D = 0;
109     }
110 }