Commit | Line | Data |
e66df073 |
1 | #!./perl |
2 | |
dfcfdb64 |
3 | BEGIN { |
ff5c8f2a |
4 | if( $ENV{PERL_CORE} ) { |
ad9da128 |
5 | chdir 't' if -d 't'; |
6 | @INC = '../lib'; |
ff5c8f2a |
7 | } |
dfcfdb64 |
8 | } |
9 | |
51947a20 |
10 | use Test::More tests => 7; |
e66df073 |
11 | |
12 | BEGIN { use_ok('Shell'); } |
13 | |
51947a20 |
14 | my $so = Shell->new; |
15 | ok($so, 'Shell->new'); |
16 | |
e66df073 |
17 | my $Is_VMS = $^O eq 'VMS'; |
18 | my $Is_MSWin32 = $^O eq 'MSWin32'; |
19 | my $Is_NetWare = $^O eq 'NetWare'; |
20 | |
51947a20 |
21 | $Shell::capture_stderr = 1; |
e66df073 |
22 | |
23 | # Now test that that works .. |
24 | |
25 | my $tmpfile = 'sht0001'; |
51947a20 |
26 | while ( -f $tmpfile ) { |
27 | $tmpfile++; |
e66df073 |
28 | } |
51947a20 |
29 | END { -f $tmpfile && (open STDERR, '>&SAVERR' and unlink $tmpfile) } |
e66df073 |
30 | |
ad9da128 |
31 | no warnings 'once'; |
32 | # no false warning about Name "main::SAVERR" used only once: possible typo |
e66df073 |
33 | |
51947a20 |
34 | open(SAVERR, ">&STDERR"); |
e66df073 |
35 | open(STDERR, ">$tmpfile"); |
36 | |
670c206d |
37 | xXx_not_there(); # Ok someone could have a program called this :( |
e66df073 |
38 | |
dfcfdb64 |
39 | # On os2 the warning is on by default... |
51947a20 |
40 | ok(($^O eq 'os2' xor !(-s $tmpfile)), '$Shell::capture_stderr'); |
e66df073 |
41 | |
51947a20 |
42 | $Shell::capture_stderr = 0; |
e66df073 |
43 | |
75ff0aab |
44 | # Trying to do two repeated C<ls>s in t in core and expecting the same output |
45 | # is a race condition when tests are running in parallel, and using it as a |
46 | # temporary directory. So go somewhere quieter. |
a13fba34 |
47 | if ($ENV{PERL_CORE} && -d 'uni') { |
48 | chdir 'uni'; |
49 | $chdir++; |
50 | } |
75ff0aab |
51 | |
e66df073 |
52 | # someone will have to fill in the blanks for other platforms |
53 | |
51947a20 |
54 | if ($Is_VMS) { |
55 | ok(directory(), 'Execute command'); |
72c157b0 |
56 | my @files = directory('*.*'); |
51947a20 |
57 | ok(@files, 'Quoted arguments'); |
58 | |
59 | ok(eq_array(\@files, [$so->directory('*.*')]), 'object method'); |
60 | eval { $so->directory }; |
61 | ok(!$@, '2 methods calls'); |
62 | } elsif ($Is_MSWin32) { |
63 | ok(dir(), 'Execute command'); |
64 | my @files = dir('*.*'); |
65 | ok(@files, 'Quoted arguments'); |
66 | |
67 | ok(eq_array(\@files, [$so->dir('*.*')]), 'object method'); |
68 | eval { $so->dir }; |
69 | ok(!$@, '2 methods calls'); |
70 | } else { |
71 | ok(ls(), 'Execute command'); |
72 | my @files = ls('*'); |
73 | ok(@files, 'Quoted arguments'); |
74 | |
75 | ok(eq_array(\@files, [$so->ls('*')]), 'object method'); |
76 | eval { $so->ls }; |
77 | ok(!$@, '2 methods calls'); |
e66df073 |
78 | |
79 | } |
51947a20 |
80 | open(STDERR, ">&SAVERR") ; |
a13fba34 |
81 | |
82 | if ($chdir) { |
83 | chdir ".."; |
84 | } |