This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Upgrade to version.pm 0.71, by John Peacock
[perl5.git] / lib / Shell.t
1 #!./perl
2
3 BEGIN {
4     if( $ENV{PERL_CORE} ) {
5         chdir 't' if -d 't';
6         @INC = '../lib';
7     }
8 }
9
10 use Test::More tests => 7;
11
12 BEGIN { use_ok('Shell'); }
13
14 my $so = Shell->new;
15 ok($so, 'Shell->new');
16
17 my $Is_VMS     = $^O eq 'VMS';
18 my $Is_MSWin32 = $^O eq 'MSWin32';
19 my $Is_NetWare = $^O eq 'NetWare';
20
21 $Shell::capture_stderr = 1;
22
23 # Now test that that works ..
24
25 my $tmpfile = 'sht0001';
26 while ( -f $tmpfile ) {
27     $tmpfile++;
28 }
29 END { -f $tmpfile && (open STDERR, '>&SAVERR' and unlink $tmpfile) }
30
31
32 open(SAVERR, ">&STDERR");
33 open(STDERR, ">$tmpfile");
34
35 xXx_not_there();  # Ok someone could have a program called this :(
36
37 # On os2 the warning is on by default...
38 ok(($^O eq 'os2' xor !(-s $tmpfile)), '$Shell::capture_stderr');
39
40 $Shell::capture_stderr = 0;
41
42 # someone will have to fill in the blanks for other platforms
43
44 if ($Is_VMS) {
45     ok(directory(), 'Execute command');
46     my @files = directory('*.*');
47     ok(@files, 'Quoted arguments');
48
49     ok(eq_array(\@files, [$so->directory('*.*')]), 'object method');
50     eval { $so->directory };
51     ok(!$@, '2 methods calls');
52 } elsif ($Is_MSWin32) {
53     ok(dir(), 'Execute command');
54     my @files = dir('*.*');
55     ok(@files, 'Quoted arguments');
56
57     ok(eq_array(\@files, [$so->dir('*.*')]), 'object method');
58     eval { $so->dir };
59     ok(!$@, '2 methods calls');
60 } else {
61     ok(ls(), 'Execute command');
62     my @files = ls('*');
63     ok(@files, 'Quoted arguments');
64
65     ok(eq_array(\@files, [$so->ls('*')]), 'object method');
66     eval { $so->ls };
67     ok(!$@, '2 methods calls');
68
69 }
70 open(STDERR, ">&SAVERR") ;