[WinCairo] Support --no-copy for jsc tests in wincairo tests, add copying of dlls for copy case
https://bugs.webkit.org/show_bug.cgi?id=185049

Patch by Stephan Szabo <stephan.szabo@sony.com> on 2018-04-27
Reviewed by Keith Miller.

* Scripts/run-javascriptcore-tests:
(runJSCStressTests):
* Scripts/run-jsc-stress-tests:

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@231122 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/Tools/ChangeLog b/Tools/ChangeLog
index 2a35486..7746fa0 100644
--- a/Tools/ChangeLog
+++ b/Tools/ChangeLog
@@ -1,3 +1,14 @@
+2018-04-27  Stephan Szabo  <stephan.szabo@sony.com>
+
+        [WinCairo] Support --no-copy for jsc tests in wincairo tests, add copying of dlls for copy case
+        https://bugs.webkit.org/show_bug.cgi?id=185049
+
+        Reviewed by Keith Miller.
+
+        * Scripts/run-javascriptcore-tests:
+        (runJSCStressTests):
+        * Scripts/run-jsc-stress-tests:
+
 2018-04-26  Ryosuke Niwa  <rniwa@webkit.org>
 
         PSON: Triggering a navigation to an invalid URL creates a new WebContent process
diff --git a/Tools/Scripts/run-javascriptcore-tests b/Tools/Scripts/run-javascriptcore-tests
index c5ba1c1..75f16a4 100755
--- a/Tools/Scripts/run-javascriptcore-tests
+++ b/Tools/Scripts/run-javascriptcore-tests
@@ -58,6 +58,7 @@
 my $memoryLimited;
 
 my $buildJSC = 1;
+my $copyJSC = 1;
 
 use constant {
     ENV_VAR_SAYS_DO_RUN => 4,
@@ -148,6 +149,17 @@
     }
 }
 
+if ($ENV{RUN_JAVASCRIPTCORE_TESTS_COPY}) {
+    if ($ENV{RUN_JAVASCRIPTCORE_TESTS_COPY} eq "true") {
+        $copyJSC = 1;
+    } elsif ($ENV{RUN_JAVASCRIPTCORE_TESTS_COPY} eq "false") {
+        $copyJSC = 0;
+    } else {
+        print "Don't recognize value for RUN_JAVASCRIPTCORE_TESTS_COPY environment variable: '"
+            . $ENV{RUN_JAVASCRIPTCORE_TESTS_COPY} . "'. Should be set to 'true' or 'false'.\n";
+    }
+}
+
 if ($ENV{RUN_JAVASCRIPTCORE_TESTS_EXTRA_TESTS}) {
     push @extraTests, $ENV{RUN_JAVASCRIPTCORE_TESTS_EXTRA_TESTS};
 }
@@ -174,6 +186,7 @@
 my $jitStressTestsDefault = $runJITStressTests ? "will run" : " will not run";
 my $quickModeDefault = $runQuickMode ? "some" : "all";
 my $failFastDefault = $failFast ? "fail fast" : "don't fail fast";
+my $copyJSCDefault = $copyJSC ? "copy" : "do not copy";
 my $filter;
 my $usage = <<EOF;
 Usage: $programName [options] [options to pass to build system]
@@ -194,6 +207,7 @@
 
   --[no-]fail-fast              Stop this script when a test family reports an error or failure (default: $failFastDefault)
   --[no-]force-collectContinuously Enable the collectContinuously mode even if it was disabled on this platform.
+  --[no-]copy                   Copy (or don't copy) the JavaScriptCore build product before testing (default: $copyJSCDefault)
   --json-output=                Create a file at specified path, listing failed stress tests in JSON format.
   --tarball                     Create a tarball of the bundle produced by running the JSC stress tests.
   --remote=                     Run the JSC stress tests on the specified remote host. Implies --tarball.
@@ -248,6 +262,7 @@
     'quick!' => \$runQuickMode,
     'fail-fast!' => \$failFast,
     'force-collectContinuously!' => \$forceCollectContinuously,
+    'copy!' => \$copyJSC,
     'json-output=s' => \$jsonFileName,
     'tarball!' => \$createTarball,
     'remote=s' => \$remoteHost,
@@ -437,6 +452,10 @@
         push(@jscStressDriverCmd, "--debug");
     }
     
+    if (!$copyJSC) {
+        push(@jscStressDriverCmd, "--no-copy");
+    }
+
     if ($forceCollectContinuously) {
         push(@jscStressDriverCmd, "--force-collectContinuously");
     }
diff --git a/Tools/Scripts/run-jsc-stress-tests b/Tools/Scripts/run-jsc-stress-tests
index e9c1bb0..eb47063 100755
--- a/Tools/Scripts/run-jsc-stress-tests
+++ b/Tools/Scripts/run-jsc-stress-tests
@@ -1579,7 +1579,7 @@
 
     if $doNotMessWithVMPath
         if !$remote and !$tarball
-            $testingFrameworkPath = frameworkFromJSCPath($jscPath).realpath
+            $testingFrameworkPath = (frameworkFromJSCPath($jscPath) || $jscPath.dirname).realpath
             $jscPath = Pathname.new($jscPath).realpath
         else
             $testingFrameworkPath = frameworkFromJSCPath($jscPath)
@@ -1599,7 +1599,19 @@
             destination = Pathname.new(".vm")
         elsif $hostOS == "windows"
             # Make sure to copy dll along with jsc on Windows
-            source = [originalJSCPath] + Dir.glob(File.dirname(originalJSCPath) + "/jscLib.dll")
+            originalJSCDir = File.dirname(originalJSCPath)
+            source = [originalJSCPath] + [originalJSCDir + "/jscLib.dll"]
+
+            # Check for and copy JavaScriptCore.dll and WTF.dll for dynamic builds
+            javaScriptCoreDLLPath = File.join(originalJSCDir, "JavaScriptCore.dll")
+            wtfDLLPath = File.join(originalJSCDir, "WTF.dll")
+            if (File.exists?(javaScriptCoreDLLPath))
+                source = source + [javaScriptCoreDLLPath]
+            end
+            if (File.exists?(wtfDLLPath))
+                source = source + [wtfDLLPath]
+            end
+
             destination = $jscPath.dirname
 
             Dir.chdir($outputDir) {