Johnny Chen | 3d7e687 | 2010-07-01 23:01:23 +0000 | [diff] [blame] | 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/.."); |
Johnny Chen | db3d874 | 2010-09-01 00:55:36 +0000 | [diff] [blame] | 19 | my $pluginDir = "$baseDir/test/plugins"; |
Johnny Chen | 3d7e687 | 2010-07-01 23:01:23 +0000 | [diff] [blame] | 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) { |
Johnny Chen | db3d874 | 2010-09-01 00:55:36 +0000 | [diff] [blame] | 25 | $ENV{'PYTHONPATH'} = "$dbgPath:$scriptDir:$pluginDir"; |
Johnny Chen | 3d7e687 | 2010-07-01 23:01:23 +0000 | [diff] [blame] | 26 | } elsif (-d $relPath) { |
Johnny Chen | db3d874 | 2010-09-01 00:55:36 +0000 | [diff] [blame] | 27 | $ENV{'PYTHONPATH'} = "$relPath:$scriptDir:$pluginDir"; |
Johnny Chen | 3d7e687 | 2010-07-01 23:01:23 +0000 | [diff] [blame] | 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 | } |