From 8beff886a03c7ba4c7e3f5df9ff875eed02fc1d9 Mon Sep 17 00:00:00 2001 From: Joyee Cheung Date: Sun, 2 Nov 2025 16:25:23 +0100 Subject: [PATCH 1/2] tools: only add test reporter args when node:test is used If the test does not use node:test, don't append the unnecessary arguments to avoid cluttering the command line printed by the test runner when the test fails. --- test/testpy/__init__.py | 5 +++++ tools/test.py | 10 +++++----- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/test/testpy/__init__.py b/test/testpy/__init__.py index 605f2d2daa80d1..a3995b5abbd314 100644 --- a/test/testpy/__init__.py +++ b/test/testpy/__init__.py @@ -35,6 +35,7 @@ FLAGS_PATTERN = re.compile(r"//\s+Flags:(.*)") LS_RE = re.compile(r'^test-.*\.m?js$') ENV_PATTERN = re.compile(r"//\s+Env:(.*)") +NODE_TEST_PATTERN = re.compile(r"['\"]node:test['\"]") class SimpleTestCase(test.TestCase): @@ -98,6 +99,10 @@ def GetRunConfiguration(self): else: result += flags + if self.context.use_error_reporter and NODE_TEST_PATTERN.search(source): + result += ['--test-reporter=./test/common/test-error-reporter.js', + '--test-reporter-destination=stdout'] + if self.additional_flags: result += self.additional_flags diff --git a/tools/test.py b/tools/test.py index 1b0159ccd9f9d7..645385b0a8798f 100755 --- a/tools/test.py +++ b/tools/test.py @@ -969,6 +969,7 @@ def __init__(self, workspace, verbose, vm, args, expect_fail, self.abort_on_timeout = abort_on_timeout self.v8_enable_inspector = True self.node_has_crypto = True + self.use_error_reporter = False def GetVm(self, arch, mode): if self.vm is not None: @@ -1461,7 +1462,7 @@ def BuildOptions(): help="Type of build (simple, fips, coverage)", default=None) result.add_argument("--error-reporter", - help="use error reporter", + help="use error reporter if the test uses node:test", default=True, action="store_true") return result @@ -1679,10 +1680,6 @@ def Main(): options.node_args.append("--trace-file-names") options.progress = "deopts" - if options.error_reporter: - options.node_args.append('--test-reporter=./test/common/test-error-reporter.js') - options.node_args.append('--test-reporter-destination=stdout') - if options.worker: run_worker = join(workspace, "tools", "run-worker.js") options.node_args.append(run_worker) @@ -1701,6 +1698,9 @@ def Main(): options.repeat, options.abort_on_timeout) + if options.error_reporter: + context.use_error_reporter = True + # Get status for tests sections = [ ] defs = { } From 840fb82f0d24d06660d6ebeeeb3f09944fe14516 Mon Sep 17 00:00:00 2001 From: Joyee Cheung Date: Mon, 3 Nov 2025 12:43:18 +0100 Subject: [PATCH 2/2] fixup! tools: only add test reporter args when node:test is used Co-authored-by: Antoine du Hamel --- test/testpy/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/testpy/__init__.py b/test/testpy/__init__.py index a3995b5abbd314..9e7686c450b74b 100644 --- a/test/testpy/__init__.py +++ b/test/testpy/__init__.py @@ -35,7 +35,7 @@ FLAGS_PATTERN = re.compile(r"//\s+Flags:(.*)") LS_RE = re.compile(r'^test-.*\.m?js$') ENV_PATTERN = re.compile(r"//\s+Env:(.*)") -NODE_TEST_PATTERN = re.compile(r"['\"]node:test['\"]") +NODE_TEST_PATTERN = re.compile(r"('|`|\")node:test\1") class SimpleTestCase(test.TestCase):