Skip to content

Commit

Permalink
port parallel tests
Browse files Browse the repository at this point in the history
  • Loading branch information
juliangruber committed Mar 26, 2022
1 parent eccc37b commit a2cfd7a
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 1 deletion.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"license": "MIT",
"repository": "juliangruber/node-core-test",
"scripts": {
"test": "prettier-standard && standard && node test"
"test": "prettier-standard && standard && node test && node test/parallel/test-runner-exit-code"
},
"devDependencies": {
"prettier-standard": "^16.4.1",
Expand Down
29 changes: 29 additions & 0 deletions test/parallel/test-runner-exit-code.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
'use strict'

// https://github.com/cjihrig/node/blob/527eb5caa5feae3b748d9c5b74b256edbb40a775/test/parallel/test-runner-exit-code.js

const assert = require('assert')
const { spawnSync } = require('child_process')

if (process.argv[2] === 'child') {
const test = require('../..')

if (process.argv[3] === 'pass') {
test('passing test', () => {
assert.strictEqual(true, true)
})
} else {
assert.strictEqual(process.argv[3], 'fail')
test('failing test', () => {
assert.strictEqual(true, false)
})
}
} else {
let child = spawnSync(process.execPath, [__filename, 'child', 'pass'])
assert.strictEqual(child.status, 0)
assert.strictEqual(child.signal, null)

child = spawnSync(process.execPath, [__filename, 'child', 'fail'])
assert.strictEqual(child.status, 1)
assert.strictEqual(child.signal, null)
}

0 comments on commit a2cfd7a

Please sign in to comment.