summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris Wilson <chris+github@qwirx.com>2015-12-12 22:48:56 +0000
committerChris Wilson <chris+github@qwirx.com>2015-12-12 22:48:56 +0000
commit6c20c44e7c2b3982d42277f067e129df66b4b23a (patch)
tree5008b6de0cc68a0df645bb6d3baa6b9a224c3472
parentab691c3c09cb1100ecd4a10a2516ce26e033860d (diff)
Add wrapper for running tests easily on MSVC/CMake
-rwxr-xr-xruntest.pl.in89
1 files changed, 84 insertions, 5 deletions
diff --git a/runtest.pl.in b/runtest.pl.in
index f01f2936..7d197d4c 100755
--- a/runtest.pl.in
+++ b/runtest.pl.in
@@ -3,7 +3,10 @@
use strict;
use warnings;
-use lib 'infrastructure';
+use File::Basename;
+chdir(dirname($0));
+use lib dirname($0).'/infrastructure';
+
use BoxPlatform;
my ($test_name,$test_mode) = @ARGV;
@@ -97,9 +100,65 @@ sub runtest
{
my ($t) = @_;
- # attempt to make this test
+ # Attempt to make this test.
my $flag = ($test_mode eq 'release')?(BoxPlatform::make_flag('RELEASE')):'';
- my $make_res = system("cd test/$t && $make_command $flag");
+ my ($make_res, $test_project_exe);
+
+ if($target_msvc)
+ {
+ $test_project_exe = "test_$t";
+ # Assume that MSVC projects are built with CMake, so we can use
+ # MSBuild to run the tests.
+ my $test_src_dir = "test\\$t";
+ my $test_dst_dir = "$test_mode\\test\\$t";
+
+ my @commands = (
+ "msbuild /nologo /consoleloggerparameters:ErrorsOnly ".
+ "infrastructure\\cmake\\$test_project_exe.vcxproj",
+ "xcopy /s /i /y /q $test_src_dir $test_dst_dir",
+ "copy infrastructure\\cmake\\$test_mode\\$test_project_exe.exe $test_dst_dir"
+ );
+
+ if(-d $test_dst_dir)
+ {
+ unshift @commands, "rmdir /s /q $test_dst_dir";
+ }
+
+ foreach my $command (@commands)
+ {
+ $make_res = system($command);
+ if ($make_res != 0)
+ {
+ push @results, "$t: make failed: $command";
+ last;
+ }
+ }
+
+ # Windows doesn't support testextra files either, so fake it.
+ if ($make_res == 0 and -r "$test_src_dir/testextra")
+ {
+ open EXTRA, "$test_src_dir/testextra"
+ or die "$test_src_dir/testextra: $!";
+ foreach my $line (<EXTRA>)
+ {
+ if ($line =~ m/^mkdir (.*)/)
+ {
+ mkdir("$test_dst_dir/$1")
+ or die "$test_dst_dir/$1: $!";
+ }
+ else
+ {
+ die "Unsupported command in ".
+ "$test_src_dir/testextra: $!";
+ }
+ }
+ }
+ }
+ else
+ {
+ $make_res = system("cd test/$t && $make_command $flag");
+ }
+
if($make_res != 0)
{
push @results,"$t: make failed";
@@ -108,10 +167,30 @@ sub runtest
}
my $logfile = "test-$t.log";
+ my $test_res;
# run it
- my $test_res = system("cd $test_mode/test/$t ; ./t 2>&1 " .
- "| tee ../../../$logfile");
+ if($target_msvc)
+ {
+ # no tee.exe, so let's do it ourselves.
+ open LOG, ">$logfile" or die "$logfile: $!";
+ chdir("$test_mode/test/$t");
+ open TEE, "$test_project_exe.exe |"
+ or die "$test_project_exe.exe: $!";
+ while (my $line = <TEE>)
+ {
+ print $line;
+ print LOG $line;
+ }
+ close LOG;
+ close TEE;
+ chdir("../../..");
+ }
+ else
+ {
+ $test_res = system("cd $test_mode/test/$t ; ./t 2>&1 " .
+ "| tee ../../../$logfile");
+ }
# open test results
if(open RESULTS, $logfile)