Skip to content

Commit

Permalink
Fix tests following change in Node's CLI parser
Browse files Browse the repository at this point in the history
  • Loading branch information
demurgos committed May 10, 2019
1 parent a6a78ba commit 976aabf
Showing 1 changed file with 26 additions and 20 deletions.
46 changes: 26 additions & 20 deletions test/basic.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,14 @@ const WRAPPER = require.resolve('./fixtures/basic.wrapper.js')

var unwrap = sw.patchInternals({ wrapper: WRAPPER, mode: 'same-process' })

var expect = 'WRAP ["--","{{FIXTURE}}","xyz"]\n' +
'["--"]\n' +
const NODE_MAJOR_VERSION = parseInt(process.versions.node.split('.')[0])
// https://github.com/nodejs/node/issues/24647
const DOUBLE_DASH = NODE_MAJOR_VERSION >= 10 ? '"--"' : ''
const DOUBLE_DASH_COMMA = NODE_MAJOR_VERSION >= 10 ? '"--",' : ''
const COMMA_DOUBLE_DASH = NODE_MAJOR_VERSION >= 10 ? ',"--"' : ''

var expect = 'WRAP [' + DOUBLE_DASH_COMMA + '"{{FIXTURE}}","xyz"]\n' +
'[' + DOUBLE_DASH + ']\n' +
'["xyz"]\n' +
'EXIT [0,null]\n'

Expand Down Expand Up @@ -63,8 +69,8 @@ t.test('spawn execPath', function (t) {
child.on('close', function (code, signal) {
t.equal(code, 0)
t.equal(signal, null)
t.equal(out, 'WRAP ["--","{{FIXTURE}}","xyz"]\n' +
'["--"]\n' +
t.equal(out, 'WRAP [' + DOUBLE_DASH_COMMA + '"{{FIXTURE}}","xyz"]\n' +
'[' + DOUBLE_DASH + ']\n' +
'["xyz"]\n' +
'SIGINT\n' +
'EXIT [0,null]\n')
Expand All @@ -82,8 +88,8 @@ t.test('spawn execPath', function (t) {
})
child.on('close', function (code, signal) {
t.equal(signal, 'SIGHUP')
t.equal(out, 'WRAP ["--","{{FIXTURE}}","xyz"]\n' +
'["--"]\n' +
t.equal(out, 'WRAP [' + DOUBLE_DASH_COMMA + '"{{FIXTURE}}","xyz"]\n' +
'[' + DOUBLE_DASH + ']\n' +
'["xyz"]\n' +
'SIGHUP\n' +
'EXIT [null,"SIGHUP"]\n')
Expand Down Expand Up @@ -133,8 +139,8 @@ t.test('spawn node', function (t) {
child.on('close', function (code, signal) {
t.equal(code, 0)
t.equal(signal, null)
t.equal(out, 'WRAP ["--","{{FIXTURE}}","xyz"]\n' +
'["--"]\n' +
t.equal(out, 'WRAP [' + DOUBLE_DASH_COMMA + '"{{FIXTURE}}","xyz"]\n' +
'[' + DOUBLE_DASH + ']\n' +
'["xyz"]\n' +
'SIGINT\n' +
'EXIT [0,null]\n')
Expand All @@ -152,8 +158,8 @@ t.test('spawn node', function (t) {
})
child.on('close', function (code, signal) {
t.equal(signal, 'SIGHUP')
t.equal(out, 'WRAP ["--","{{FIXTURE}}","xyz"]\n' +
'["--"]\n' +
t.equal(out, 'WRAP [' + DOUBLE_DASH_COMMA + '"{{FIXTURE}}","xyz"]\n' +
'[' + DOUBLE_DASH + ']\n' +
'["xyz"]\n' +
'SIGHUP\n' +
'EXIT [null,"SIGHUP"]\n')
Expand Down Expand Up @@ -212,8 +218,8 @@ t.test('exec execPath', function (t) {
child.on('close', function (code, signal) {
t.equal(code, 0)
t.equal(signal, null)
t.equal(out, 'WRAP ["--","{{FIXTURE}}","xyz"]\n' +
'["--"]\n' +
t.equal(out, 'WRAP [' + DOUBLE_DASH_COMMA + '"{{FIXTURE}}","xyz"]\n' +
'[' + DOUBLE_DASH + ']\n' +
'["xyz"]\n' +
'SIGINT\n' +
'EXIT [0,null]\n')
Expand All @@ -231,8 +237,8 @@ t.test('exec execPath', function (t) {
})
child.on('close', function (code, signal) {
t.equal(signal, 'SIGHUP')
t.equal(out, 'WRAP ["--","{{FIXTURE}}","xyz"]\n' +
'["--"]\n' +
t.equal(out, 'WRAP [' + DOUBLE_DASH_COMMA + '"{{FIXTURE}}","xyz"]\n' +
'[' + DOUBLE_DASH + ']\n' +
'["xyz"]\n' +
'SIGHUP\n' +
'EXIT [null,"SIGHUP"]\n')
Expand Down Expand Up @@ -269,8 +275,8 @@ t.test('exec shebang', { skip: winNoShebang }, function (t) {
})
child.on('close', function (code, signal) {
t.equal(signal, 'SIGHUP')
t.equal(out, 'WRAP ["--","{{FIXTURE}}","xyz"]\n' +
'["--"]\n' +
t.equal(out, 'WRAP [' + DOUBLE_DASH_COMMA + '"{{FIXTURE}}","xyz"]\n' +
'[' + DOUBLE_DASH + ']\n' +
'["xyz"]\n' +
'SIGHUP\n' +
'EXIT [null,"SIGHUP"]\n')
Expand All @@ -292,8 +298,8 @@ t.test('exec shebang', { skip: winNoShebang }, function (t) {
child.on('close', function (code, signal) {
t.equal(code, 0)
t.equal(signal, null)
t.equal(out, 'WRAP ["--","{{FIXTURE}}","xyz"]\n' +
'["--"]\n' +
t.equal(out, 'WRAP [' + DOUBLE_DASH_COMMA + '"{{FIXTURE}}","xyz"]\n' +
'[' + DOUBLE_DASH + ']\n' +
'["xyz"]\n' +
'SIGINT\n' +
'EXIT [0,null]\n')
Expand Down Expand Up @@ -352,8 +358,8 @@ t.test('--harmony', function (t) {
child.on('close', function (code, signal) {
t.equal(code, 0)
t.equal(signal, null)
t.equal(out, 'WRAP ["--harmony","--","{{FIXTURE}}","xyz"]\n' +
'["--harmony","--"]\n' +
t.equal(out, 'WRAP ["--harmony",' + DOUBLE_DASH_COMMA + '"{{FIXTURE}}","xyz"]\n' +
'["--harmony"' + COMMA_DOUBLE_DASH + ']\n' +
'["xyz"]\n' +
'EXIT [0,null]\n')
t.end()
Expand Down

0 comments on commit 976aabf

Please sign in to comment.