Changeset 2052

Show
Ignore:
Timestamp:
03/09/08 03:22:11 (2 months ago)
Author:
joshr
Message:

skip valgrind test unless valgrind is found in the user's PATH.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • Swishetest/trunk/t/025-valgrind.t

    r2044 r2052  
    66######################### 
    77 
    8 # change 'tests => 1' to 'tests => last_test_to_print'; 
    9  
    10 use Test::More tests => 3; 
     8use Test::More;  
     9use File::Path qw(mkpath); 
    1110use Swishetest; 
    1211 
    13 BEGIN {  
    14     use File::Path qw(mkpath); 
     12############################################ 
     13main(); 
     14 
     15############################################ 
     16sub main { 
    1517    mkpath( ["blib/index"], 0, 0755); 
    1618 
     
    1921                    data/C020-words-txt/words-osx-10_3.txt ); 
    2022 
     23    my $valgrind = mywhich( "valgrind" ); 
     24    unless( $valgrind ) { 
     25        plan tests => 1; 
     26        ok( 1, "skipping, valgrind not found" ); 
     27        exit(0); 
     28    } 
     29    plan tests => scalar( @docs ); 
    2130    for my $doc (@docs) { 
    2231        #my $valgrind_options = "--show-below-main=yes --leak-check=full --show-reachable=yes -v"; 
     
    2635        ok(1, "valgrind indexing $doc" ); 
    2736    } 
     37}; 
    2838 
    29 }; 
     39############################################ 
     40sub mywhich {   # so we don't have to use File::Which 
     41    my $exe = shift; 
     42    my @dirs = split( /:/, $ENV{PATH} || "" ); 
     43    for my $dir (@dirs) { 
     44        if (-x "$dir/$exe") { 
     45            return "$dir/$exe"; 
     46        } 
     47    } 
     48    return; # not found 
     49