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 8use strict; 9use FindBin; 10use File::Find; 11use File::Basename; 12use Cwd; 13use Cwd 'abs_path'; 14 15scalar(@ARGV) == 1 or die "Usage: dotest.pl testdir"; 16 17my $scriptDir = $FindBin::Bin; 18my $baseDir = abs_path("$scriptDir/.."); 19my $pluginDir = "$baseDir/test/plugins"; 20my $testDir = $ARGV[0]; 21 22my $dbgPath = "$baseDir/build/Debug/LLDB.framework/Resources/Python"; 23my $relPath = "$baseDir/build/Release/LLDB.framework/Resources/Python"; 24if (-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. 32find(\&handleFind, $testDir); 33 34sub 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