Skip to content
Permalink
Browse files
test262-runner should have basic Windows compatibility
https://bugs.webkit.org/show_bug.cgi?id=240698

Reviewed by Mark Lam.

test262-runner currently has a slew of incompabilities on Windows;
this patch rectifies enough of them to achieve basic usability.

In particular:
- When `use` of a module triggers a fork() call, a crash occurs on Windows. Avoid by calling Runner::main() from outside.
- This is a WebKit-specific file; use webkitdirs.pm without hesitation and determine jsc binary path using jscPath().
- Don't use `DYLD_FRAMEWORK_PATH=` prefix on Windows.
- Remove erroneous quotes from system call.
- Use File::Copy::copy instead of cp.
- abs_path() of a not-yet-created file is invalid on Windows. But it's also completely unnecessary, as $resultsDir is absolute.
- Manually flush progress meter on Windows (since \r without \n will never be flushed automatically).

Remaining limitation:
- If --child-processes value is too high, the runner will hang. Workaround is to provide a lower number.

* Tools/Scripts/test262-runner:
* Tools/Scripts/test262/Runner.pm:
(processCLI):
(main):
(getBuildPath):
(runTest):
(summarizeResults):
(printHTMLResults):

Canonical link: https://commits.webkit.org/250811@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@294568 268f45cc-cd09-0410-ab3c-d52691b4dbfc
  • Loading branch information
rkirsling committed May 20, 2022
1 parent 94ad0c1 commit 93ec627a0798b645c14becdd8f741f3ac2411908
Showing 2 changed files with 19 additions and 31 deletions.
@@ -71,4 +71,4 @@ BEGIN {

use Runner;

exit 0;
Test262::Runner::main();
@@ -37,13 +37,15 @@ use File::Temp qw(tempfile tempdir);
use File::Spec::Functions qw(abs2rel);
use File::Basename qw(dirname);
use File::Path qw(mkpath);
use File::Copy qw(copy);
use Cwd qw(abs_path);
use FindBin;
use Env qw(DYLD_FRAMEWORK_PATH);
use Config;
use Time::HiRes qw(time);
use IO::Handle;
use IO::Select;
use webkitdirs;

my $Bin;
BEGIN {
@@ -104,11 +106,6 @@ sub LoadFile {
return Load(do { local $/; <$IN> });
}

my $webkitdirIsAvailable;
if (eval {require webkitdirs; 1;}) {
webkitdirs->import(qw(executableProductDir setConfiguration));
$webkitdirIsAvailable = 1;
}
my $podIsAvailable;
if (eval {require Pod::Usage; 1;}) {
Pod::Usage->import();
@@ -152,8 +149,6 @@ my ($deffh, $deffile) = getTempFile();

my $startTime = time();

main();

sub processCLI {
my $help = 0;
my $release;
@@ -212,7 +207,7 @@ sub processCLI {

if ($stats || $failingOnly) {
# If not supplied, try to find the results file in expected directory
$resultsFile ||= abs_path("$resultsDir/results.yaml");
$resultsFile ||= "$resultsDir/results.yaml";

if ($failingOnly && ! -e $resultsFile) {
die "Error: cannot find results file to run failing tests," .
@@ -433,6 +428,7 @@ sub main {
print $readyChild "$file\n";
if (!$noProgress) {
print "[$completedFiles/$numFiles]\r";
STDOUT->flush() if (isWindows());
}
$activeChildren++;
} elsif (!$activeChildren) {
@@ -563,13 +559,13 @@ sub main {
mkpath($resultsDir);
}

$resultsFile = abs_path("$resultsDir/results.yaml");
$resultsFile = "$resultsDir/results.yaml";

DumpFile($resultsFile, \@results);
print "Saved all the results in $resultsFile\n";

my $styleCss = abs_path("$Bin/report.css");
qx/cp $styleCss $resultsDir/;
copy($styleCss, $resultsDir);
summarizeResults();
printHTMLResults(\%failed, $totalRun, $failcount, $newfailcount, $skipfilecount);

@@ -633,21 +629,10 @@ sub parseError {
sub getBuildPath {
my ($release) = @_;

my $jsc;

if ($webkitdirIsAvailable) {
my $webkit_config = $release ? 'Release' : 'Debug';
setConfiguration($webkit_config);
my $jscDir = executableProductDir();

$jsc = $jscDir . '/jsc';
$jsc = $jscDir . '/JavaScriptCore.framework/Helpers/jsc' if (! -e $jsc);
$jsc = $jscDir . '/bin/jsc' if (! -e $jsc);

# Sets the Env DYLD_FRAMEWORK_PATH, abs_path will remove any extra '/' character
$DYLD_FRAMEWORK_PATH = abs_path(dirname($jsc)) if (-e $jsc);
}
my $webkit_config = $release ? 'Release' : 'Debug';
setConfiguration($webkit_config);

my $jsc = jscPath(jscProductDir());
if (! $jsc || ! -e $jsc) {
# If we cannot find jsc using webkitdirs, look in path
$jsc = qx(which jsc);
@@ -658,6 +643,9 @@ sub getBuildPath {
}
}

# Sets the Env DYLD_FRAMEWORK_PATH, abs_path will remove any extra '/' character
$DYLD_FRAMEWORK_PATH = abs_path(dirname($jsc)) if (-e $jsc);

return $jsc;
}

@@ -825,10 +813,10 @@ sub runTest {
my $defaultHarness = '';
$defaultHarness = $deffile if $scenario ne 'raw';

my $prefix = $DYLD_FRAMEWORK_PATH ? qq(DYLD_FRAMEWORK_PATH=$DYLD_FRAMEWORK_PATH) : "";
my $prefix = !isWindows() && $DYLD_FRAMEWORK_PATH ? qq(DYLD_FRAMEWORK_PATH=$DYLD_FRAMEWORK_PATH) : "";
my $execTimeStart = time();

my $result = qx($prefix $JSC $args $defaultHarness $includesfile '$prefixFile$filename');
my $result = qx($prefix $JSC $args $defaultHarness $includesfile $prefixFile$filename);
my $execTime = time() - $execTimeStart;

chomp $result;
@@ -1010,9 +998,9 @@ sub summarizeResults {
if (! -e $resultsDir) {
mkpath($resultsDir);
}
$summaryTxtFile = abs_path("$resultsDir/summary.txt");
$summaryFile = abs_path("$resultsDir/summary.yaml");
my $summaryHTMLFile = abs_path("$resultsDir/summary.html");
$summaryTxtFile = "$resultsDir/summary.txt";
$summaryFile = "$resultsDir/summary.yaml";
my $summaryHTMLFile = "$resultsDir/summary.html";

my %byfeature;
my %bypath;
@@ -1232,7 +1220,7 @@ sub printHTMLResults {
mkpath($resultsDir);
}

my $indexHTML = abs_path("$resultsDir/index.html");
my $indexHTML = "$resultsDir/index.html";
open(my $htmlfh, '>', $indexHTML) or die $!;

print $htmlfh qq{<html><head>

0 comments on commit 93ec627

Please sign in to comment.