Add test-suite-source-dir flag to new test runner

The current tests try to figure out the root directory and then glob
for _test.ts files within there, but this breaks easily if the folder
structure isn't exactly as expected. Instead we can set this via a
flag in the test runner.

This CL only updates the interaction tests, which use the new runner.
e2e tests will be supported in time.

Bug: chromium:1186163
Change-Id: I198b67bf0081ce7334c40d7d661fb8642c2d56d0
Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/2772045
Commit-Queue: Jack Franklin <jacktfranklin@chromium.org>
Auto-Submit: Jack Franklin <jacktfranklin@chromium.org>
Reviewed-by: Paul Lewis <aerotwist@chromium.org>
diff --git a/scripts/component_server/BUILD.gn b/scripts/component_server/BUILD.gn
index ad9b5e0..7015759 100644
--- a/scripts/component_server/BUILD.gn
+++ b/scripts/component_server/BUILD.gn
@@ -6,4 +6,6 @@
 
 copy_to_gen("component_server") {
   sources = [ "server.js" ]
+
+  deps = [ "../test" ]
 }
diff --git a/scripts/component_server/server.js b/scripts/component_server/server.js
index 358179d..bcbaad8 100644
--- a/scripts/component_server/server.js
+++ b/scripts/component_server/server.js
@@ -7,19 +7,8 @@
 const path = require('path');
 const parseURL = require('url').parse;
 const {argv} = require('yargs');
+const {getTestRunnerConfigSetting} = require('../test/test_config_helpers.js');
 
-function getTestRunnerConfig() {
-  try {
-    return JSON.parse(process.env.TEST_RUNNER_JSON_CONFIG);
-  } catch {
-    // Return an empty object so any lookups return undefined
-    return {};
-  }
-}
-function getTestRunnerConfigSetting(settingKey, fallbackValue) {
-  const config = getTestRunnerConfig();
-  return config[settingKey] === undefined ? fallbackValue : config[settingKey];
-}
 
 const serverPort = parseInt(process.env.PORT, 10) || 8090;
 const target = argv.target || process.env.TARGET || 'Default';
diff --git a/scripts/test/BUILD.gn b/scripts/test/BUILD.gn
new file mode 100644
index 0000000..1703201
--- /dev/null
+++ b/scripts/test/BUILD.gn
@@ -0,0 +1,9 @@
+# Copyright 2021 The Chromium Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+import("../build/ninja/copy.gni")
+
+copy_to_gen("test") {
+  sources = [ "test_config_helpers.js" ]
+}
diff --git a/scripts/test/run_test_suite.js b/scripts/test/run_test_suite.js
index 6815862..476d81f 100644
--- a/scripts/test/run_test_suite.js
+++ b/scripts/test/run_test_suite.js
@@ -24,7 +24,13 @@
 const yargsObject =
     require('yargs')
         .option(
-            'test-suite-path', {type: 'string', desc: 'Path to the test suite, starting from out/Target directory.'})
+            'test-suite-path',
+            {type: 'string', desc: 'Path to the test suite, starting from out/Target directory.', demandOption: true})
+        .option('test-suite-source-dir', {
+          type: 'string',
+          desc: 'Path to the source folder containing the tests, relative to the current working directory.',
+          demandOption: true
+        })
         .option('target', {type: 'string', default: 'Default', desc: 'Name of the Ninja output directory.'})
         .option('node-modules-path', {
           type: 'string',
@@ -79,7 +85,6 @@
           // argv with '--foo-bar', not '--foo-bar' and 'fooBar'.
           'camel-case-expansion': false
         })
-        .demandOption(['test-suite-path'])
         // Take options via --config config.json
         .config()
         // Fail on any unknown arguments
diff --git a/scripts/test/test_config_helpers.js b/scripts/test/test_config_helpers.js
new file mode 100644
index 0000000..d56501c
--- /dev/null
+++ b/scripts/test/test_config_helpers.js
@@ -0,0 +1,18 @@
+// Copyright 2021 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+function getTestRunnerConfig() {
+  try {
+    return JSON.parse(process.env.TEST_RUNNER_JSON_CONFIG);
+  } catch {
+    // Return an empty object so any lookups return undefined
+    return {};
+  }
+}
+function getTestRunnerConfigSetting(settingKey, fallbackValue) {
+  const config = getTestRunnerConfig();
+  return config[settingKey] === undefined ? fallbackValue : config[settingKey];
+}
+
+module.exports = {getTestRunnerConfigSetting};