Skip to content

Commit

Permalink
fix: debug nonzero exit codes (windows, CI)
Browse files Browse the repository at this point in the history
  • Loading branch information
rvagg committed May 15, 2023
1 parent aa2f616 commit 362f6c5
Show file tree
Hide file tree
Showing 6 changed files with 76 additions and 19 deletions.
20 changes: 16 additions & 4 deletions test/test-bare-async.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,10 @@ testing bare fixture
`

it('should run in page', async () => {
const { stdout, code } = await runCli(bareAsyncFixture, '--runner=bare-async')
const { stdout, stderr, code } = await runCli(bareAsyncFixture, '--runner=bare-async')
if (code !== 0) {
console.error(stderr)
}
assert.strictEqual(code, 0, 'exited with zero exit code')
const expected = expectedTemplate.replace(/WORKER/, 'not in worker')
if (!stdout.includes(expected)) {
Expand All @@ -34,7 +37,10 @@ testing bare fixture
})

it('should run in worker', async () => {
const { stdout, code } = await runCli(bareAsyncFixture, '--runner=bare-async --worker --page=false')
const { stdout, stderr, code } = await runCli(bareAsyncFixture, '--runner=bare-async --worker --page=false')
if (code !== 0) {
console.error(stderr)
}
assert.strictEqual(code, 0, 'exited with zero exit code')
const expected = expectedTemplate.replace(/WORKER/, 'in worker')
if (!stdout.includes(expected)) {
Expand All @@ -45,7 +51,10 @@ testing bare fixture
})

it('should run in serviceworker', async () => {
const { stdout, code } = await runCli(bareAsyncFixture, '--runner=bare-async --serviceworker --page=false')
const { stdout, stderr, code } = await runCli(bareAsyncFixture, '--runner=bare-async --serviceworker --page=false')
if (code !== 0) {
console.error(stderr)
}
assert.strictEqual(code, 0, 'exited with zero exit code')
const expected = expectedTemplate.replace(/WORKER/, 'in serviceworker')
if (!stdout.includes(expected)) {
Expand All @@ -56,7 +65,10 @@ testing bare fixture
})

it('should run in page, worker and serviceworker', async () => {
const { stdout, code } = await runCli(bareAsyncFixture, '--runner=bare-async --worker --serviceworker')
const { stdout, stderr, code } = await runCli(bareAsyncFixture, '--runner=bare-async --worker --serviceworker')
if (code !== 0) {
console.error(stderr)
}
assert.strictEqual(code, 0, 'exited with zero exit code')

let expected = expectedTemplate.replace(/WORKER/, 'not in worker')
Expand Down
20 changes: 16 additions & 4 deletions test/test-bare-sync.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,10 @@ testing bare fixture
`

it('should run in page', async () => {
const { stdout, code } = await runCli(bareSyncFixture, '--runner=bare-sync')
const { stdout, stderr, code } = await runCli(bareSyncFixture, '--runner=bare-sync')
if (code !== 0) {
console.error(stderr)
}
assert.strictEqual(code, 0, 'exited with zero exit code')
const expected = expectedTemplate.replace(/WORKER/, 'not in worker')
if (!stdout.includes(expected)) {
Expand All @@ -32,7 +35,10 @@ testing bare fixture
})

it('should run in worker', async () => {
const { stdout, code } = await runCli(bareSyncFixture, '--runner=bare-sync --worker --page=false')
const { stdout, stderr, code } = await runCli(bareSyncFixture, '--runner=bare-sync --worker --page=false')
if (code !== 0) {
console.error(stderr)
}
assert.strictEqual(code, 0, 'exited with zero exit code')
const expected = expectedTemplate.replace(/WORKER/, 'in worker')
if (!stdout.includes(expected)) {
Expand All @@ -43,7 +49,10 @@ testing bare fixture
})

it('should run in serviceworker', async () => {
const { stdout, code } = await runCli(bareSyncFixture, '--runner=bare-sync --serviceworker --page=false')
const { stdout, stderr, code } = await runCli(bareSyncFixture, '--runner=bare-sync --serviceworker --page=false')
if (code !== 0) {
console.error(stderr)
}
assert.strictEqual(code, 0, 'exited with zero exit code')
const expected = expectedTemplate.replace(/WORKER/, 'in serviceworker')
if (!stdout.includes(expected)) {
Expand All @@ -54,7 +63,10 @@ testing bare fixture
})

it('should run in page, worker and serviceworker', async () => {
const { stdout, code } = await runCli(bareSyncFixture, '--runner=bare-sync --worker --serviceworker')
const { stdout, stderr, code } = await runCli(bareSyncFixture, '--runner=bare-sync --worker --serviceworker')
if (code !== 0) {
console.error(stderr)
}
assert.strictEqual(code, 0, 'exited with zero exit code')

let expected = expectedTemplate.replace(/WORKER/, 'not in worker')
Expand Down
20 changes: 16 additions & 4 deletions test/test-mocha.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,10 @@ for (const type of ['cjs', 'esm']) {
`

it('should run in page', async () => {
const { stdout, code } = await runCli(mochaFixture)
const { stdout, stderr, code } = await runCli(mochaFixture)
if (code !== 0) {
console.error(stderr)
}
assert.strictEqual(code, 0, 'exited with zero exit code')
const expected = expectedTemplate.replace(/WORKER/, 'not in worker')
if (!stdout.includes(expected)) {
Expand All @@ -42,7 +45,10 @@ for (const type of ['cjs', 'esm']) {
})

it('should run in worker', async () => {
const { stdout, code } = await runCli(mochaFixture, '--worker --page=false')
const { stdout, stderr, code } = await runCli(mochaFixture, '--worker --page=false')
if (code !== 0) {
console.error(stderr)
}
assert.strictEqual(code, 0, 'exited with zero exit code')
const expected = expectedTemplate.replace(/WORKER/, 'in worker')
if (!stdout.includes(expected)) {
Expand All @@ -53,7 +59,10 @@ for (const type of ['cjs', 'esm']) {
})

it('should run in serviceworker', async () => {
const { stdout, code } = await runCli(mochaFixture, '--serviceworker --page=false')
const { stdout, stderr, code } = await runCli(mochaFixture, '--serviceworker --page=false')
if (code !== 0) {
console.error(stderr)
}
assert.strictEqual(code, 0, 'exited with zero exit code')
const expected = expectedTemplate.replace(/WORKER/, 'in serviceworker')
if (!stdout.includes(expected)) {
Expand All @@ -64,7 +73,10 @@ for (const type of ['cjs', 'esm']) {
})

it('should run in page, worker and serviceworker', async () => {
const { stdout, code } = await runCli(mochaFixture, '--worker --serviceworker')
const { stdout, stderr, code } = await runCli(mochaFixture, '--worker --serviceworker')
if (code !== 0) {
console.error(stderr)
}
assert.strictEqual(code, 0, 'exited with zero exit code')

let expected = expectedTemplate.replace(/WORKER/, 'not in worker')
Expand Down
10 changes: 8 additions & 2 deletions test/test-polendina-node.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,10 @@ testing bare fixture
✔ test-2.js
Took X seconds
`
const { stdout, code } = await runCli('bare-sync', bareSyncFixture)
const { stdout, stderr, code } = await runCli('bare-sync', bareSyncFixture)
if (code !== 0) {
console.error(stderr)
}
assert.strictEqual(code, 0, 'exited with zero exit code')
assert.strictEqual(removeTiming(stdout), expected)
})
Expand Down Expand Up @@ -65,7 +68,10 @@ testing bare fixture
✔ test2
Took X seconds
`
const { stdout, code } = await runCli('bare-async', bareAsyncFixture)
const { stdout, stderr, code } = await runCli('bare-async', bareAsyncFixture)
if (code !== 0) {
console.error(stderr)
}
assert.strictEqual(code, 0, 'exited with zero exit code')
assert.strictEqual(removeTiming(stdout), expected)
})
Expand Down
20 changes: 16 additions & 4 deletions test/test-tape.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,10 @@ ok 5 all good
`

it('should run in page', async () => {
const { stdout, code } = await runCli(tapeFixture, '--runner=tape')
const { stdout, stderr, code } = await runCli(tapeFixture, '--runner=tape')
if (code !== 0) {
console.error(stderr)
}
assert.strictEqual(code, 0, 'exited with zero exit code')
const expected = expectedTemplate.replace(/WORKER/, 'not in worker')
if (!stdout.includes(expected)) {
Expand All @@ -48,7 +51,10 @@ ok 5 all good
})

it('should run in worker', async () => {
const { stdout, code } = await runCli(tapeFixture, '--runner=tape --worker --page=false')
const { stdout, stderr, code } = await runCli(tapeFixture, '--runner=tape --worker --page=false')
if (code !== 0) {
console.error(stderr)
}
assert.strictEqual(code, 0, 'exited with zero exit code')
const expected = expectedTemplate.replace(/WORKER/, 'in worker')
if (!stdout.includes(expected)) {
Expand All @@ -59,7 +65,10 @@ ok 5 all good
})

it('should run in serviceworker', async () => {
const { stdout, code } = await runCli(tapeFixture, '--runner=tape --serviceworker --page=false')
const { stdout, stderr, code } = await runCli(tapeFixture, '--runner=tape --serviceworker --page=false')
if (code !== 0) {
console.error(stderr)
}
assert.strictEqual(code, 0, 'exited with zero exit code')
const expected = expectedTemplate.replace(/WORKER/, 'in serviceworker')
if (!stdout.includes(expected)) {
Expand All @@ -70,7 +79,10 @@ ok 5 all good
})

it('should run in page, worker and serviceworker', async () => {
const { stdout, code } = await runCli(tapeFixture, '--runner=tape --worker --serviceworker')
const { stdout, stderr, code } = await runCli(tapeFixture, '--runner=tape --worker --serviceworker')
if (code !== 0) {
console.error(stderr)
}
assert.strictEqual(code, 0, 'exited with zero exit code')

let expected = expectedTemplate.replace(/WORKER/, 'not in worker')
Expand Down
5 changes: 4 additions & 1 deletion test/test-webpack-merge.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,10 @@ assert.ok() is a function
WOOP is set
✔ test.js
`
const { stdout, code } = await runCli(webpackMergeFixture, '--runner=bare-sync --webpack-config webpack.config.js')
const { stdout, stderr, code } = await runCli(webpackMergeFixture, '--runner=bare-sync --webpack-config webpack.config.js')
if (code !== 0) {
console.error(stderr)
}
assert.strictEqual(code, 0, 'exited with zero exit code')
if (!stdout.includes(expected)) {
console.error(stdout)
Expand Down

0 comments on commit 362f6c5

Please sign in to comment.