llvm-capstone/lldb/test/dotest.pl
Johnny Chen bf6ffa3b89 Abstracted the lldb-specific unittest.TestCase.setUp()/tearDown() in a separate
module lldbtest.py and refactored the existing test cases to derive from the
abstract base class lldbtest.TestBase.

MOdified the test driver (dotest.py and dotest.pl) to set up additional
PYTHONPATH component for locating the lldbtest module, which sits in the same
directory.

llvm-svn: 107563
2010-07-03 03:41:59 +00:00

44 lines
1.1 KiB
Perl
Executable File

#!/usr/bin/perl -w
#
# Use this script to visit each python test case under the specified directory
# and invoke unittest.main() on each test case.
#
use strict;
use FindBin;
use File::Find;
use File::Basename;
use Cwd;
use Cwd 'abs_path';
scalar(@ARGV) == 1 or die "Usage: dotest.pl testdir";
my $scriptDir = $FindBin::Bin;
my $baseDir = abs_path("$scriptDir/..");
my $testDir = $ARGV[0];
my $dbgPath = "$baseDir/build/Debug/LLDB.framework/Resources/Python";
my $relPath = "$baseDir/build/Release/LLDB.framework/Resources/Python";
if (-d $dbgPath) {
$ENV{'PYTHONPATH'} = "$dbgPath:$scriptDir";
} elsif (-d $relPath) {
$ENV{'PYTHONPATH'} = "$relPath:$scriptDir";
}
#print("ENV{PYTHONPATH}=$ENV{'PYTHONPATH'}\n");
# Traverse the directory to find our python test cases.
find(\&handleFind, $testDir);
sub handleFind {
my $foundFile = $File::Find::name;
my $dir = getcwd;
#print("foundFile: $foundFile\n");
# Test*.py is the naming pattern for our test cases.
if ($foundFile =~ /.*\/(Test.*\.py)$/) {
print("Running python $1 (cwd = $dir)...\n");
system("python $1");
}
}