X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FShell.t;h=51f54a1bf8565f6c10bb4dc8d40a009514a2dc6f;hb=9b5be9b5aa498a302ab752a0d1cdb335a620ede2;hp=5ff0b16087efa914fb0b343237f464919608b0ce;hpb=e66df07321b4a66bafe24ee0eb6883a0274bbb47;p=p5sagit%2Fp5-mst-13.2.git diff --git a/lib/Shell.t b/lib/Shell.t index 5ff0b16..51f54a1 100644 --- a/lib/Shell.t +++ b/lib/Shell.t @@ -1,59 +1,70 @@ #!./perl -use Test::More tests => 4; +BEGIN { + if( $ENV{PERL_CORE} ) { + chdir 't' if -d 't'; + @INC = '../lib'; + } +} + +use Test::More tests => 7; BEGIN { use_ok('Shell'); } +my $so = Shell->new; +ok($so, 'Shell->new'); + my $Is_VMS = $^O eq 'VMS'; my $Is_MSWin32 = $^O eq 'MSWin32'; my $Is_NetWare = $^O eq 'NetWare'; -$Shell::capture_stderr = 1; # +$Shell::capture_stderr = 1; # Now test that that works .. my $tmpfile = 'sht0001'; - -while ( -f $tmpfile ) -{ - $tmpfile++; +while ( -f $tmpfile ) { + $tmpfile++; } - -END { -f $tmpfile && unlink $tmpfile }; - +END { -f $tmpfile && (open STDERR, '>&SAVERR' and unlink $tmpfile) } -open(SAVERR,">&STDERR") ; +open(SAVERR, ">&STDERR"); open(STDERR, ">$tmpfile"); -xXx(); # Ok someone could have a program called this :( +xXx_not_there(); # Ok someone could have a program called this :( -ok( !(-s $tmpfile) ,'$Shell::capture_stderr'); +# On os2 the warning is on by default... +ok(($^O eq 'os2' xor !(-s $tmpfile)), '$Shell::capture_stderr'); -$Shell::capture_stderr = 0; # +$Shell::capture_stderr = 0; # someone will have to fill in the blanks for other platforms -if ( $Is_VMS ) -{ - skip "Please implement VMS test", 2; - ok(1); - ok(1); -} -elsif( $Is_MSWin32 ) -{ - ok(dir(),'Execute command'); - - my @files = dir('*.*'); - - ok(@files, 'Quoted arguments'); -} -else -{ - ok(ls(),'Execute command'); - - my @files = ls('*'); - - ok(@files,'Quoted arguments'); +if ($Is_VMS) { + ok(directory(), 'Execute command'); + my @files = directory('*.*'); + ok(@files, 'Quoted arguments'); + + ok(eq_array(\@files, [$so->directory('*.*')]), 'object method'); + eval { $so->directory }; + ok(!$@, '2 methods calls'); +} elsif ($Is_MSWin32) { + ok(dir(), 'Execute command'); + my @files = dir('*.*'); + ok(@files, 'Quoted arguments'); + + ok(eq_array(\@files, [$so->dir('*.*')]), 'object method'); + eval { $so->dir }; + ok(!$@, '2 methods calls'); +} else { + ok(ls(), 'Execute command'); + my @files = ls('*'); + ok(@files, 'Quoted arguments'); + + ok(eq_array(\@files, [$so->ls('*')]), 'object method'); + eval { $so->ls }; + ok(!$@, '2 methods calls'); } +open(STDERR, ">&SAVERR") ;