From e70778f1a8f5f5e2d099eb7411fc755cc0bdfd93 Mon Sep 17 00:00:00 2001 From: Camillo Bruni Date: Wed, 13 Nov 2024 13:30:47 +0100 Subject: [PATCH] Add more flexible SUITE_RUNNER_LOOKUP (#438) Add SUITE_RUNNER_LOOKUP to dynamically look up the suite runner class --- resources/benchmark-runner.mjs | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/resources/benchmark-runner.mjs b/resources/benchmark-runner.mjs index b9741199d..8b84c7fda 100644 --- a/resources/benchmark-runner.mjs +++ b/resources/benchmark-runner.mjs @@ -409,7 +409,8 @@ export class BenchmarkRunner { async runSuite(suite) { // FIXME: Encapsulate more state in the SuiteRunner. // FIXME: Return and use measured values from SuiteRunner. - const suiteRunner = new SuiteRunner(this._measuredValues, this._frame, this._page, this._client, suite); + const suiteRunnerClass = SUITE_RUNNER_LOOKUP[suite.type ?? "default"]; + const suiteRunner = new suiteRunnerClass(this._measuredValues, this._frame, this._page, this._client, suite); await suiteRunner.run(); } @@ -622,3 +623,12 @@ export class SuiteRunner { await this._client.didRunTest(this._suite, test); } } + +// FIXME: implement remote steps +class RemoteSuiteRunner extends SuiteRunner {} + +const SUITE_RUNNER_LOOKUP = { + __proto__: null, + default: SuiteRunner, + remote: RemoteSuiteRunner, +};