-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
76 additions
and
65 deletions.
There are no files selected for viewing
This file contains 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 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 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 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 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 |
---|---|---|
|
@@ -60,6 +60,7 @@ t.test('pkg has server.js, start not specified', async t => { | |
path, | ||
scriptShell: 'sh', | ||
args: [], | ||
binPaths: false, | ||
env: { | ||
environ: 'value', | ||
}, | ||
|
@@ -83,6 +84,7 @@ t.test('pkg has server.js, start not specified, with args', async t => { | |
environ: 'value', | ||
}, | ||
args: ['a', 'b', 'c'], | ||
binPaths: false, | ||
stdio: 'pipe', | ||
pkg: { | ||
_id: '[email protected]', | ||
|
@@ -100,6 +102,7 @@ t.test('pkg has server.js, start not specified, with args', async t => { | |
stdio: 'pipe', | ||
cmd: 'node server.js', | ||
args: ['a', 'b', 'c'], | ||
binPaths: false, | ||
}, { | ||
event: 'start', | ||
script: 'node server.js', | ||
|
@@ -132,6 +135,7 @@ t.test('pkg has no foo script, but custom cmd provided', t => runScriptPkg({ | |
path: 'path', | ||
scriptShell: 'sh', | ||
args: [], | ||
binPaths: false, | ||
env: { | ||
environ: 'value', | ||
}, | ||
|
@@ -168,6 +172,7 @@ t.test('do the banner when stdio is inherited, handle line breaks', t => { | |
path: 'path', | ||
scriptShell: 'sh', | ||
args: [], | ||
binPaths: false, | ||
env: { | ||
environ: 'value', | ||
}, | ||
|
@@ -206,6 +211,7 @@ t.test('do not show banner when stdio is inherited, if suppressed', t => { | |
path: 'path', | ||
scriptShell: 'sh', | ||
args: [], | ||
binPaths: false, | ||
env: { | ||
environ: 'value', | ||
}, | ||
|
@@ -242,6 +248,7 @@ t.test('do the banner with no pkgid', t => { | |
path: 'path', | ||
scriptShell: 'sh', | ||
args: [], | ||
binPaths: false, | ||
env: { | ||
environ: 'value', | ||
}, | ||
|
@@ -275,6 +282,7 @@ t.test('pkg has foo script', t => runScriptPkg({ | |
path: 'path', | ||
scriptShell: 'sh', | ||
args: [], | ||
binPaths: false, | ||
env: { | ||
environ: 'value', | ||
}, | ||
|
@@ -302,12 +310,14 @@ t.test('pkg has foo script, with args', t => runScriptPkg({ | |
}, | ||
}, | ||
args: ['a', 'b', 'c'], | ||
binPaths: false, | ||
}).then(res => t.strictSame(res, ['sh', ['-c', 'bar'], { | ||
stdioString: false, | ||
event: 'foo', | ||
path: 'path', | ||
scriptShell: 'sh', | ||
args: ['a', 'b', 'c'], | ||
binPaths: false, | ||
env: { | ||
environ: 'value', | ||
}, | ||
|
@@ -346,6 +356,7 @@ t.test('pkg has no install or preinstall script, but node-gyp files are present' | |
path: 'path', | ||
scriptShell: 'sh', | ||
args: [], | ||
binPaths: false, | ||
env: { environ: 'value' }, | ||
stdio: 'pipe', | ||
cmd: 'node-gyp rebuild', | ||
|
This file contains 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 |
---|---|---|
@@ -1,69 +1,53 @@ | ||
const t = require('tap') | ||
const requireInject = require('require-inject') | ||
const isWindows = require('../lib/is-windows.js') | ||
const { resolve, delimiter } = require('path').posix | ||
|
||
if (!process.env.__FAKE_TESTING_PLATFORM__) { | ||
const fake = isWindows ? 'posix' : 'win32' | ||
t.spawn(process.execPath, [__filename, fake], { env: { | ||
...process.env, | ||
__FAKE_TESTING_PLATFORM__: fake, | ||
} }) | ||
} | ||
const setPATH = t.mock('../lib/set-path.js', { | ||
// Always use posix path functions so tests are consistent | ||
path: require('path').posix, | ||
}) | ||
|
||
if (isWindows) { | ||
const setPATH = requireInject('../lib/set-path.js', { | ||
path: require('path').win32, | ||
}) | ||
const expect = [ | ||
'c:\\x\\y\\z\\node_modules\\a\\node_modules\\b\\node_modules\\.bin', | ||
'c:\\x\\y\\z\\node_modules\\a\\node_modules\\node_modules\\.bin', | ||
'c:\\x\\y\\z\\node_modules\\a\\node_modules\\.bin', | ||
'c:\\x\\y\\z\\node_modules\\node_modules\\.bin', | ||
'c:\\x\\y\\z\\node_modules\\.bin', | ||
'c:\\x\\y\\node_modules\\.bin', | ||
'c:\\x\\node_modules\\.bin', | ||
'c:\\node_modules\\.bin', | ||
require('path').win32.resolve(__dirname, '../lib/node-gyp-bin'), | ||
'c:\\usr\\local\\bin', | ||
'c:\\usr\\local\\sbin', | ||
'c:\\usr\\bin', | ||
'c:\\usr\\sbin', | ||
'c:\\bin', | ||
'c:\\sbin', | ||
].join(';') | ||
t.strictSame(setPATH('c:\\x\\y\\z\\node_modules\\a\\node_modules\\b', { | ||
const paths = [ | ||
'/x/y/z/node_modules/a/node_modules/b/node_modules/.bin', | ||
'/x/y/z/node_modules/a/node_modules/node_modules/.bin', | ||
'/x/y/z/node_modules/a/node_modules/.bin', | ||
'/x/y/z/node_modules/node_modules/.bin', | ||
'/x/y/z/node_modules/.bin', | ||
'/x/y/node_modules/.bin', | ||
'/x/node_modules/.bin', | ||
'/node_modules/.bin', | ||
resolve(__dirname, '../lib/node-gyp-bin'), | ||
'/usr/local/bin', | ||
'/usr/local/sbin', | ||
'/usr/bin', | ||
'/usr/sbin', | ||
'/bin', | ||
'/sbin', | ||
] | ||
t.test('no binPaths', async t => { | ||
const projectPath = '/x/y/z/node_modules/a/node_modules/b' | ||
t.strictSame(setPATH(projectPath, false, { | ||
foo: 'bar', | ||
PATH: 'c:\\usr\\local\\bin;c:\\usr\\local\\sbin', | ||
Path: 'c:\\usr\\local\\bin;c:\\usr\\bin;c:\\usr\\sbin;c:\\bin;c:\\sbin', | ||
PATH: '/usr/local/bin:/usr/local/sbin:/usr/bin:/usr/sbin:/bin:/sbin', | ||
}), { | ||
foo: 'bar', | ||
PATH: expect, | ||
Path: expect, | ||
PATH: paths.join(delimiter), | ||
}) | ||
} else { | ||
const setPATH = requireInject('../lib/set-path.js', { | ||
path: require('path').posix, | ||
}) | ||
t.strictSame(setPATH('/x/y/z/node_modules/a/node_modules/b', { | ||
}) | ||
|
||
t.test('binPaths end up at beginning of PATH', async t => { | ||
const projectPath = '/x/y/z/node_modules/a/node_modules/b' | ||
const binPaths = [ | ||
'/q/r/s/node_modules/.bin', | ||
'/t/u/v/node_modules/.bin', | ||
] | ||
t.strictSame(setPATH(projectPath, binPaths, { | ||
foo: 'bar', | ||
PATH: '/usr/local/bin:/usr/local/sbin:/usr/bin:/usr/sbin:/bin:/sbin', | ||
}), { | ||
foo: 'bar', | ||
PATH: | ||
'/x/y/z/node_modules/a/node_modules/b/node_modules/.bin:' + | ||
'/x/y/z/node_modules/a/node_modules/node_modules/.bin:' + | ||
'/x/y/z/node_modules/a/node_modules/.bin:' + | ||
'/x/y/z/node_modules/node_modules/.bin:' + | ||
'/x/y/z/node_modules/.bin:' + | ||
'/x/y/node_modules/.bin:' + | ||
'/x/node_modules/.bin:' + | ||
'/node_modules/.bin:' + | ||
require('path').posix.resolve(__dirname, '../lib/node-gyp-bin') + ':' + | ||
'/usr/local/bin:' + | ||
'/usr/local/sbin:' + | ||
'/usr/bin:' + | ||
'/usr/sbin:' + | ||
'/bin:' + | ||
'/sbin', | ||
PATH: [ | ||
...binPaths, | ||
...paths, | ||
].join(delimiter), | ||
}) | ||
} | ||
}) |