Repository navigation
fix(run): don't fail the run on a failing todo or skip test #41
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
065f857
fix(run): don't fail the run on a failing todo or skip test
kriszyp f41f56e
fix(run): match node's own todo/skip classification, harden the self-…
kriszyp 924b179
fix(run): kill the spawned CLI when a run.test.ts timeout fires
kriszyp 949e855
refactor(run): spell out which todo/skip marker values skip a failure
kriszyp 324c7f6
test(run): move the run.test.ts fixtures into test/fixtures/run
kriszyp File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| import { test } from 'node:test'; | ||
| import assert from 'node:assert'; | ||
|
|
||
| test('a todo test with an empty reason that fails', { todo: '' }, () => { | ||
| assert.strictEqual(1, 2); | ||
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| import { test } from 'node:test'; | ||
| import assert from 'node:assert'; | ||
|
|
||
| test('a real failure', () => { | ||
| assert.strictEqual(1, 2); | ||
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| import { test } from 'node:test'; | ||
| import assert from 'node:assert'; | ||
|
|
||
| // `t.skip()` from inside the body, not `{ skip: true }`: the option skips the body entirely, so the | ||
| // test never fails and never reaches the runner's `data.skip` branch. | ||
| test('a skipped test that fails', (t) => { | ||
| t.skip('skipped for testing'); | ||
| assert.strictEqual(1, 2); | ||
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| import { test } from 'node:test'; | ||
| import assert from 'node:assert'; | ||
|
|
||
| test('a todo test that fails', { todo: true }, () => { | ||
| assert.strictEqual(1, 2); | ||
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,40 @@ | ||
| import { test } from 'node:test'; | ||
| import { strictEqual, ok } from 'node:assert'; | ||
| import { spawn } from 'node:child_process'; | ||
| import { once } from 'node:events'; | ||
| import { fileURLToPath } from 'node:url'; | ||
|
|
||
| const RUN_SCRIPT = fileURLToPath(new URL('../src/run.ts', import.meta.url)); | ||
|
|
||
| function fixture(name: string): string { | ||
| return fileURLToPath(new URL(`./fixtures/run/${name}`, import.meta.url)); | ||
| } | ||
|
|
||
| const cleanEnv = Object.fromEntries(Object.entries(process.env).filter(([key]) => !key.startsWith('HARPER_INTEGRATION_TEST_'))); | ||
|
|
||
| async function runCli(globPattern: string, signal: AbortSignal): Promise<number> { | ||
| const child = spawn(process.execPath, [RUN_SCRIPT, '--isolation=none', globPattern], { | ||
| stdio: 'ignore', | ||
| env: cleanEnv, | ||
| signal, | ||
| }); | ||
| const [code, exitSignal] = await once(child, 'exit'); | ||
| ok(exitSignal === null, `run.ts was killed by signal ${exitSignal}`); | ||
| return code; | ||
| } | ||
|
|
||
| test('a suite whose only failure is a todo test exits 0', { timeout: 15_000 }, async (t) => { | ||
| strictEqual(await runCli(fixture('todo-fail.ts'), t.signal), 0); | ||
| }); | ||
|
|
||
| test('a suite whose only failure is a skipped test exits 0', { timeout: 15_000 }, async (t) => { | ||
| strictEqual(await runCli(fixture('skip-fail.ts'), t.signal), 0); | ||
| }); | ||
|
|
||
| test('a suite whose only failure is a todo test with an empty reason exits 0', { timeout: 15_000 }, async (t) => { | ||
| strictEqual(await runCli(fixture('empty-reason-todo-fail.ts'), t.signal), 0); | ||
| }); | ||
|
|
||
| test('a suite with a real failure exits 1 (control)', { timeout: 15_000 }, async (t) => { | ||
| strictEqual(await runCli(fixture('real-fail.ts'), t.signal), 1); | ||
| }); | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.