Skip to content

Commit 8a0d7f8

Browse files
committed
test: make test-runner-cli.js more flexible
Use regular expressions for top level test numbers instead of hard coding them. This helps the test pass if more fixtures are added that change the test ordering.
1 parent 32e478d commit 8a0d7f8

1 file changed

Lines changed: 21 additions & 21 deletions

File tree

test/parallel/test-runner-cli.js

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,10 @@ const testFixtures = fixtures.path('test-runner');
2828
assert.strictEqual(child.signal, null);
2929
assert.strictEqual(child.stderr.toString(), '');
3030
const stdout = child.stdout.toString();
31-
assert.match(stdout, /ok 1 - this should pass/);
32-
assert.match(stdout, /not ok 2 - this should fail/);
33-
assert.match(stdout, /ok 3 - .+subdir.+subdir_test\.js/);
34-
assert.match(stdout, /ok 4 - this should pass/);
31+
assert.match(stdout, /ok \d+ - this should pass/);
32+
assert.match(stdout, /not ok \d+ - this should fail/);
33+
assert.match(stdout, /ok \d+ - .+subdir.+subdir_test\.js/);
34+
assert.match(stdout, /ok \d+ - this should pass/);
3535
}
3636

3737
{
@@ -40,10 +40,10 @@ const testFixtures = fixtures.path('test-runner');
4040
const child = spawnSync(process.execPath, args);
4141

4242
const stdout = child.stdout.toString();
43-
assert.match(stdout, /ok 1 - this should pass/);
44-
assert.match(stdout, /not ok 2 - this should fail/);
45-
assert.match(stdout, /ok 3 - .+subdir.+subdir_test\.js/);
46-
assert.match(stdout, /ok 4 - this should pass/);
43+
assert.match(stdout, /ok \d+ - this should pass/);
44+
assert.match(stdout, /not ok \d+ - this should fail/);
45+
assert.match(stdout, /ok \d+ - .+subdir.+subdir_test\.js/);
46+
assert.match(stdout, /ok \d+ - this should pass/);
4747
assert.strictEqual(child.status, 1);
4848
assert.strictEqual(child.signal, null);
4949
assert.strictEqual(child.stderr.toString(), '');
@@ -58,11 +58,11 @@ const testFixtures = fixtures.path('test-runner');
5858
assert.strictEqual(child.signal, null);
5959
assert.strictEqual(child.stderr.toString(), '');
6060
const stdout = child.stdout.toString();
61-
assert.match(stdout, /not ok 1 - .+index\.js/);
62-
assert.match(stdout, /ok 2 - this should pass/);
63-
assert.match(stdout, /not ok 3 - this should fail/);
64-
assert.match(stdout, /ok 4 - .+subdir.+subdir_test\.js/);
65-
assert.match(stdout, /ok 5 - this should pass/);
61+
assert.match(stdout, /not ok \d+ - .+index\.js/);
62+
assert.match(stdout, /ok \d+ - this should pass/);
63+
assert.match(stdout, /not ok \d+ - this should fail/);
64+
assert.match(stdout, /ok \d+ - .+subdir.+subdir_test\.js/);
65+
assert.match(stdout, /ok \d+ - this should pass/);
6666
}
6767

6868
{
@@ -87,10 +87,10 @@ const testFixtures = fixtures.path('test-runner');
8787
assert.strictEqual(child.signal, null);
8888
assert.strictEqual(child.stderr.toString(), '');
8989
const stdout = child.stdout.toString();
90-
assert.match(stdout, /ok 1 - this should pass/);
91-
assert.match(stdout, /not ok 2 - this should fail/);
92-
assert.match(stdout, /ok 3 - .+subdir.+subdir_test\.js/);
93-
assert.match(stdout, /ok 4 - this should pass/);
90+
assert.match(stdout, /ok \d+ - this should pass/);
91+
assert.match(stdout, /not ok \d+ - this should fail/);
92+
assert.match(stdout, /ok \d+ - .+subdir.+subdir_test\.js/);
93+
assert.match(stdout, /ok \d+ - this should pass/);
9494
}
9595

9696
{
@@ -129,14 +129,14 @@ const testFixtures = fixtures.path('test-runner');
129129
assert.strictEqual(child.stderr.toString(), '');
130130
const stdout = child.stdout.toString();
131131
assert.match(stdout, /# Subtest: this should pass/);
132-
assert.match(stdout, /ok 1 - this should pass/);
132+
assert.match(stdout, /ok \d+ - this should pass/);
133133
assert.match(stdout, / {2}---/);
134134
assert.match(stdout, / {2}duration_ms: .*/);
135135
assert.match(stdout, / {2}\.\.\./);
136136

137137
assert.match(stdout, /# Subtest: .+invalid-tap\.js/);
138138
assert.match(stdout, /# invalid tap output/);
139-
assert.match(stdout, /ok 2 - .+invalid-tap\.js/);
139+
assert.match(stdout, /ok \d+ - .+invalid-tap\.js/);
140140

141141
assert.match(stdout, /# Subtest: level 0a/);
142142
assert.match(stdout, / {4}# Subtest: level 1a/);
@@ -177,11 +177,11 @@ const testFixtures = fixtures.path('test-runner');
177177
assert.match(stdout, /# stderr 2/);
178178
assert.match(stdout, /# stdout 3/);
179179
assert.match(stdout, /# stderr 6/);
180-
assert.match(stdout, /# not ok 1 - fake test/);
180+
assert.match(stdout, /# not ok \d+ - fake test/);
181181
assert.match(stdout, /# stderr 5/);
182182
assert.match(stdout, /# stdout 4/);
183183
assert.match(stdout, /# Subtest: a test/);
184-
assert.match(stdout, /ok 1 - a test/);
184+
assert.match(stdout, /ok \d+ - a test/);
185185
assert.match(stdout, /# tests 1/);
186186
assert.match(stdout, /# pass 1/);
187187
}

0 commit comments

Comments
 (0)