From 9dc94d7b09ffa193a64e228b02b57ef80c4fce7c Mon Sep 17 00:00:00 2001 From: Myles Borins Date: Tue, 9 Feb 2016 10:32:32 -0800 Subject: [PATCH] test: add test-npm-install to parallel tests suite Currently we are not testing that `npm install` works. This is a very naive / basic test that shells out to `npm install` in an empty `tempDir`. While this test will not be able to check that `npm install` is 100% working, it should catch certain edge cases that break it. PR-URL: https://github.com/nodejs/node/pull/5166 Reviewed-By: Rich Trott Reviewed-By: James M Snell Reviewed-By: Alexis Campailla --- test/parallel/test-npm-install.js | 40 +++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 test/parallel/test-npm-install.js diff --git a/test/parallel/test-npm-install.js b/test/parallel/test-npm-install.js new file mode 100644 index 00000000000000..5275b17b39ebb7 --- /dev/null +++ b/test/parallel/test-npm-install.js @@ -0,0 +1,40 @@ +'use strict'; +const common = require('../common'); + +const path = require('path'); +const spawn = require('child_process').spawn; +const assert = require('assert'); +const fs = require('fs'); + +common.refreshTmpDir(); + +const npmPath = path.join( + common.testDir, + '..', + 'deps', + 'npm', + 'bin', + 'npm-cli.js' +); + +const args = [ + npmPath, + 'install' +]; + +const pkgContent = '{}'; + +const pkgPath = path.join(common.tmpDir, 'package.json'); + +fs.writeFileSync(pkgPath, pkgContent); + +const proc = spawn(process.execPath, args, { + cwd: common.tmpDir +}); + +function handleExit(code, signalCode) { + assert.equal(code, 0, 'npm install should run without an error'); + assert.ok(signalCode === null, 'signalCode should be null'); +} + +proc.on('exit', common.mustCall(handleExit));