From 36d867143b588eae326f415cec95a0c082c289a9 Mon Sep 17 00:00:00 2001 From: Ms2ger Date: Fri, 23 Aug 2024 12:34:23 +0200 Subject: [PATCH 1/2] Pass the --module argument to the SM shell in the expected location Ref https://github.com/tc39/test262-harness/issues/163 --- lib/agents/jsshell.js | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/lib/agents/jsshell.js b/lib/agents/jsshell.js index 8a3db75..6887af9 100644 --- a/lib/agents/jsshell.js +++ b/lib/agents/jsshell.js @@ -11,13 +11,17 @@ const stackRe = /^([\s\S]*?)\r?\nStack:\r?\n([\s\S]*)$/; const stackFrameRe = /^(.*?)?@(.*?):(\d+):(\d+)?$/; class JSShell extends ConsoleAgent { - async evalScript(code, options = {}) { - if (options.module && this.args[0] !== '--module') { - this.args.unshift('--module'); + constructor(options) { + super(options); + if (this.args.indexOf('--module') !== -1) { + throw new Error("Passing --module as a SpiderMonkey host argument is not supported.") } + } - if (!options.module && this.args[0] === '--module') { - this.args.shift(); + async evalScript(code, options = {}) { + if (options.module) { + // The file name must come immediataly after the `--module` flag. + this.args.push('--module'); } return super.evalScript(code, options); From a4de90ae6f67cad80974fdee986e28f4d56a19b8 Mon Sep 17 00:00:00 2001 From: Ms2ger Date: Mon, 26 Aug 2024 17:49:28 +0200 Subject: [PATCH 2/2] Mutable state is evil --- lib/ConsoleAgent.js | 2 +- lib/agents/jsshell.js | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/lib/ConsoleAgent.js b/lib/ConsoleAgent.js index f59a865..29c5da6 100644 --- a/lib/ConsoleAgent.js +++ b/lib/ConsoleAgent.js @@ -212,7 +212,7 @@ class ConsoleAgent extends Agent { }; } - this[CHILD_PROCESS] = await this.createChildProcess([tempfile]); + this[CHILD_PROCESS] = await this.createChildProcess([...options.testHostArgs || [], tempfile]); this.hasFinishedCreatingChildProcess = true; if (this.isStopped && this[CHILD_PROCESS] === null) { diff --git a/lib/agents/jsshell.js b/lib/agents/jsshell.js index 6887af9..a5d837d 100644 --- a/lib/agents/jsshell.js +++ b/lib/agents/jsshell.js @@ -20,8 +20,10 @@ class JSShell extends ConsoleAgent { async evalScript(code, options = {}) { if (options.module) { - // The file name must come immediataly after the `--module` flag. - this.args.push('--module'); + if (!options.testHostArgs) { + options.testHostArgs = []; + } + options.testHostArgs.push('--module'); } return super.evalScript(code, options);