blob: f093ed8f8f22ec905cc4eabf9417cd64bed439ef [file] [log] [blame]
Johnny Chen3d7e6872010-07-01 23:01:23 +00001#!/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/..");
Johnny Chendb3d8742010-09-01 00:55:36 +000019my $pluginDir = "$baseDir/test/plugins";
Johnny Chen3d7e6872010-07-01 23:01:23 +000020my $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) {
Johnny Chendb3d8742010-09-01 00:55:36 +000025 $ENV{'PYTHONPATH'} = "$dbgPath:$scriptDir:$pluginDir";
Johnny Chen3d7e6872010-07-01 23:01:23 +000026} elsif (-d $relPath) {
Johnny Chendb3d8742010-09-01 00:55:36 +000027 $ENV{'PYTHONPATH'} = "$relPath:$scriptDir:$pluginDir";
Johnny Chen3d7e6872010-07-01 23:01:23 +000028}
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}