Commit | Line | Data |
e66df073 |
1 | #!./perl |
2 | |
51947a20 |
3 | use Test::More tests => 7; |
e66df073 |
4 | |
5 | BEGIN { use_ok('Shell'); } |
6 | |
51947a20 |
7 | my $so = Shell->new; |
8 | ok($so, 'Shell->new'); |
9 | |
e66df073 |
10 | my $Is_VMS = $^O eq 'VMS'; |
11 | my $Is_MSWin32 = $^O eq 'MSWin32'; |
12 | my $Is_NetWare = $^O eq 'NetWare'; |
13 | |
51947a20 |
14 | $Shell::capture_stderr = 1; |
e66df073 |
15 | |
16 | # Now test that that works .. |
17 | |
18 | my $tmpfile = 'sht0001'; |
51947a20 |
19 | while ( -f $tmpfile ) { |
20 | $tmpfile++; |
e66df073 |
21 | } |
51947a20 |
22 | END { -f $tmpfile && (open STDERR, '>&SAVERR' and unlink $tmpfile) } |
e66df073 |
23 | |
ad9da128 |
24 | no warnings 'once'; |
25 | # no false warning about Name "main::SAVERR" used only once: possible typo |
e66df073 |
26 | |
51947a20 |
27 | open(SAVERR, ">&STDERR"); |
e66df073 |
28 | open(STDERR, ">$tmpfile"); |
29 | |
670c206d |
30 | xXx_not_there(); # Ok someone could have a program called this :( |
e66df073 |
31 | |
dfcfdb64 |
32 | # On os2 the warning is on by default... |
51947a20 |
33 | ok(($^O eq 'os2' xor !(-s $tmpfile)), '$Shell::capture_stderr'); |
e66df073 |
34 | |
51947a20 |
35 | $Shell::capture_stderr = 0; |
e66df073 |
36 | |
37 | # someone will have to fill in the blanks for other platforms |
38 | |
51947a20 |
39 | if ($Is_VMS) { |
40 | ok(directory(), 'Execute command'); |
72c157b0 |
41 | my @files = directory('*.*'); |
51947a20 |
42 | ok(@files, 'Quoted arguments'); |
43 | |
44 | ok(eq_array(\@files, [$so->directory('*.*')]), 'object method'); |
45 | eval { $so->directory }; |
46 | ok(!$@, '2 methods calls'); |
47 | } elsif ($Is_MSWin32) { |
48 | ok(dir(), 'Execute command'); |
49 | my @files = dir('*.*'); |
50 | ok(@files, 'Quoted arguments'); |
51 | |
52 | ok(eq_array(\@files, [$so->dir('*.*')]), 'object method'); |
53 | eval { $so->dir }; |
54 | ok(!$@, '2 methods calls'); |
55 | } else { |
56 | ok(ls(), 'Execute command'); |
57 | my @files = ls('*'); |
58 | ok(@files, 'Quoted arguments'); |
59 | |
60 | ok(eq_array(\@files, [$so->ls('*')]), 'object method'); |
61 | eval { $so->ls }; |
62 | ok(!$@, '2 methods calls'); |
e66df073 |
63 | |
64 | } |
51947a20 |
65 | open(STDERR, ">&SAVERR") ; |