1 # driver.pm - common test driver code
6 *CORE::GLOBAL::syswrite =
7 sub(*\$$;$) { my( $h, $b, $s ) = @_; CORE::syswrite $h, $b, $s } ;
9 *CORE::GLOBAL::sysread =
10 sub(*\$$;$) { my( $h, $b, $s ) = @_; CORE::sysread $h, $b, $s } ;
19 # plan for one expected ok() call per test
21 plan( tests => scalar @{$tests} ) ;
23 # loop over all the tests
25 foreach my $test ( @{$tests} ) {
29 if ( $test->{skip} ) {
30 ok( 1, "SKIPPING $test->{name}" ) ;
34 my $override = $test->{override} ;
36 # run any setup sub before this test. this can is used to modify the
37 # object for this test (e.g. delete templates from the cache).
39 if( my $pretest = $test->{pretest} ) {
44 my $sub = $test->{sub} ;
45 my $args = $test->{args} ;
48 local *{"CORE::GLOBAL::$override"} = sub {} if $override ;
54 # if we had an error and expected it, we pass this test
58 if ( $test->{error} && $@ =~ /$test->{error}/ ) {
60 ok( 1, $test->{name} ) ;
65 print "unexpected error: $@\n" ;
66 ok( 0, $test->{name} ) ;
70 if( my $posttest = $test->{posttest} ) {