11cb0ef41Sopenharmony_ci'use strict'; 21cb0ef41Sopenharmony_ci 31cb0ef41Sopenharmony_cirequire('../common'); 41cb0ef41Sopenharmony_ciconst assert = require('assert'); 51cb0ef41Sopenharmony_ciconst { spawnSync } = require('child_process'); 61cb0ef41Sopenharmony_ciconst { join } = require('path'); 71cb0ef41Sopenharmony_ciconst { readdirSync } = require('fs'); 81cb0ef41Sopenharmony_ciconst fixtures = require('../common/fixtures'); 91cb0ef41Sopenharmony_ciconst testFixtures = fixtures.path('test-runner'); 101cb0ef41Sopenharmony_ci 111cb0ef41Sopenharmony_ci{ 121cb0ef41Sopenharmony_ci // File not found. 131cb0ef41Sopenharmony_ci const args = ['--test', 'a-random-file-that-does-not-exist.js']; 141cb0ef41Sopenharmony_ci const child = spawnSync(process.execPath, args); 151cb0ef41Sopenharmony_ci 161cb0ef41Sopenharmony_ci assert.strictEqual(child.status, 1); 171cb0ef41Sopenharmony_ci assert.strictEqual(child.signal, null); 181cb0ef41Sopenharmony_ci assert.strictEqual(child.stdout.toString(), ''); 191cb0ef41Sopenharmony_ci assert.match(child.stderr.toString(), /^Could not find/); 201cb0ef41Sopenharmony_ci} 211cb0ef41Sopenharmony_ci 221cb0ef41Sopenharmony_ci{ 231cb0ef41Sopenharmony_ci // Default behavior. node_modules is ignored. Files that don't match the 241cb0ef41Sopenharmony_ci // pattern are ignored except in test/ directories. 251cb0ef41Sopenharmony_ci const args = ['--test']; 261cb0ef41Sopenharmony_ci const child = spawnSync(process.execPath, args, { cwd: join(testFixtures, 'default-behavior') }); 271cb0ef41Sopenharmony_ci 281cb0ef41Sopenharmony_ci assert.strictEqual(child.status, 1); 291cb0ef41Sopenharmony_ci assert.strictEqual(child.signal, null); 301cb0ef41Sopenharmony_ci assert.strictEqual(child.stderr.toString(), ''); 311cb0ef41Sopenharmony_ci const stdout = child.stdout.toString(); 321cb0ef41Sopenharmony_ci assert.match(stdout, /ok 1 - this should pass/); 331cb0ef41Sopenharmony_ci assert.match(stdout, /not ok 2 - this should fail/); 341cb0ef41Sopenharmony_ci assert.match(stdout, /ok 3 - .+subdir.+subdir_test\.js/); 351cb0ef41Sopenharmony_ci assert.match(stdout, /ok 4 - this should pass/); 361cb0ef41Sopenharmony_ci assert.match(stdout, /ok 5 - this should be skipped/); 371cb0ef41Sopenharmony_ci assert.match(stdout, /ok 6 - this should be executed/); 381cb0ef41Sopenharmony_ci} 391cb0ef41Sopenharmony_ci 401cb0ef41Sopenharmony_ci{ 411cb0ef41Sopenharmony_ci // Same but with a prototype mutation in require scripts. 421cb0ef41Sopenharmony_ci const args = ['--require', join(testFixtures, 'protoMutation.js'), '--test']; 431cb0ef41Sopenharmony_ci const child = spawnSync(process.execPath, args, { cwd: join(testFixtures, 'default-behavior') }); 441cb0ef41Sopenharmony_ci 451cb0ef41Sopenharmony_ci const stdout = child.stdout.toString(); 461cb0ef41Sopenharmony_ci assert.match(stdout, /ok 1 - this should pass/); 471cb0ef41Sopenharmony_ci assert.match(stdout, /not ok 2 - this should fail/); 481cb0ef41Sopenharmony_ci assert.match(stdout, /ok 3 - .+subdir.+subdir_test\.js/); 491cb0ef41Sopenharmony_ci assert.match(stdout, /ok 4 - this should pass/); 501cb0ef41Sopenharmony_ci assert.match(stdout, /ok 5 - this should be skipped/); 511cb0ef41Sopenharmony_ci assert.match(stdout, /ok 6 - this should be executed/); 521cb0ef41Sopenharmony_ci assert.strictEqual(child.status, 1); 531cb0ef41Sopenharmony_ci assert.strictEqual(child.signal, null); 541cb0ef41Sopenharmony_ci assert.strictEqual(child.stderr.toString(), ''); 551cb0ef41Sopenharmony_ci} 561cb0ef41Sopenharmony_ci 571cb0ef41Sopenharmony_ci{ 581cb0ef41Sopenharmony_ci // User specified files that don't match the pattern are still run. 591cb0ef41Sopenharmony_ci const args = ['--test', join(testFixtures, 'index.js')]; 601cb0ef41Sopenharmony_ci const child = spawnSync(process.execPath, args, { cwd: testFixtures }); 611cb0ef41Sopenharmony_ci 621cb0ef41Sopenharmony_ci assert.strictEqual(child.status, 1); 631cb0ef41Sopenharmony_ci assert.strictEqual(child.signal, null); 641cb0ef41Sopenharmony_ci assert.strictEqual(child.stderr.toString(), ''); 651cb0ef41Sopenharmony_ci const stdout = child.stdout.toString(); 661cb0ef41Sopenharmony_ci assert.match(stdout, /not ok 1 - .+index\.js/); 671cb0ef41Sopenharmony_ci} 681cb0ef41Sopenharmony_ci 691cb0ef41Sopenharmony_ci{ 701cb0ef41Sopenharmony_ci // Searches node_modules if specified. 711cb0ef41Sopenharmony_ci const args = ['--test', join(testFixtures, 'default-behavior/node_modules')]; 721cb0ef41Sopenharmony_ci const child = spawnSync(process.execPath, args); 731cb0ef41Sopenharmony_ci 741cb0ef41Sopenharmony_ci assert.strictEqual(child.status, 1); 751cb0ef41Sopenharmony_ci assert.strictEqual(child.signal, null); 761cb0ef41Sopenharmony_ci assert.strictEqual(child.stderr.toString(), ''); 771cb0ef41Sopenharmony_ci const stdout = child.stdout.toString(); 781cb0ef41Sopenharmony_ci assert.match(stdout, /not ok 1 - .+test-nm\.js/); 791cb0ef41Sopenharmony_ci} 801cb0ef41Sopenharmony_ci 811cb0ef41Sopenharmony_ci{ 821cb0ef41Sopenharmony_ci // The current directory is used by default. 831cb0ef41Sopenharmony_ci const args = ['--test']; 841cb0ef41Sopenharmony_ci const options = { cwd: join(testFixtures, 'default-behavior') }; 851cb0ef41Sopenharmony_ci const child = spawnSync(process.execPath, args, options); 861cb0ef41Sopenharmony_ci 871cb0ef41Sopenharmony_ci assert.strictEqual(child.status, 1); 881cb0ef41Sopenharmony_ci assert.strictEqual(child.signal, null); 891cb0ef41Sopenharmony_ci assert.strictEqual(child.stderr.toString(), ''); 901cb0ef41Sopenharmony_ci const stdout = child.stdout.toString(); 911cb0ef41Sopenharmony_ci assert.match(stdout, /ok 1 - this should pass/); 921cb0ef41Sopenharmony_ci assert.match(stdout, /not ok 2 - this should fail/); 931cb0ef41Sopenharmony_ci assert.match(stdout, /ok 3 - .+subdir.+subdir_test\.js/); 941cb0ef41Sopenharmony_ci assert.match(stdout, /ok 4 - this should pass/); 951cb0ef41Sopenharmony_ci assert.match(stdout, /ok 5 - this should be skipped/); 961cb0ef41Sopenharmony_ci assert.match(stdout, /ok 6 - this should be executed/); 971cb0ef41Sopenharmony_ci} 981cb0ef41Sopenharmony_ci 991cb0ef41Sopenharmony_ci{ 1001cb0ef41Sopenharmony_ci // Flags that cannot be combined with --test. 1011cb0ef41Sopenharmony_ci const flags = [ 1021cb0ef41Sopenharmony_ci ['--check', '--test'], 1031cb0ef41Sopenharmony_ci ['--interactive', '--test'], 1041cb0ef41Sopenharmony_ci ['--eval', 'console.log("should not print")', '--test'], 1051cb0ef41Sopenharmony_ci ['--print', 'console.log("should not print")', '--test'], 1061cb0ef41Sopenharmony_ci ]; 1071cb0ef41Sopenharmony_ci 1081cb0ef41Sopenharmony_ci flags.forEach((args) => { 1091cb0ef41Sopenharmony_ci const child = spawnSync(process.execPath, args); 1101cb0ef41Sopenharmony_ci 1111cb0ef41Sopenharmony_ci assert.notStrictEqual(child.status, 0); 1121cb0ef41Sopenharmony_ci assert.strictEqual(child.signal, null); 1131cb0ef41Sopenharmony_ci assert.strictEqual(child.stdout.toString(), ''); 1141cb0ef41Sopenharmony_ci const stderr = child.stderr.toString(); 1151cb0ef41Sopenharmony_ci assert.match(stderr, /--test/); 1161cb0ef41Sopenharmony_ci }); 1171cb0ef41Sopenharmony_ci} 1181cb0ef41Sopenharmony_ci 1191cb0ef41Sopenharmony_ci{ 1201cb0ef41Sopenharmony_ci // Test combined stream outputs 1211cb0ef41Sopenharmony_ci const args = [ 1221cb0ef41Sopenharmony_ci '--test', 1231cb0ef41Sopenharmony_ci 'test/fixtures/test-runner/default-behavior/index.test.js', 1241cb0ef41Sopenharmony_ci 'test/fixtures/test-runner/nested.js', 1251cb0ef41Sopenharmony_ci 'test/fixtures/test-runner/invalid-tap.js', 1261cb0ef41Sopenharmony_ci ]; 1271cb0ef41Sopenharmony_ci const child = spawnSync(process.execPath, args); 1281cb0ef41Sopenharmony_ci 1291cb0ef41Sopenharmony_ci 1301cb0ef41Sopenharmony_ci assert.strictEqual(child.status, 1); 1311cb0ef41Sopenharmony_ci assert.strictEqual(child.signal, null); 1321cb0ef41Sopenharmony_ci assert.strictEqual(child.stderr.toString(), ''); 1331cb0ef41Sopenharmony_ci const stdout = child.stdout.toString(); 1341cb0ef41Sopenharmony_ci assert.match(stdout, /# Subtest: this should pass/); 1351cb0ef41Sopenharmony_ci assert.match(stdout, /ok 1 - this should pass/); 1361cb0ef41Sopenharmony_ci assert.match(stdout, / {2}---/); 1371cb0ef41Sopenharmony_ci assert.match(stdout, / {2}duration_ms: .*/); 1381cb0ef41Sopenharmony_ci assert.match(stdout, / {2}\.\.\./); 1391cb0ef41Sopenharmony_ci 1401cb0ef41Sopenharmony_ci assert.match(stdout, /# Subtest: .+invalid-tap\.js/); 1411cb0ef41Sopenharmony_ci assert.match(stdout, /# invalid tap output/); 1421cb0ef41Sopenharmony_ci assert.match(stdout, /ok 2 - .+invalid-tap\.js/); 1431cb0ef41Sopenharmony_ci 1441cb0ef41Sopenharmony_ci assert.match(stdout, /# Subtest: level 0a/); 1451cb0ef41Sopenharmony_ci assert.match(stdout, / {4}# Subtest: level 1a/); 1461cb0ef41Sopenharmony_ci assert.match(stdout, / {4}ok 1 - level 1a/); 1471cb0ef41Sopenharmony_ci assert.match(stdout, / {4}# Subtest: level 1b/); 1481cb0ef41Sopenharmony_ci assert.match(stdout, / {4}not ok 2 - level 1b/); 1491cb0ef41Sopenharmony_ci assert.match(stdout, / {6}code: 'ERR_TEST_FAILURE'/); 1501cb0ef41Sopenharmony_ci assert.match(stdout, / {6}stack: |-'/); 1511cb0ef41Sopenharmony_ci assert.match(stdout, / {8}TestContext\.<anonymous> .*/); 1521cb0ef41Sopenharmony_ci assert.match(stdout, / {4}# Subtest: level 1c/); 1531cb0ef41Sopenharmony_ci assert.match(stdout, / {4}ok 3 - level 1c # SKIP aaa/); 1541cb0ef41Sopenharmony_ci assert.match(stdout, / {4}# Subtest: level 1d/); 1551cb0ef41Sopenharmony_ci assert.match(stdout, / {4}ok 4 - level 1d/); 1561cb0ef41Sopenharmony_ci assert.match(stdout, /not ok 3 - level 0a/); 1571cb0ef41Sopenharmony_ci assert.match(stdout, / {2}error: '1 subtest failed'/); 1581cb0ef41Sopenharmony_ci assert.match(stdout, /# Subtest: level 0b/); 1591cb0ef41Sopenharmony_ci assert.match(stdout, /not ok 4 - level 0b/); 1601cb0ef41Sopenharmony_ci assert.match(stdout, / {2}error: 'level 0b error'/); 1611cb0ef41Sopenharmony_ci assert.match(stdout, /# tests 8/); 1621cb0ef41Sopenharmony_ci assert.match(stdout, /# suites 0/); 1631cb0ef41Sopenharmony_ci assert.match(stdout, /# pass 4/); 1641cb0ef41Sopenharmony_ci assert.match(stdout, /# fail 3/); 1651cb0ef41Sopenharmony_ci assert.match(stdout, /# cancelled 0/); 1661cb0ef41Sopenharmony_ci assert.match(stdout, /# skipped 1/); 1671cb0ef41Sopenharmony_ci assert.match(stdout, /# todo 0/); 1681cb0ef41Sopenharmony_ci} 1691cb0ef41Sopenharmony_ci 1701cb0ef41Sopenharmony_ci{ 1711cb0ef41Sopenharmony_ci // Test user logging in tests. 1721cb0ef41Sopenharmony_ci const args = [ 1731cb0ef41Sopenharmony_ci '--test', 1741cb0ef41Sopenharmony_ci 'test/fixtures/test-runner/user-logs.js', 1751cb0ef41Sopenharmony_ci ]; 1761cb0ef41Sopenharmony_ci const child = spawnSync(process.execPath, args); 1771cb0ef41Sopenharmony_ci 1781cb0ef41Sopenharmony_ci assert.strictEqual(child.status, 0); 1791cb0ef41Sopenharmony_ci assert.strictEqual(child.signal, null); 1801cb0ef41Sopenharmony_ci assert.strictEqual(child.stderr.toString(), ''); 1811cb0ef41Sopenharmony_ci const stdout = child.stdout.toString(); 1821cb0ef41Sopenharmony_ci assert.match(stdout, /# stderr 1/); 1831cb0ef41Sopenharmony_ci assert.match(stdout, /# stderr 2/); 1841cb0ef41Sopenharmony_ci assert.match(stdout, /# stdout 3/); 1851cb0ef41Sopenharmony_ci assert.match(stdout, /# stderr 6/); 1861cb0ef41Sopenharmony_ci assert.match(stdout, /# not ok 1 - fake test/); 1871cb0ef41Sopenharmony_ci assert.match(stdout, /# stderr 5/); 1881cb0ef41Sopenharmony_ci assert.match(stdout, /# stdout 4/); 1891cb0ef41Sopenharmony_ci assert.match(stdout, /# Subtest: a test/); 1901cb0ef41Sopenharmony_ci assert.match(stdout, /ok 1 - a test/); 1911cb0ef41Sopenharmony_ci assert.match(stdout, /# tests 1/); 1921cb0ef41Sopenharmony_ci assert.match(stdout, /# pass 1/); 1931cb0ef41Sopenharmony_ci} 1941cb0ef41Sopenharmony_ci 1951cb0ef41Sopenharmony_ci{ 1961cb0ef41Sopenharmony_ci // Use test with --loader and --require. 1971cb0ef41Sopenharmony_ci // This case is common since vscode uses --require to load the debugger. 1981cb0ef41Sopenharmony_ci const args = ['--no-warnings', 1991cb0ef41Sopenharmony_ci '--experimental-loader', 'data:text/javascript,', 2001cb0ef41Sopenharmony_ci '--require', fixtures.path('empty.js'), 2011cb0ef41Sopenharmony_ci '--test', join(testFixtures, 'default-behavior', 'index.test.js')]; 2021cb0ef41Sopenharmony_ci const child = spawnSync(process.execPath, args); 2031cb0ef41Sopenharmony_ci 2041cb0ef41Sopenharmony_ci assert.strictEqual(child.stderr.toString(), ''); 2051cb0ef41Sopenharmony_ci assert.strictEqual(child.status, 0); 2061cb0ef41Sopenharmony_ci assert.strictEqual(child.signal, null); 2071cb0ef41Sopenharmony_ci const stdout = child.stdout.toString(); 2081cb0ef41Sopenharmony_ci assert.match(stdout, /ok 1 - this should pass/); 2091cb0ef41Sopenharmony_ci} 2101cb0ef41Sopenharmony_ci 2111cb0ef41Sopenharmony_ci{ 2121cb0ef41Sopenharmony_ci // --test-shard option validation 2131cb0ef41Sopenharmony_ci const args = ['--test', '--test-shard=1', join(testFixtures, 'index.js')]; 2141cb0ef41Sopenharmony_ci const child = spawnSync(process.execPath, args, { cwd: testFixtures }); 2151cb0ef41Sopenharmony_ci 2161cb0ef41Sopenharmony_ci assert.strictEqual(child.status, 1); 2171cb0ef41Sopenharmony_ci assert.strictEqual(child.signal, null); 2181cb0ef41Sopenharmony_ci assert.match(child.stderr.toString(), /The argument '--test-shard' must be in the form of <index>\/<total>\. Received '1'/); 2191cb0ef41Sopenharmony_ci const stdout = child.stdout.toString(); 2201cb0ef41Sopenharmony_ci assert.strictEqual(stdout, ''); 2211cb0ef41Sopenharmony_ci} 2221cb0ef41Sopenharmony_ci 2231cb0ef41Sopenharmony_ci{ 2241cb0ef41Sopenharmony_ci // --test-shard option validation 2251cb0ef41Sopenharmony_ci const args = ['--test', '--test-shard=1/2/3', join(testFixtures, 'index.js')]; 2261cb0ef41Sopenharmony_ci const child = spawnSync(process.execPath, args, { cwd: testFixtures }); 2271cb0ef41Sopenharmony_ci 2281cb0ef41Sopenharmony_ci assert.strictEqual(child.status, 1); 2291cb0ef41Sopenharmony_ci assert.strictEqual(child.signal, null); 2301cb0ef41Sopenharmony_ci assert.match(child.stderr.toString(), /The argument '--test-shard' must be in the form of <index>\/<total>\. Received '1\/2\/3'/); 2311cb0ef41Sopenharmony_ci const stdout = child.stdout.toString(); 2321cb0ef41Sopenharmony_ci assert.strictEqual(stdout, ''); 2331cb0ef41Sopenharmony_ci} 2341cb0ef41Sopenharmony_ci 2351cb0ef41Sopenharmony_ci{ 2361cb0ef41Sopenharmony_ci // --test-shard option validation 2371cb0ef41Sopenharmony_ci const args = ['--test', '--test-shard=0/3', join(testFixtures, 'index.js')]; 2381cb0ef41Sopenharmony_ci const child = spawnSync(process.execPath, args, { cwd: testFixtures }); 2391cb0ef41Sopenharmony_ci 2401cb0ef41Sopenharmony_ci assert.strictEqual(child.status, 1); 2411cb0ef41Sopenharmony_ci assert.strictEqual(child.signal, null); 2421cb0ef41Sopenharmony_ci assert.match(child.stderr.toString(), /The value of "options\.shard\.index" is out of range\. It must be >= 1 && <= 3 \("options\.shard\.total"\)\. Received 0/); 2431cb0ef41Sopenharmony_ci const stdout = child.stdout.toString(); 2441cb0ef41Sopenharmony_ci assert.strictEqual(stdout, ''); 2451cb0ef41Sopenharmony_ci} 2461cb0ef41Sopenharmony_ci 2471cb0ef41Sopenharmony_ci{ 2481cb0ef41Sopenharmony_ci // --test-shard option validation 2491cb0ef41Sopenharmony_ci const args = ['--test', '--test-shard=0xf/20abcd', join(testFixtures, 'index.js')]; 2501cb0ef41Sopenharmony_ci const child = spawnSync(process.execPath, args, { cwd: testFixtures }); 2511cb0ef41Sopenharmony_ci 2521cb0ef41Sopenharmony_ci assert.strictEqual(child.status, 1); 2531cb0ef41Sopenharmony_ci assert.strictEqual(child.signal, null); 2541cb0ef41Sopenharmony_ci assert.match(child.stderr.toString(), /The argument '--test-shard' must be in the form of <index>\/<total>\. Received '0xf\/20abcd'/); 2551cb0ef41Sopenharmony_ci const stdout = child.stdout.toString(); 2561cb0ef41Sopenharmony_ci assert.strictEqual(stdout, ''); 2571cb0ef41Sopenharmony_ci} 2581cb0ef41Sopenharmony_ci 2591cb0ef41Sopenharmony_ci{ 2601cb0ef41Sopenharmony_ci // --test-shard option validation 2611cb0ef41Sopenharmony_ci const args = ['--test', '--test-shard=hello', join(testFixtures, 'index.js')]; 2621cb0ef41Sopenharmony_ci const child = spawnSync(process.execPath, args, { cwd: testFixtures }); 2631cb0ef41Sopenharmony_ci 2641cb0ef41Sopenharmony_ci assert.strictEqual(child.status, 1); 2651cb0ef41Sopenharmony_ci assert.strictEqual(child.signal, null); 2661cb0ef41Sopenharmony_ci assert.match(child.stderr.toString(), /The argument '--test-shard' must be in the form of <index>\/<total>\. Received 'hello'/); 2671cb0ef41Sopenharmony_ci const stdout = child.stdout.toString(); 2681cb0ef41Sopenharmony_ci assert.strictEqual(stdout, ''); 2691cb0ef41Sopenharmony_ci} 2701cb0ef41Sopenharmony_ci 2711cb0ef41Sopenharmony_ci{ 2721cb0ef41Sopenharmony_ci // --test-shard option, first shard 2731cb0ef41Sopenharmony_ci const shardsTestPath = join(testFixtures, 'shards'); 2741cb0ef41Sopenharmony_ci const allShardsTestsFiles = readdirSync(shardsTestPath).map((file) => join(shardsTestPath, file)); 2751cb0ef41Sopenharmony_ci const args = [ 2761cb0ef41Sopenharmony_ci '--test', 2771cb0ef41Sopenharmony_ci '--test-shard=1/2', 2781cb0ef41Sopenharmony_ci ...allShardsTestsFiles, 2791cb0ef41Sopenharmony_ci ]; 2801cb0ef41Sopenharmony_ci const child = spawnSync(process.execPath, args); 2811cb0ef41Sopenharmony_ci 2821cb0ef41Sopenharmony_ci assert.strictEqual(child.status, 0); 2831cb0ef41Sopenharmony_ci assert.strictEqual(child.signal, null); 2841cb0ef41Sopenharmony_ci assert.strictEqual(child.stderr.toString(), ''); 2851cb0ef41Sopenharmony_ci const stdout = child.stdout.toString(); 2861cb0ef41Sopenharmony_ci assert.match(stdout, /# Subtest: a\.cjs this should pass/); 2871cb0ef41Sopenharmony_ci assert.match(stdout, /ok 1 - a\.cjs this should pass/); 2881cb0ef41Sopenharmony_ci 2891cb0ef41Sopenharmony_ci assert.match(stdout, /# Subtest: c\.cjs this should pass/); 2901cb0ef41Sopenharmony_ci assert.match(stdout, /ok 2 - c\.cjs this should pass/); 2911cb0ef41Sopenharmony_ci 2921cb0ef41Sopenharmony_ci assert.match(stdout, /# Subtest: e\.cjs this should pass/); 2931cb0ef41Sopenharmony_ci assert.match(stdout, /ok 3 - e\.cjs this should pass/); 2941cb0ef41Sopenharmony_ci 2951cb0ef41Sopenharmony_ci assert.match(stdout, /# Subtest: g\.cjs this should pass/); 2961cb0ef41Sopenharmony_ci assert.match(stdout, /ok 4 - g\.cjs this should pass/); 2971cb0ef41Sopenharmony_ci 2981cb0ef41Sopenharmony_ci assert.match(stdout, /# Subtest: i\.cjs this should pass/); 2991cb0ef41Sopenharmony_ci assert.match(stdout, /ok 5 - i\.cjs this should pass/); 3001cb0ef41Sopenharmony_ci 3011cb0ef41Sopenharmony_ci assert.match(stdout, /# tests 5/); 3021cb0ef41Sopenharmony_ci assert.match(stdout, /# pass 5/); 3031cb0ef41Sopenharmony_ci assert.match(stdout, /# fail 0/); 3041cb0ef41Sopenharmony_ci assert.match(stdout, /# skipped 0/); 3051cb0ef41Sopenharmony_ci} 3061cb0ef41Sopenharmony_ci 3071cb0ef41Sopenharmony_ci{ 3081cb0ef41Sopenharmony_ci // --test-shard option, last shard 3091cb0ef41Sopenharmony_ci const shardsTestPath = join(testFixtures, 'shards'); 3101cb0ef41Sopenharmony_ci const allShardsTestsFiles = readdirSync(shardsTestPath).map((file) => join(shardsTestPath, file)); 3111cb0ef41Sopenharmony_ci const args = [ 3121cb0ef41Sopenharmony_ci '--test', 3131cb0ef41Sopenharmony_ci '--test-shard=2/2', 3141cb0ef41Sopenharmony_ci ...allShardsTestsFiles, 3151cb0ef41Sopenharmony_ci ]; 3161cb0ef41Sopenharmony_ci const child = spawnSync(process.execPath, args); 3171cb0ef41Sopenharmony_ci 3181cb0ef41Sopenharmony_ci assert.strictEqual(child.status, 0); 3191cb0ef41Sopenharmony_ci assert.strictEqual(child.signal, null); 3201cb0ef41Sopenharmony_ci assert.strictEqual(child.stderr.toString(), ''); 3211cb0ef41Sopenharmony_ci const stdout = child.stdout.toString(); 3221cb0ef41Sopenharmony_ci assert.match(stdout, /# Subtest: b\.cjs this should pass/); 3231cb0ef41Sopenharmony_ci assert.match(stdout, /ok 1 - b\.cjs this should pass/); 3241cb0ef41Sopenharmony_ci 3251cb0ef41Sopenharmony_ci assert.match(stdout, /# Subtest: d\.cjs this should pass/); 3261cb0ef41Sopenharmony_ci assert.match(stdout, /ok 2 - d\.cjs this should pass/); 3271cb0ef41Sopenharmony_ci 3281cb0ef41Sopenharmony_ci assert.match(stdout, /# Subtest: f\.cjs this should pass/); 3291cb0ef41Sopenharmony_ci assert.match(stdout, /ok 3 - f\.cjs this should pass/); 3301cb0ef41Sopenharmony_ci 3311cb0ef41Sopenharmony_ci assert.match(stdout, /# Subtest: h\.cjs this should pass/); 3321cb0ef41Sopenharmony_ci assert.match(stdout, /ok 4 - h\.cjs this should pass/); 3331cb0ef41Sopenharmony_ci 3341cb0ef41Sopenharmony_ci assert.match(stdout, /# Subtest: j\.cjs this should pass/); 3351cb0ef41Sopenharmony_ci assert.match(stdout, /ok 5 - j\.cjs this should pass/); 3361cb0ef41Sopenharmony_ci 3371cb0ef41Sopenharmony_ci assert.match(stdout, /# tests 5/); 3381cb0ef41Sopenharmony_ci assert.match(stdout, /# pass 5/); 3391cb0ef41Sopenharmony_ci assert.match(stdout, /# fail 0/); 3401cb0ef41Sopenharmony_ci assert.match(stdout, /# skipped 0/); 3411cb0ef41Sopenharmony_ci} 342