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