Changeset 7219


Ignore:
Timestamp:
04/19/10 17:23:01 (2 years ago)
Author:
MichaelTempest
Message:

Item1326: Report unexpected passes correctly

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/UnitTestContrib/lib/Unit/TestRunner.pm

    r7180 r7219  
    102102                $action = runOne($tester, $suite, $testToRun); 
    103103            } 
    104             ($action) = $action =~ m/^(.*)$/ms; 
     104            # untaint action for the case where the test is run in another process 
     105            ($action) = $action =~ m/^(.*)$/ms;  
     106 
    105107            eval $action; 
    106108            die $@ if $@; 
    107109            die "Test suite $suite aborted\n" unless $completed; 
    108110        } 
    109    } 
     111    } 
    110112 
    111113    if ( $this->{unexpected_failures} || $this->{unexpected_passes} ) { 
     114        $this->{unexpected_failures} ||= 0; 
     115        $this->{unexpected_passes} ||= 0; 
    112116        if ($this->{unexpected_failures}) { 
    113         print $this->{unexpected_failures} . " failure". 
     117            print $this->{unexpected_failures} . " failure". 
    114118                ($this->{unexpected_failures}>1?'s':''). 
    115119                "\n"; 
    116             } 
     120        } 
    117121        if ($this->{unexpected_passes}) { 
    118         print $this->{unexpected_passes} . " unexpected pass". 
     122            print $this->{unexpected_passes} . " unexpected pass". 
    119123                ($this->{unexpected_passes}>1?'es':''). 
    120124                "\n"; 
    121             } 
     125        } 
    122126        if (($passes + $this->{unexpected_failures}) > 1) { 
    123127            #don't print the failure a second time if there is only one test run - its really annoying. 
     
    125129            "\n"; 
    126130        } 
    127         $this->{unexpected_failures} ||= 0; 
    128131        print "$passes of ", $passes + $this->{unexpected_failures}, 
    129132          " test cases passed\n"; 
     
    280283    } 
    281284    foreach my $test (@tests) { 
    282                 #Devel::Leak::Object::checkpoint(); 
     285        #Devel::Leak::Object::checkpoint(); 
    283286        print "\t$test\n"; 
     287        $action .= "\n# $test\n    "; 
    284288        $tester->set_up(); 
    285289        try { 
    286290            $tester->$test(); 
    287291            $action .= '$passes++;'; 
     292            if ( $tester->{expect_failure} ) { 
     293                $action .= '$this->{unexpected_passes}++;'; 
     294            } 
    288295        } 
    289296        catch Error with { 
     
    297304            } 
    298305            $action .= 'push( @{ $this->{failures} }, "' 
    299                      . $test  
    300                      . '\n'  
     306                     . quotemeta( $test )  
     307                     . '\\n'  
    301308                     . quotemeta( $e->stringify() ) 
    302309                     . '" );'; 
    303         } 
    304         otherwise { 
    305             if ( $tester->{expect_failure} ) { 
    306                 $action .= '$this->{unexpected_passes}++;'; 
    307             } 
    308310        }; 
    309311        $tester->tear_down(); 
Note: See TracChangeset for help on using the changeset viewer.