diff --git a/test/testpy/__init__.py b/test/testpy/__init__.py index 605f2d2daa8..9e7686c450b 100644 --- a/test/testpy/__init__.py +++ b/test/testpy/__init__.py @@ -35,6 +35,7 @@ from io import open 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\1") class SimpleTestCase(test.TestCase): @@ -98,6 +99,10 @@ class SimpleTestCase(test.TestCase): 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 1b0159ccd9f..645385b0a87 100755 --- a/tools/test.py +++ b/tools/test.py @@ -969,6 +969,7 @@ class Context(object): 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 = { }