diff options
author | Kat Marchán <kzm@sykosomatic.org> | 2017-05-28 21:04:08 -0700 |
---|---|---|
committer | Anna Henningsen <anna@addaleax.net> | 2017-05-29 18:06:04 +0200 |
commit | c58cea5a163cd5d7133e00fdf257325ce3807c09 (patch) | |
tree | 1b7f97c0474f1990450a54e82b4432ec37de1956 /deps/npm/test | |
parent | 88fe7e84e56e44a727169c07ee040cbf67f9c0a8 (diff) | |
download | android-node-v8-c58cea5a163cd5d7133e00fdf257325ce3807c09.tar.gz android-node-v8-c58cea5a163cd5d7133e00fdf257325ce3807c09.tar.bz2 android-node-v8-c58cea5a163cd5d7133e00fdf257325ce3807c09.zip |
deps: upgrade npm to 5.0.0
PR-URL: https://github.com/nodejs/node/pull/13276
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Jeremiah Senkpiel <fishrock123@rocketmail.com>
Diffstat (limited to 'deps/npm/test')
-rw-r--r-- | deps/npm/test/tap/bearer-token-check.js | 5 | ||||
-rw-r--r-- | deps/npm/test/tap/config-meta.js | 1 | ||||
-rw-r--r-- | deps/npm/test/tap/gently-rm-linked-module.js | 68 | ||||
-rw-r--r-- | deps/npm/test/tap/no-scan-full-global-dir.js | 35 | ||||
-rw-r--r-- | deps/npm/test/tap/noargs-install-config-save.js | 2 | ||||
-rw-r--r-- | deps/npm/test/tap/shrinkwrap-extra-metadata.js | 5 | ||||
-rw-r--r-- | deps/npm/test/tap/shrinkwrap-package-integrity.js | 50 | ||||
-rw-r--r-- | deps/npm/test/tap/shrinkwrap-scoped-auth.js | 24 | ||||
-rw-r--r-- | deps/npm/test/tap/uninstall-link-clean.js | 14 | ||||
-rw-r--r-- | deps/npm/test/tap/uninstall-save.js | 96 | ||||
-rw-r--r-- | deps/npm/test/tap/unit-link.js | 2 |
11 files changed, 108 insertions, 194 deletions
diff --git a/deps/npm/test/tap/bearer-token-check.js b/deps/npm/test/tap/bearer-token-check.js index 42c8f313e2..23870d2f21 100644 --- a/deps/npm/test/tap/bearer-token-check.js +++ b/deps/npm/test/tap/bearer-token-check.js @@ -89,7 +89,10 @@ var contents = '@scoped:registry=' + common.registry + '\n' + var json = { name: 'test-package-install', - version: '1.0.0' + version: '1.0.0', + dependencies: { + '@scoped/underscore': '1.3.1' + } } var shrinkwrap = { diff --git a/deps/npm/test/tap/config-meta.js b/deps/npm/test/tap/config-meta.js index d7897a16ce..f667077a1a 100644 --- a/deps/npm/test/tap/config-meta.js +++ b/deps/npm/test/tap/config-meta.js @@ -19,6 +19,7 @@ var exceptions = [ path.resolve(lib, 'adduser.js'), path.resolve(lib, 'config.js'), path.resolve(lib, 'config', 'pacote.js'), + path.resolve(lib, 'pack.js'), path.resolve(lib, 'publish.js'), path.resolve(lib, 'install', 'inflate-shrinkwrap.js'), path.resolve(lib, 'utils', 'lifecycle.js'), diff --git a/deps/npm/test/tap/gently-rm-linked-module.js b/deps/npm/test/tap/gently-rm-linked-module.js index aeae71eee0..a9804cd792 100644 --- a/deps/npm/test/tap/gently-rm-linked-module.js +++ b/deps/npm/test/tap/gently-rm-linked-module.js @@ -46,7 +46,8 @@ var env = extend({}, process.env) env.npm_config_prefix = linkedGlobal var EXEC_OPTS = { cwd: workingDir, - env: env + env: env, + stdio: [0, 'pipe', 2] } test('setup', function (t) { @@ -57,49 +58,32 @@ test('setup', function (t) { }) test('install and link', function (t) { + var globalBin = resolve(linkedGlobal, isWindows ? '.' : 'bin', 'linked') + var globalModule = resolve(linkedGlobal, isWindows ? '.' : 'lib', 'node_modules', '@test', 'linked') // link our test module into the global folder - common.npm( - [ - '--loglevel', 'error', - 'link', - toInstall - ], - EXEC_OPTS, - function (er, code) { - if (er) throw er - t.is(code, 0, 'link succeeded') - var globalBin = resolve(linkedGlobal, isWindows ? '.' : 'bin', 'linked') - var globalModule = resolve(linkedGlobal, isWindows ? '.' : 'lib', 'node_modules', '@test', 'linked') - var localBin = resolve(workingDir, 'node_modules', '.bin', 'linked') - var localModule = resolve(workingDir, 'node_modules', '@test', 'linked') - try { - t.ok(fs.statSync(globalBin), 'global bin exists') - t.is(fs.lstatSync(globalModule).isSymbolicLink(), true, 'global module is link') - t.ok(fs.statSync(localBin), 'local bin exists') - t.is(fs.lstatSync(localModule).isSymbolicLink(), true, 'local module is link') - } catch (ex) { - t.ifError(ex, 'linking happened') - } - if (code !== 0) return t.end() - - // and try removing it and make sure that succeeds - common.npm( - [ - '--global', - '--loglevel', 'error', - 'rm', '@test/linked' - ], - EXEC_OPTS, - function (er, code) { - if (er) throw er - t.is(code, 0, 'rm succeeded') - t.throws(function () { fs.statSync(globalBin) }, 'global bin removed') - t.throws(function () { fs.statSync(globalModule) }, 'global module removed') - t.end() - } - ) + return common.npm(['--loglevel', 'error', 'link', toInstall], EXEC_OPTS).spread((code, out) => { + t.comment(out) + t.is(code, 0, 'link succeeded') + var localBin = resolve(workingDir, 'node_modules', '.bin', 'linked') + var localModule = resolve(workingDir, 'node_modules', '@test', 'linked') + try { + t.ok(fs.statSync(globalBin), 'global bin exists') + t.is(fs.lstatSync(globalModule).isSymbolicLink(), true, 'global module is link') + t.ok(fs.statSync(localBin), 'local bin exists') + t.is(fs.lstatSync(localModule).isSymbolicLink(), true, 'local module is link') + } catch (ex) { + t.ifError(ex, 'linking happened') } - ) + if (code !== 0) throw new Error('aborting') + + // and try removing it and make sure that succeeds + return common.npm(['--global', '--loglevel', 'error', 'rm', '@test/linked'], EXEC_OPTS) + }).spread((code, out) => { + t.comment(out) + t.is(code, 0, 'rm succeeded') + t.throws(function () { fs.statSync(globalBin) }, 'global bin removed') + t.throws(function () { fs.statSync(globalModule) }, 'global module removed') + }) }) test('cleanup', function (t) { diff --git a/deps/npm/test/tap/no-scan-full-global-dir.js b/deps/npm/test/tap/no-scan-full-global-dir.js index ca051fc628..6a9349d54d 100644 --- a/deps/npm/test/tap/no-scan-full-global-dir.js +++ b/deps/npm/test/tap/no-scan-full-global-dir.js @@ -4,7 +4,6 @@ var path = require('path') var test = require('tap').test var requireInject = require('require-inject') var osenv = require('osenv') -var inherits = require('inherits') var npm = require('../../lib/npm.js') var packages = { @@ -47,26 +46,26 @@ test('setup', function (t) { }) }) -function loadArgMetadata (cb) { - this.args = this.args.map(function (arg) { return {name: arg} }) - cb() -} - test('installer', function (t) { t.plan(1) var installer = requireInject('../../lib/install.js', { 'fs': mockFs, 'readdir-scoped-modules': mockReaddir, - 'read-package-json': mockReadPackageJson + 'read-package-json': mockReadPackageJson, + 'mkdirp': function (path, cb) { cb() } }) var Installer = installer.Installer - var TestInstaller = function () { - Installer.apply(this, arguments) - this.global = true + class TestInstaller extends Installer { + constructor (where, dryrun, args) { + super(where, dryrun, args) + this.global = true + } + loadArgMetadata (cb) { + this.args = this.args.map(function (arg) { return {name: arg} }) + cb() + } } - inherits(TestInstaller, Installer) - TestInstaller.prototype.loadArgMetadata = loadArgMetadata var inst = new TestInstaller(__dirname, false, ['def', 'abc']) inst.loadCurrentTree(function () { @@ -81,15 +80,17 @@ test('uninstaller', function (t) { var uninstaller = requireInject('../../lib/uninstall.js', { 'fs': mockFs, 'readdir-scoped-modules': mockReaddir, - 'read-package-json': mockReadPackageJson + 'read-package-json': mockReadPackageJson, + 'mkdirp': function (path, cb) { cb() } }) var Uninstaller = uninstaller.Uninstaller - var TestUninstaller = function () { - Uninstaller.apply(this, arguments) - this.global = true + class TestUninstaller extends Uninstaller { + constructor (where, dryrun, args) { + super(where, dryrun, args) + this.global = true + } } - inherits(TestUninstaller, Uninstaller) var uninst = new TestUninstaller(__dirname, false, ['ghi', 'jkl']) uninst.loadCurrentTree(function () { diff --git a/deps/npm/test/tap/noargs-install-config-save.js b/deps/npm/test/tap/noargs-install-config-save.js index 074d5e848d..12ccf86804 100644 --- a/deps/npm/test/tap/noargs-install-config-save.js +++ b/deps/npm/test/tap/noargs-install-config-save.js @@ -62,7 +62,7 @@ test('updates the package.json (adds dependencies) with an argument', function ( t.plan(2) mr({ port: common.port }, function (er, s) { - common.npm(['install', 'underscore'], OPTS, function (er, code, stdout, stderr) { + common.npm(['install', 'underscore', '-P'], OPTS, function (er, code, stdout, stderr) { if (er) throw er t.is(code, 0) s.close() diff --git a/deps/npm/test/tap/shrinkwrap-extra-metadata.js b/deps/npm/test/tap/shrinkwrap-extra-metadata.js index c5f60e4c22..dd7f85ee82 100644 --- a/deps/npm/test/tap/shrinkwrap-extra-metadata.js +++ b/deps/npm/test/tap/shrinkwrap-extra-metadata.js @@ -7,15 +7,11 @@ const mr = require('npm-registry-mock') const npm = require('../../lib/npm.js') const osenv = require('osenv') const path = require('path') -const pkgSri = require('../../lib/utils/package-integrity.js') const rimraf = require('rimraf') const test = require('tap').test const pkg = path.join(__dirname, path.basename(__filename, '.js')) -const EXEC_OPTS = { - cwd: pkg } - const json = { author: 'Rockbert', name: 'shrinkwrap-extra-metadata', @@ -54,7 +50,6 @@ test('adds additional metadata fields from the pkglock spec', function (t) { 'name': 'shrinkwrap-extra-metadata', 'version': '0.0.0', 'lockfileVersion': npm.lockfileVersion, - 'packageIntegrity': pkgSri.hash(json), 'preserveSymlinks': 'foo' }, JSON.parse(desired), diff --git a/deps/npm/test/tap/shrinkwrap-package-integrity.js b/deps/npm/test/tap/shrinkwrap-package-integrity.js deleted file mode 100644 index 6333757d7f..0000000000 --- a/deps/npm/test/tap/shrinkwrap-package-integrity.js +++ /dev/null @@ -1,50 +0,0 @@ -'use strict' - -const pkgsri = require('../../lib/utils/package-integrity.js') -const ssri = require('ssri') -const test = require('tap').test - -test('generates integrity according to spec', (t) => { - const pkgJson = { - 'name': 'foo', - 'version': '1.0.0', - 'dependencies': { - 'x': '1.0.0' - }, - 'devDependencies': { - 'y': '1.0.0' - }, - 'optionalDependencies': { - 'z': '1.0.0' - } - } - const integrity = pkgsri.hash(pkgJson) - t.ok(integrity && integrity.toString(), 'hash returned') - t.equal( - ssri.parse(integrity).toString(), - integrity, - 'hash is a valid ssri string' - ) - t.ok(pkgsri.check(pkgJson, integrity), 'same-data integrity check succeeds') - t.done() -}) - -test('updates if anything changes in package.json', (t) => { - const pkgJson = { - 'name': 'foo', - 'version': '1.0.0', - 'dependencies': { - 'x': '1.0.0' - }, - 'devDependencies': { - 'y': '1.0.0' - }, - 'optionalDependencies': { - 'z': '1.0.0' - } - } - const sri = pkgsri.hash(pkgJson) - pkgJson.version = '1.2.3' - t.equal(pkgsri.check(pkgJson, sri), false, 'no match after pkgJson change') - t.done() -}) diff --git a/deps/npm/test/tap/shrinkwrap-scoped-auth.js b/deps/npm/test/tap/shrinkwrap-scoped-auth.js index 6d5130137e..bd884c00b7 100644 --- a/deps/npm/test/tap/shrinkwrap-scoped-auth.js +++ b/deps/npm/test/tap/shrinkwrap-scoped-auth.js @@ -1,4 +1,4 @@ -var resolve = require('path').resolve +var path = require('path') var writeFileSync = require('graceful-fs').writeFileSync var mkdirp = require('mkdirp') @@ -10,12 +10,12 @@ var test = require('tap').test var common = require('../common-tap.js') var toNerfDart = require('../../lib/config/nerf-dart.js') -var pkg = resolve(__dirname, 'shrinkwrap-scoped-auth') -var outfile = resolve(pkg, '_npmrc') -var modules = resolve(pkg, 'node_modules') +var pkg = path.resolve(__dirname, path.basename(__filename, '.js')) +var outfile = path.resolve(pkg, '_npmrc') +var modules = path.resolve(pkg, 'node_modules') var tarballPath = '/scoped-underscore/-/scoped-underscore-1.3.1.tgz' var tarballURL = common.registry + tarballPath -var tarball = resolve(__dirname, '../fixtures/scoped-underscore-1.3.1.tgz') +var tarball = path.resolve(__dirname, '../fixtures/scoped-underscore-1.3.1.tgz') var server @@ -46,10 +46,9 @@ test('authed npm install with shrinkwrapped scoped package', function (t) { '--fetch-retries', 0, '--userconfig', outfile ], - {cwd: pkg}, - function (err, code, stdout, stderr) { + {cwd: pkg, stdio: [0, 'pipe', 2]}, + function (err, code, stdout) { if (err) throw err - if (stderr) t.comment(stderr) t.equal(code, 0, 'npm install exited OK') try { var results = JSON.parse(stdout) @@ -75,7 +74,10 @@ var contents = '@scoped:registry=' + common.registry + '\n' + var json = { name: 'test-package-install', - version: '1.0.0' + version: '1.0.0', + dependencies: { + '@scoped/underscore': '1.0.0' + } } var shrinkwrap = { @@ -93,10 +95,10 @@ var shrinkwrap = { function setup () { cleanup() mkdirp.sync(modules) - writeFileSync(resolve(pkg, 'package.json'), JSON.stringify(json, null, 2) + '\n') + writeFileSync(path.resolve(pkg, 'package.json'), JSON.stringify(json, null, 2) + '\n') writeFileSync(outfile, contents) writeFileSync( - resolve(pkg, 'npm-shrinkwrap.json'), + path.resolve(pkg, 'npm-shrinkwrap.json'), JSON.stringify(shrinkwrap, null, 2) + '\n' ) } diff --git a/deps/npm/test/tap/uninstall-link-clean.js b/deps/npm/test/tap/uninstall-link-clean.js index b4759e8895..2b1d244d00 100644 --- a/deps/npm/test/tap/uninstall-link-clean.js +++ b/deps/npm/test/tap/uninstall-link-clean.js @@ -3,15 +3,15 @@ var path = require('path') var existsSync = fs.existsSync || path.existsSync var mkdirp = require('mkdirp') -var osenv = require('osenv') var rimraf = require('rimraf') var test = require('tap').test var common = require('../common-tap.js') -var pkg = path.join(__dirname, 'uninstall-link-clean') -var dep = path.join(__dirname, 'dep') -var work = path.join(__dirname, 'uninstall-link-clean-TEST') +var testdir = path.join(__dirname, path.basename(__filename, '.js')) +var pkg = path.join(testdir, 'pkg') +var dep = path.join(testdir, 'dep') +var work = path.join(testdir, 'uninstall-link-clean-TEST') var modules = path.join(work, 'node_modules') var EXEC_OPTS = { cwd: work, stdio: [0, 'ignore', 2] } @@ -54,7 +54,6 @@ test('setup', function (t) { fs.writeFileSync(path.join(dep, 'world.js'), world) mkdirp.sync(modules) - process.chdir(work) t.end() }) @@ -110,8 +109,5 @@ test('cleanup', function (t) { }) function cleanup () { - process.chdir(osenv.tmpdir()) - rimraf.sync(dep) - rimraf.sync(work) - rimraf.sync(pkg) + rimraf.sync(testdir) } diff --git a/deps/npm/test/tap/uninstall-save.js b/deps/npm/test/tap/uninstall-save.js index 47cffdb521..9bf342d7cf 100644 --- a/deps/npm/test/tap/uninstall-save.js +++ b/deps/npm/test/tap/uninstall-save.js @@ -10,7 +10,7 @@ var test = require('tap').test var common = require('../common-tap.js') var server -var pkg = path.join(__dirname, 'uninstall-save') +var pkg = path.join(__dirname, path.basename(__filename, '.js')) var EXEC_OPTS = { cwd: pkg, stdio: [0, 'ignore', 2] } @@ -29,62 +29,44 @@ test('setup', function (t) { }) test('uninstall --save removes rm-ed package from package.json', function (t) { - common.npm( - [ - '--registry', common.registry, - '--loglevel', 'error', - '--save-prefix', '^', - '--save', - 'install', 'underscore@latest' - ], - EXEC_OPTS, - function (err, code) { - t.ifError(err, 'npm install ran without issue') - t.notOk(code, 'npm install exited with code 0') - - var p = path.join(pkg, 'node_modules', 'underscore', 'package.json') - t.ok(JSON.parse(fs.readFileSync(p))) - - var pkgJson = JSON.parse(fs.readFileSync( - path.join(pkg, 'package.json'), - 'utf8' - )) - t.deepEqual( - pkgJson.dependencies, - { 'underscore': '^1.5.1' }, - 'got expected save prefix and version of 1.5.1' - ) - - var installed = path.join(pkg, 'node_modules', 'underscore') - rimraf.sync(installed) - - common.npm( - [ - '--registry', common.registry, - '--loglevel', 'debug', - '--save', - 'uninstall', 'underscore' - ], - EXEC_OPTS, - function (err, code) { - t.ifError(err, 'npm uninstall ran without issue') - - var pkgJson = JSON.parse(fs.readFileSync( - path.join(pkg, 'package.json'), - 'utf8' - )) - - t.deepEqual( - pkgJson.dependencies, - { }, - 'dependency removed as expected' - ) - - t.end() - } - ) - } - ) + var config = [ + '--registry', common.registry, + '--save-prefix', '^', + '--save', + '--loglevel=error' + ] + return common.npm(config.concat(['install', 'underscore@latest']), EXEC_OPTS).spread((code) => { + t.notOk(code, 'npm install exited with code 0') + + var p = path.join(pkg, 'node_modules', 'underscore', 'package.json') + t.ok(JSON.parse(fs.readFileSync(p))) + + var pkgJson = JSON.parse(fs.readFileSync( + path.join(pkg, 'package.json'), + 'utf8' + )) + t.deepEqual( + pkgJson.dependencies, + { 'underscore': '^1.5.1' }, + 'got expected save prefix and version of 1.5.1' + ) + + var installed = path.join(pkg, 'node_modules', 'underscore') + rimraf.sync(installed) + + return common.npm(config.concat(['uninstall', 'underscore']), EXEC_OPTS) + }).spread((code) => { + var pkgJson = JSON.parse(fs.readFileSync( + path.join(pkg, 'package.json'), + 'utf8' + )) + + t.deepEqual( + pkgJson.dependencies, + { }, + 'dependency removed as expected' + ) + }) }) test('cleanup', function (t) { diff --git a/deps/npm/test/tap/unit-link.js b/deps/npm/test/tap/unit-link.js index e4b9094068..4f4083e110 100644 --- a/deps/npm/test/tap/unit-link.js +++ b/deps/npm/test/tap/unit-link.js @@ -227,7 +227,7 @@ function testLink (opts, cb) { } } }, - '../../lib/utils/gently-rm.js': dezalgo(function (toRemove, gently, cb) { + '../../lib/utils/gently-rm.js': dezalgo(function (toRemove, gently, basedir, cb) { if (opts.rm[toRemove] && opts.rm[toRemove].gently === gently) { cb() } else { |