Skip to content

Commit

Permalink
test: Proper handing of /usr/bin/node lifecycle-path test
Browse files Browse the repository at this point in the history
PR-URL: #228
Credit: @olivr70
Close: #228
Reviewed-by: @isaacs
  • Loading branch information
Olivier Chevet authored and isaacs committed Aug 9, 2019
1 parent 82f8e17 commit b6df091
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions test/broken-under-nyc-and-travis/lifecycle-path.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ var path = require('path')
var mkdirp = require('mkdirp')
var osenv = require('osenv')
var rimraf = require('rimraf')
var which = require('which')
var test = require('tap').test

var common = require('../common-tap.js')
Expand All @@ -21,6 +22,9 @@ if (isWindows) {
PATH = '/bin:/usr/bin'
}

var systemNode = which.sync('node', { nothrow: true, path: PATH })
// the path to the system wide node (null if none)

test('setup', function (t) {
cleanup()
mkdirp.sync(pkg)
Expand Down Expand Up @@ -183,6 +187,12 @@ function checkPath (testconfig, t) {
'The node binary used for scripts is.*' +
process.execPath.replace(/[/\\]/g, '.'))
t.match(stderr, regex, 'reports the current binary vs conflicting')
} else if (systemNode !== null) {
var regexSystemNode = new RegExp(
'The node binary used for scripts is.*' +
systemNode.replace(/[/\\]/g, '.')
)
t.match(stderr, regexSystemNode, 'reports the system binary vs conflicting')
} else {
t.match(stderr, /there is no node binary in the current PATH/, 'informs user that there is no node binary in PATH')
}
Expand Down

0 comments on commit b6df091

Please sign in to comment.