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