Skip to content

Commit d68f6e6

Browse files
Benjamin CoeMylesBorins
Benjamin Coe
authored andcommitted
test: fix tests that fail under coverage
Make test runner capable of skipping tests, which makes it possible to skip the failing test/message/core_line_numbers.js test. Make nyc no longer generate compact instrumentation (this causes significantly different code output, which leads to failing test assertions). PR-URL: #20794 Reviewed-By: Rich Trott <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Khaidi Chu <[email protected]> Reviewed-By: Anatoli Papirovski <[email protected]>
1 parent 1f01830 commit d68f6e6

File tree

3 files changed

+12
-2
lines changed

3 files changed

+12
-2
lines changed

.nycrc

+1
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,6 @@
22
"exclude": [
33
"**/internal/process/write-coverage.js"
44
],
5+
"compact": false,
56
"reporter": ["html", "text"]
67
}

Makefile

+2-2
Original file line numberDiff line numberDiff line change
@@ -233,6 +233,7 @@ v8:
233233
.PHONY: jstest
234234
jstest: build-addons build-addons-napi ## Runs addon tests and JS tests
235235
$(PYTHON) tools/test.py $(PARALLEL_ARGS) --mode=$(BUILDTYPE_LOWER) \
236+
--skip-tests=$(CI_SKIP_TESTS) \
236237
$(CI_JS_SUITES) \
237238
$(CI_NATIVE_SUITES)
238239

@@ -263,8 +264,7 @@ test-cov: all
263264
$(MAKE) build-addons
264265
$(MAKE) build-addons-napi
265266
# $(MAKE) cctest
266-
$(MAKE) jstest
267-
$(MAKE) lint
267+
CI_SKIP_TESTS=core_line_numbers.js $(MAKE) jstest
268268

269269
test-parallel: all
270270
$(PYTHON) tools/test.py $(PARALLEL_ARGS) --mode=$(BUILDTYPE_LOWER) parallel

tools/test.py

+9
Original file line numberDiff line numberDiff line change
@@ -1382,6 +1382,9 @@ def BuildOptions():
13821382
result.add_option("--flaky-tests",
13831383
help="Regard tests marked as flaky (run|skip|dontcare)",
13841384
default="run")
1385+
result.add_option("--skip-tests",
1386+
help="Tests that should not be executed (comma-separated)",
1387+
default="")
13851388
result.add_option("--warn-unused", help="Report unused rules",
13861389
default=False, action="store_true")
13871390
result.add_option("-j", help="The number of parallel tasks to run",
@@ -1424,6 +1427,7 @@ def ProcessOptions(options):
14241427
options.arch = options.arch.split(',')
14251428
options.mode = options.mode.split(',')
14261429
options.run = options.run.split(',')
1430+
options.skip_tests = options.skip_tests.split(',')
14271431
if options.run == [""]:
14281432
options.run = None
14291433
elif len(options.run) != 2:
@@ -1710,6 +1714,11 @@ def Main():
17101714

17111715
result = None
17121716
def DoSkip(case):
1717+
# A list of tests that should be skipped can be provided. This is
1718+
# useful for tests that fail in some environments, e.g., under coverage.
1719+
if options.skip_tests != [""]:
1720+
if [ st for st in options.skip_tests if st in case.case.file ]:
1721+
return True
17131722
if SKIP in case.outcomes or SLOW in case.outcomes:
17141723
return True
17151724
return FLAKY in case.outcomes and options.flaky_tests == SKIP

0 commit comments

Comments
 (0)