Gently nudge old-run-webkit-tests toward working with Win32 Perl
This makes old-run-webkit-tests able to build DRT and find all the
tests to run. It even invokes DRT and passes it the list of tests. But
DRT ends up hung blocking on I/O.
Fixes <http://webkit.org/b/47961> Get old-run-webkit-tests mostly
working with Win32 Perl
Reviewed by David Kilzer.
* Scripts/old-run-webkit-tests:
- Use File::Spec instead of manually concatenating paths
- Use dirname instead of manually stripping off the base name
- Use isCygwin/isWindows/isAppleWinWebKit more judiciously
- Explicitly invoke Perl when running Perl scripts
- Quote paths when using them in regular expressions to allow them
to include characters that have special meanings in regular
expressions
* Scripts/run-webkit-tests: Use File::Spec instead of manually
concatenating paths.
* Scripts/webkitdirs.pm:
- Remove the unused $windowsTmpPath variable
- Use isCygwin/isWindows/isAppleWinWebKit more judiciously
- Only pass paths to cygpath when using Cygwin Perl
- Only use pdevenv when using Cygwin Perl, for now
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@70188 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/WebKitTools/ChangeLog b/WebKitTools/ChangeLog
index 1b23aae..745847e 100644
--- a/WebKitTools/ChangeLog
+++ b/WebKitTools/ChangeLog
@@ -1,3 +1,34 @@
+2010-10-19 Adam Roben <aroben@apple.com>
+
+ Gently nudge old-run-webkit-tests toward working with Win32 Perl
+
+ This makes old-run-webkit-tests able to build DRT and find all the
+ tests to run. It even invokes DRT and passes it the list of tests. But
+ DRT ends up hung blocking on I/O.
+
+ Fixes <http://webkit.org/b/47961> Get old-run-webkit-tests mostly
+ working with Win32 Perl
+
+ Reviewed by David Kilzer.
+
+ * Scripts/old-run-webkit-tests:
+ - Use File::Spec instead of manually concatenating paths
+ - Use dirname instead of manually stripping off the base name
+ - Use isCygwin/isWindows/isAppleWinWebKit more judiciously
+ - Explicitly invoke Perl when running Perl scripts
+ - Quote paths when using them in regular expressions to allow them
+ to include characters that have special meanings in regular
+ expressions
+
+ * Scripts/run-webkit-tests: Use File::Spec instead of manually
+ concatenating paths.
+
+ * Scripts/webkitdirs.pm:
+ - Remove the unused $windowsTmpPath variable
+ - Use isCygwin/isWindows/isAppleWinWebKit more judiciously
+ - Only pass paths to cygpath when using Cygwin Perl
+ - Only use pdevenv when using Cygwin Perl, for now
+
2010-10-20 Daniel Bates <dbates@rim.com>
Reviewed by Martin Robinson.
diff --git a/WebKitTools/Scripts/old-run-webkit-tests b/WebKitTools/Scripts/old-run-webkit-tests
index 2aceebb..a468b4d 100755
--- a/WebKitTools/Scripts/old-run-webkit-tests
+++ b/WebKitTools/Scripts/old-run-webkit-tests
@@ -49,6 +49,7 @@
use strict;
use warnings;
+use Config;
use Cwd;
use Data::Dumper;
use Fcntl qw(F_GETFL F_SETFL O_NONBLOCK);
@@ -157,7 +158,7 @@
my $testWebSocket = 1;
my $testMedia = 1;
my $tmpDir = "/tmp";
-my $testResultsDirectory = File::Spec->catfile($tmpDir, "layout-test-results");
+my $testResultsDirectory = File::Spec->catdir($tmpDir, "layout-test-results");
my $testsPerDumpTool = 1000;
my $threaded = 0;
# DumpRenderTree has an internal timeout of 30 seconds, so this must be > 30.
@@ -180,6 +181,8 @@
# Default to --no-http for wx for now.
$testHTTP = 0 if (isWx());
+my $perlInterpreter = "perl";
+
my $expectedTag = "expected";
my $actualTag = "actual";
my $prettyDiffTag = "pretty-diff";
@@ -224,7 +227,7 @@
$platform = "gtk";
} elsif (isWx()) {
$platform = "wx";
-} elsif (isCygwin()) {
+} elsif (isCygwin() || isWindows()) {
if (isWindowsXP()) {
$platform = "win-xp";
} elsif (isWindowsVista()) {
@@ -236,7 +239,7 @@
}
}
-if (isQt() || isCygwin()) {
+if (isQt() || isAppleWinWebKit()) {
my $testfontPath = $ENV{"WEBKIT_TESTFONTS"};
if (!$testfontPath || !-d "$testfontPath") {
print "The WEBKIT_TESTFONTS environment variable is not defined or not set properly\n";
@@ -412,8 +415,11 @@
my $dumpToolName = $useWebKitTestRunner ? "WebKitTestRunner" : "DumpRenderTree";
-$dumpToolName .= "_debug" if isCygwin() && configurationForVisualStudio() !~ /^Release|Debug_Internal$/;
-my $dumpTool = "$productDir/$dumpToolName";
+if (isAppleWinWebKit()) {
+ $dumpToolName .= "_debug" if configurationForVisualStudio() !~ /^Release|Debug_Internal$/;
+ $dumpToolName .= $Config{_exe};
+}
+my $dumpTool = File::Spec->catfile($productDir, $dumpToolName);
die "can't find executable $dumpToolName (looked in $productDir)\n" unless -x $dumpTool;
my $imageDiffTool = "$productDir/ImageDiff";
@@ -684,7 +690,7 @@
my $suffixExpectedHash = "";
if ($pixelTests && !$resetResults) {
my $expectedPixelDir = expectedDirectoryForTest($base, 0, "png");
- if (open EXPECTEDHASH, "$expectedPixelDir/$base-$expectedTag.checksum") {
+ if (open EXPECTEDHASH, File::Spec->catfile($expectedPixelDir, "$base-$expectedTag.checksum")) {
my $expectedHash = <EXPECTEDHASH>;
chomp($expectedHash);
close EXPECTEDHASH;
@@ -766,7 +772,7 @@
my $isText = isTextOnlyTest($actual);
my $expectedDir = expectedDirectoryForTest($base, $isText, $expectedExtension);
- $expectedResultPaths{$base} = "$expectedDir/$expectedFileName";
+ $expectedResultPaths{$base} = File::Spec->catfile($expectedDir, $expectedFileName);
unless ($readResults->{status} eq "success") {
my $crashed = $readResults->{status} eq "crashed";
@@ -780,7 +786,7 @@
my $expected;
- if (!$resetResults && open EXPECTED, "<", "$expectedDir/$expectedFileName") {
+ if (!$resetResults && open EXPECTED, "<", $expectedResultPaths{$base}) {
$expected = "";
while (<EXPECTED>) {
next if $stripEditingCallbacks && $_ =~ /^EDITING DELEGATE:/;
@@ -830,12 +836,13 @@
if ($actualPNGSize > 0) {
my $expectedPixelDir = expectedDirectoryForTest($base, 0, "png");
+ my $expectedPNGPath = File::Spec->catfile($expectedPixelDir, "$base-$expectedTag.png");
if (!$resetResults && ($expectedHash ne $actualHash || ($actualHash eq "" && $expectedHash eq ""))) {
- if (-f "$expectedPixelDir/$base-$expectedTag.png") {
- my $expectedPNGSize = -s "$expectedPixelDir/$base-$expectedTag.png";
+ if (-f $expectedPNGPath) {
+ my $expectedPNGSize = -s $expectedPNGPath;
my $expectedPNG = "";
- open EXPECTEDPNG, "$expectedPixelDir/$base-$expectedTag.png";
+ open EXPECTEDPNG, $expectedPNGPath;
read(EXPECTEDPNG, $expectedPNG, $expectedPNGSize);
openDiffTool();
@@ -866,13 +873,14 @@
}
}
- if ($resetResults || !-f "$expectedPixelDir/$base-$expectedTag.png") {
+ if ($resetResults || !-f $expectedPNGPath) {
mkpath catfile($expectedPixelDir, dirname($base)) if $testDirectory ne $expectedPixelDir;
- writeToFile("$expectedPixelDir/$base-$expectedTag.png", $actualPNG);
+ writeToFile($expectedPNGPath, $actualPNG);
}
- if ($actualHash ne "" && ($resetResults || !-f "$expectedPixelDir/$base-$expectedTag.checksum")) {
- writeToFile("$expectedPixelDir/$base-$expectedTag.checksum", $actualHash);
+ my $expectedChecksumPath = File::Spec->catfile($expectedPixelDir, "$base-$expectedTag.checksum");
+ if ($actualHash ne "" && ($resetResults || !-f $expectedChecksumPath)) {
+ writeToFile($expectedChecksumPath, $actualHash);
}
}
@@ -1009,11 +1017,10 @@
}
if ($error) {
- my $dir = "$testResultsDirectory/$base";
- $dir =~ s|/([^/]+)$|| or die "Failed to find test name from base\n";
+ my $dir = dirname(File::Spec->catdir($testResultsDirectory, $base));
mkpath $dir;
- writeToFile("$testResultsDirectory/$base-$errorTag.txt", $error);
+ writeToFile(File::Spec->catfile($testResultsDirectory, "$base-$errorTag.txt"), $error);
$counts{error}++;
push @{$tests{error}}, $test;
@@ -1121,6 +1128,8 @@
system "WebKitTools/Scripts/run-launcher", @configurationArgs, "file://".$testResults if $launchSafari;
} elsif (isCygwin()) {
system "cygstart", $testResults if $launchSafari;
+} elsif (isWindows()) {
+ system "start", $testResults if $launchSafari;
} else {
system "WebKitTools/Scripts/run-safari", @configurationArgs, "-NSOpen", $testResults if $launchSafari;
}
@@ -1322,7 +1331,7 @@
unshift @{$args}, "\"$allEnvVars\"";
my $execScript = File::Spec->catfile(sourceDir(), qw(WebKitTools Scripts execAppWithEnv));
- unshift @{$args}, $execScript;
+ unshift @{$args}, $perlInterpreter, $execScript;
return @{$args};
}
@@ -1364,7 +1373,7 @@
}
my @args = argumentsForConfiguration();
- my $buildProcess = open3($childIn, $childOut, $childErr, "WebKitTools/Scripts/$dumpToolBuildScript", @args) or die "Failed to run build-dumprendertree";
+ my $buildProcess = open3($childIn, $childOut, $childErr, $perlInterpreter, File::Spec->catfile(qw(WebKitTools Scripts), $dumpToolBuildScript), @args) or die "Failed to run build-dumprendertree";
close($childIn);
waitpid $buildProcess, 0;
my $buildResult = $?;
@@ -1507,7 +1516,7 @@
sub checkPythonVersion()
{
# we have not chdir to sourceDir yet.
- system sourceDir() . "/WebKitTools/Scripts/ensure-valid-python", "--check-only";
+ system $perlInterpreter, File::Spec->catfile(sourceDir(), qw(WebKitTools Scripts ensure-valid-python)), "--check-only";
return exitStatus($?) == 0;
}
@@ -1610,12 +1619,12 @@
my ($base, $isText, $expectedExtension) = @_;
my @directories = @platformResultHierarchy;
- push @directories, map { catdir($platformBaseDirectory, $_) } qw(mac-snowleopard mac) if isCygwin();
+ push @directories, map { catdir($platformBaseDirectory, $_) } qw(mac-snowleopard mac) if isAppleWinWebKit();
push @directories, $expectedDirectory;
# If we already have expected results, just return their location.
foreach my $directory (@directories) {
- return $directory if (-f "$directory/$base-$expectedTag.$expectedExtension");
+ return $directory if -f File::Spec->catfile($directory, "$base-$expectedTag.$expectedExtension");
}
# For cross-platform tests, text-only results should go in the cross-platform directory,
@@ -1631,9 +1640,9 @@
if ($shouldCheckLeaks) {
my $fileName;
if ($testsPerDumpTool == 1) {
- $fileName = "$testResultsDirectory/$base-leaks.txt";
+ $fileName = File::Spec->catfile($testResultsDirectory, "$base-leaks.txt");
} else {
- $fileName = "$testResultsDirectory/" . fileNameWithNumber($dumpToolName, $leaksOutputFileNumber) . "-leaks.txt";
+ $fileName = File::Spec->catfile($testResultsDirectory, fileNameWithNumber($dumpToolName, $leaksOutputFileNumber) . "-leaks.txt");
}
my $leakCount = countAndPrintLeaks($dumpToolName, $dumpToolPID, $fileName);
$totalLeaks += $leakCount;
@@ -1656,14 +1665,13 @@
sampleDumpTool() unless $didCrash;
- my $dir = "$testResultsDirectory/$base";
- $dir =~ s|/([^/]+)$|| or die "Failed to find test name from base\n";
+ my $dir = dirname(File::Spec->catdir($testResultsDirectory, $base));
mkpath $dir;
deleteExpectedAndActualResults($base);
if (defined($error) && length($error)) {
- writeToFile("$testResultsDirectory/$base-$errorTag.txt", $error);
+ writeToFile(File::Spec->catfile($testResultsDirectory, "$base-$errorTag.txt"), $error);
}
recordActualResultsAndDiff($base, $actual);
@@ -1901,8 +1909,8 @@
my $expectedResultPath = $expectedResultPaths{$base};
my ($expectedResultFileNameMinusExtension, $expectedResultDirectoryPath, $expectedResultExtension) = fileparse($expectedResultPath, qr{\.[^.]+$});
- my $actualResultsPath = "$testResultsDirectory/$base-$actualTag$expectedResultExtension";
- my $copiedExpectedResultsPath = "$testResultsDirectory/$base-$expectedTag$expectedResultExtension";
+ my $actualResultsPath = File::Spec->catfile($testResultsDirectory, "$base-$actualTag$expectedResultExtension");
+ my $copiedExpectedResultsPath = File::Spec->catfile($testResultsDirectory, "$base-$expectedTag$expectedResultExtension");
mkpath(dirname($actualResultsPath));
writeToFile("$actualResultsPath", $actualResults);
@@ -1914,7 +1922,7 @@
close EMPTY;
}
- my $diffOuputBasePath = "$testResultsDirectory/$base";
+ my $diffOuputBasePath = File::Spec->catfile($testResultsDirectory, $base);
my $diffOutputPath = "$diffOuputBasePath-$diffsTag.txt";
system "diff -u \"$copiedExpectedResultsPath\" \"$actualResultsPath\" > \"$diffOutputPath\"";
@@ -2274,7 +2282,7 @@
my @testsToRun = ();
for my $test (@ARGV) {
- $test =~ s/^($layoutTestsName|$testDirectory)\///;
+ $test =~ s/^(\Q$layoutTestsName\E|\Q$testDirectory\E)\///;
my $fullPath = catfile($testDirectory, $test);
if (file_name_is_absolute($test)) {
print "can't run test $test outside $testDirectory\n";
diff --git a/WebKitTools/Scripts/run-webkit-tests b/WebKitTools/Scripts/run-webkit-tests
index 8fe8360..6b530e1 100755
--- a/WebKitTools/Scripts/run-webkit-tests
+++ b/WebKitTools/Scripts/run-webkit-tests
@@ -41,6 +41,7 @@
use strict;
use warnings;
+use File::Spec;
use FindBin;
use lib $FindBin::Bin;
use webkitdirs;
@@ -79,5 +80,5 @@
}
}
-my $harnessPath = sprintf("%s/%s", relativeScriptsDir(), $harnessName);
+my $harnessPath = File::Spec->catfile(relativeScriptsDir(), $harnessName);
exec $harnessPath ($harnessPath, @ARGV) or die "Failed to execute $harnessPath";
diff --git a/WebKitTools/Scripts/webkitdirs.pm b/WebKitTools/Scripts/webkitdirs.pm
index 8a05561..fa85667 100644
--- a/WebKitTools/Scripts/webkitdirs.pm
+++ b/WebKitTools/Scripts/webkitdirs.pm
@@ -71,7 +71,6 @@
# Variables for Win32 support
my $vcBuildPath;
-my $windowsTmpPath;
my $windowsSourceDir;
my $winVersion;
my $willUseVCExpressWhenBuilding = 0;
@@ -173,9 +172,6 @@
my $dosBuildPath = `cygpath --windows \"$baseProductDir\"`;
chomp $dosBuildPath;
$ENV{"WEBKITOUTPUTDIR"} = $dosBuildPath;
- }
-
- if (isAppleWinWebKit()) {
my $unixBuildPath = `cygpath --unix \"$baseProductDir\"`;
chomp $unixBuildPath;
$baseProductDir = $unixBuildPath;
@@ -289,8 +285,9 @@
$configurationForVisualStudio = $configuration;
return unless $configuration eq "Debug";
setupCygwinEnv();
- chomp(my $dir = `cygpath -ua '$ENV{WEBKITLIBRARIESDIR}'`);
- $configurationForVisualStudio = "Debug_Internal" if -f "$dir/bin/CoreFoundation_debug.dll";
+ my $dir = $ENV{WEBKITLIBRARIESDIR};
+ chomp($dir = `cygpath -ua '$dir'`) if isCygwin();
+ $configurationForVisualStudio = "Debug_Internal" if -f File::Spec->catfile($dir, "bin", "CoreFoundation_debug.dll");
}
sub determineConfigurationProductDir
@@ -299,7 +296,7 @@
determineBaseProductDir();
determineConfiguration();
if (isAppleWinWebKit() && !isWx()) {
- $configurationProductDir = "$baseProductDir/bin";
+ $configurationProductDir = File::Spec->catdir($baseProductDir, "bin");
} else {
# [Gtk][Efl] We don't have Release/Debug configurations in straight
# autotool builds (non build-webkit). In this case and if
@@ -529,7 +526,7 @@
} elsif (isAppleWinWebKit()) {
$safariBundle = `"$configurationProductDir/FindSafari.exe"`;
$safariBundle =~ s/[\r\n]+$//;
- $safariBundle = `cygpath -u '$safariBundle'`;
+ $safariBundle = `cygpath -u '$safariBundle'` if isCygwin();
$safariBundle =~ s/[\r\n]+$//;
$safariBundle .= "Safari.exe";
}
@@ -624,7 +621,7 @@
# Check to see that all the frameworks are built.
sub checkFrameworks # FIXME: This is a poor name since only the Mac calls built WebCore a Framework.
{
- return if isCygwin();
+ return if isCygwin() || isWindows();
my @frameworks = ("JavaScriptCore", "WebCore");
push(@frameworks, "WebKit") if isAppleMacWebKit(); # FIXME: This seems wrong, all ports should have a WebKit these days.
for my $framework (@frameworks) {
@@ -873,7 +870,7 @@
sub isAppleWinWebKit()
{
- return isAppleWebKit() && isCygwin();
+ return isAppleWebKit() && (isCygwin() || isWindows());
}
sub isPerianInstalled()
@@ -1009,8 +1006,8 @@
sub determineWindowsSourceDir()
{
return if $windowsSourceDir;
- my $sourceDir = sourceDir();
- chomp($windowsSourceDir = `cygpath -w '$sourceDir'`);
+ $windowsSourceDir = sourceDir();
+ chomp($windowsSourceDir = `cygpath -w '$windowsSourceDir'`) if isCygwin();
}
sub windowsSourceDir()
@@ -1070,25 +1067,25 @@
sub setupCygwinEnv()
{
- return if !isCygwin();
+ return if !isCygwin() && !isWindows();
return if $vcBuildPath;
my $vsInstallDir;
- my $programFilesPath = $ENV{'PROGRAMFILES'} || "C:\\Program Files";
+ my $programFilesPath = $ENV{'PROGRAMFILES(X86)'} || $ENV{'PROGRAMFILES'} || "C:\\Program Files";
if ($ENV{'VSINSTALLDIR'}) {
$vsInstallDir = $ENV{'VSINSTALLDIR'};
} else {
- $vsInstallDir = "$programFilesPath/Microsoft Visual Studio 8";
+ $vsInstallDir = File::Spec->catdir($programFilesPath, "Microsoft Visual Studio 8");
}
- $vsInstallDir = `cygpath "$vsInstallDir"`;
- chomp $vsInstallDir;
- $vcBuildPath = "$vsInstallDir/Common7/IDE/devenv.com";
+ chomp($vsInstallDir = `cygpath "$vsInstallDir"`) if isCygwin();
+ $vcBuildPath = File::Spec->catfile($vsInstallDir, qw(Common7 IDE devenv.com));
if (-e $vcBuildPath) {
# Visual Studio is installed; we can use pdevenv to build.
- $vcBuildPath = File::Spec->catfile(sourceDir(), qw(WebKitTools Scripts pdevenv));
+ # FIXME: Make pdevenv work with non-Cygwin Perl.
+ $vcBuildPath = File::Spec->catfile(sourceDir(), qw(WebKitTools Scripts pdevenv)) if isCygwin();
} else {
# Visual Studio not found, try VC++ Express
- $vcBuildPath = "$vsInstallDir/Common7/IDE/VCExpress.exe";
+ $vcBuildPath = File::Spec->catfile($vsInstallDir, qw(Common7 IDE VCExpress.exe));
if (! -e $vcBuildPath) {
print "*************************************************************\n";
print "Cannot find '$vcBuildPath'\n";
@@ -1101,7 +1098,7 @@
$willUseVCExpressWhenBuilding = 1;
}
- my $qtSDKPath = "$programFilesPath/QuickTime SDK";
+ my $qtSDKPath = File::Spec->catdir($programFilesPath, "QuickTime SDK");
if (0 && ! -e $qtSDKPath) {
print "*************************************************************\n";
print "Cannot find '$qtSDKPath'\n";
@@ -1111,10 +1108,11 @@
die;
}
- chomp($ENV{'WEBKITLIBRARIESDIR'} = `cygpath -wa "$sourceDir/WebKitLibraries/win"`) unless $ENV{'WEBKITLIBRARIESDIR'};
+ unless ($ENV{WEBKITLIBRARIESDIR}) {
+ $ENV{'WEBKITLIBRARIESDIR'} = File::Spec->catdir($sourceDir, "WebKitLibraries", "win");
+ chomp($ENV{WEBKITLIBRARIESDIR} = `cygpath -wa $ENV{WEBKITLIBRARIESDIR}`) if isCygwin();
+ }
- $windowsTmpPath = `cygpath -w /tmp`;
- chomp $windowsTmpPath;
print "Building results into: ", baseProductDir(), "\n";
print "WEBKITOUTPUTDIR is set to: ", $ENV{"WEBKITOUTPUTDIR"}, "\n";
print "WEBKITLIBRARIESDIR is set to: ", $ENV{"WEBKITLIBRARIESDIR"}, "\n";
@@ -1197,14 +1195,14 @@
dieIfWindowsPlatformSDKNotInstalled() if $willUseVCExpressWhenBuilding;
- chomp(my $winProjectPath = `cygpath -w "$project"`);
+ chomp($project = `cygpath -w "$project"`) if isCygwin();
my $action = "/build";
if ($clean) {
$action = "/clean";
}
- my @command = ($vcBuildPath, $winProjectPath, $action, $config);
+ my @command = ($vcBuildPath, $project, $action, $config);
print join(" ", @command), "\n";
return system @command;