Home | History | Annotate | Download | only in attic
      1 #!/usr/bin/perl -w
      2 
      3 #
      4 # Use this script to visit each python test case under the specified directory
      5 # and invoke unittest.main() on each test case.
      6 #
      7 
      8 use strict;
      9 use FindBin;
     10 use File::Find;
     11 use File::Basename;
     12 use Cwd;
     13 use Cwd 'abs_path';
     14 
     15 scalar(@ARGV) == 1 or die "Usage: dotest.pl testdir";
     16 
     17 my $scriptDir = $FindBin::Bin;
     18 my $baseDir = abs_path("$scriptDir/..");
     19 my $pluginDir = "$baseDir/test/plugins";
     20 my $testDir = $ARGV[0];
     21 
     22 my $dbgPath = "$baseDir/build/Debug/LLDB.framework/Resources/Python";
     23 my $relPath = "$baseDir/build/Release/LLDB.framework/Resources/Python";
     24 if (-d $dbgPath) {
     25   $ENV{'PYTHONPATH'} = "$dbgPath:$scriptDir:$pluginDir";
     26 } elsif (-d $relPath) {
     27   $ENV{'PYTHONPATH'} = "$relPath:$scriptDir:$pluginDir";
     28 }
     29 #print("ENV{PYTHONPATH}=$ENV{'PYTHONPATH'}\n");
     30 
     31 # Traverse the directory to find our python test cases.
     32 find(\&handleFind, $testDir);
     33 
     34 sub handleFind {
     35   my $foundFile = $File::Find::name;
     36   my $dir = getcwd;
     37   #print("foundFile: $foundFile\n");
     38   
     39   # Test*.py is the naming pattern for our test cases.
     40   if ($foundFile =~ /.*\/(Test.*\.py)$/) {
     41     print("Running python $1 (cwd = $dir)...\n");
     42     system("python $1");
     43   }
     44 }
     45