Skip to content

Commit

Permalink
chore: fixes nodejs tests
Browse files Browse the repository at this point in the history
- Fixes ability to run tests using an arbitrary node bin
- Fixes `make test-npm` in nodejs repo
  - Added `tap-snapshots` folder
  - Added required `.npmrc` root file

Fixes npm/statusboard#45

PR-URL: #696
Credit: @ruyadorno
Close: #696
Reviewed-by: @mikemimik
  • Loading branch information
ruyadorno authored and Michael Perrotte committed Jan 21, 2020
1 parent ac3739f commit 88cfb88
Show file tree
Hide file tree
Showing 9 changed files with 24 additions and 9 deletions.
3 changes: 2 additions & 1 deletion lib/utils/unsupported.js
Expand Up @@ -7,7 +7,8 @@ var supportedNode = [
{ver: '10', min: '10.0.0'},
{ver: '11', min: '11.0.0'},
{ver: '12', min: '12.0.0'},
{ver: '13', min: '13.0.0'}
{ver: '13', min: '13.0.0'},
{ver: '14', min: '14.0.0'}
]
var knownBroken = '<6.2.0 || 9.0 - 9.2'

Expand Down
2 changes: 2 additions & 0 deletions scripts/release.sh
Expand Up @@ -12,6 +12,8 @@ node ./bin/npm-cli.js pack --loglevel error >/dev/null
mv *.tgz release
cd release
tar xzf *.tgz
cp ../.npmrc package/
cp -r ../tap-snapshots package/
cp -r ../test package/

mkdir node_modules
Expand Down
5 changes: 4 additions & 1 deletion test/tap/ci.js
Expand Up @@ -15,7 +15,10 @@ const File = Tacks.File
const cacheDir = common.cache
const testDir = common.pkg

const EXEC_OPTS = { cwd: testDir }
const EXEC_OPTS = {
cwd: testDir,
nodeExecPath: process.execPath
}

const PKG = {
name: 'top',
Expand Down
6 changes: 5 additions & 1 deletion test/tap/prepare.js
Expand Up @@ -55,7 +55,11 @@ test('test', function (t) {
common.npm([
'pack',
'--loglevel', 'warn'
], { cwd: pkg, env: env }, function (err, code, stdout, stderr) {
], {
cwd: pkg,
env: env,
nodeExecPath: process.execPath
}, function (err, code, stdout, stderr) {
t.equal(code, 0, 'pack finished successfully')
t.ifErr(err, 'pack finished successfully')

Expand Down
3 changes: 2 additions & 1 deletion test/tap/prepublish-only.js
Expand Up @@ -98,7 +98,8 @@ test('test', function (t) {
common.npm(
[
'publish',
'--loglevel', 'warn'
'--loglevel', 'warn',
'--scripts-prepend-node-path'
],
{
cwd: pkg,
Expand Down
2 changes: 1 addition & 1 deletion test/tap/publish-scoped.js
Expand Up @@ -46,7 +46,7 @@ test('npm publish should honor scoping', function (t) {

fs.writeFileSync(configFile, configuration.join('\n') + '\n')

common.npm(['publish'], {'cwd': pkg}, function (err, code, stdout, stderr) {
common.npm(['publish'], {'cwd': pkg, nodeExecPath: process.execPath}, function (err, code, stdout, stderr) {
if (err) throw err
t.is(code, 0, 'published without error')
server.done()
Expand Down
5 changes: 4 additions & 1 deletion test/tap/publish.js
Expand Up @@ -52,7 +52,10 @@ test('basic npm publish', (t) => {
`--//localhost:${server.port}/:username=username`,
`--//localhost:${server.port}/:_password=` + Buffer.from('password').toString('base64'),
`--//localhost:${server.port}/:email=` + 'ogd@aoaioxxysz.net'
], {'cwd': testDir})
], {
'cwd': testDir,
nodeExecPath: process.execPath
})
.spread((code, stdout, stderr) => {
t.comment(stdout)
t.comment(stderr)
Expand Down
5 changes: 3 additions & 2 deletions test/tap/umask-lifecycle.js
Expand Up @@ -40,12 +40,13 @@ test('setup', function (t) {
})

test('umask script', function (t) {
common.npm(['run', 'umask'], {
common.npm(['run', 'umask', '--scripts-prepend-node-path'], {
cwd: pkg,
env: {
PATH: process.env.PATH,
Path: process.env.Path,
'npm_config_loglevel': 'warn'
'npm_config_loglevel': 'warn',
nodeExecPath: process.execPath
}
}, function (er, code, sout, serr) {
t.equal(sout, expected)
Expand Down
2 changes: 1 addition & 1 deletion test/tap/version-no-package.js
Expand Up @@ -7,7 +7,7 @@ test('npm version in a prefix with no package.json', function (t) {
process.chdir(pkg)
common.npm(
['version', '--json', '--prefix', pkg],
{ cwd: pkg },
{ cwd: pkg, nodeExecPath: process.execPath },
function (er, code, stdout, stderr) {
t.ifError(er, "npm version doesn't care that there's no package.json")
t.notOk(code, 'npm version ran without barfing')
Expand Down

0 comments on commit 88cfb88

Please sign in to comment.