diff options
Diffstat (limited to 'deps/node/deps/npm/test/need-npm5-update/belongs-in-pacote')
-rw-r--r-- | deps/node/deps/npm/test/need-npm5-update/belongs-in-pacote/add-remote-git-get-resolved.js | 129 | ||||
-rw-r--r-- | deps/node/deps/npm/test/need-npm5-update/belongs-in-pacote/git-races.js | 219 |
2 files changed, 0 insertions, 348 deletions
diff --git a/deps/node/deps/npm/test/need-npm5-update/belongs-in-pacote/add-remote-git-get-resolved.js b/deps/node/deps/npm/test/need-npm5-update/belongs-in-pacote/add-remote-git-get-resolved.js deleted file mode 100644 index fadfc330..00000000 --- a/deps/node/deps/npm/test/need-npm5-update/belongs-in-pacote/add-remote-git-get-resolved.js +++ /dev/null @@ -1,129 +0,0 @@ -'use strict' -var test = require('tap').test - -var npm = require('../../lib/npm.js') -var common = require('../common-tap.js') -var npa = require('npm-package-arg') - -var getResolved = null - -/** - * Note: This is here because `normalizeGitUrl` is usually called - * before getResolved is, and receives *that* URL. - */ -function tryGetResolved (uri, treeish) { - return getResolved(npa(uri), uri, treeish) -} - -test('setup', function (t) { - var opts = { - registry: common.registry, - loglevel: 'silent' - } - npm.load(opts, function (er) { - t.ifError(er, 'npm loaded without error') - getResolved = require('../../lib/cache/add-remote-git.js').getResolved - t.end() - }) -}) - -test('add-remote-git#get-resolved git: passthru', function (t) { - verify('git:github.com/foo/repo') - verify('git:github.com/foo/repo.git') - verify('git://github.com/foo/repo#decadacefadabade') - verify('git://github.com/foo/repo.git#decadacefadabade') - - function verify (uri) { - t.equal( - tryGetResolved(uri, 'decadacefadabade'), - 'git://github.com/foo/repo.git#decadacefadabade', - uri + ' normalized to canonical form git://github.com/foo/repo.git#decadacefadabade' - ) - } - t.end() -}) - -test('add-remote-git#get-resolved SSH', function (t) { - t.comment('tests for https://github.com/npm/npm/issues/7961') - verify('git+ssh://git@github.com:foo/repo') - verify('git+ssh://git@github.com:foo/repo#master') - verify('git+ssh://git@github.com/foo/repo#master') - verify('git+ssh://git@github.com/foo/repo#decadacefadabade') - - function verify (uri) { - t.equal( - tryGetResolved(uri, 'decadacefadabade'), - 'git+ssh://git@github.com/foo/repo.git#decadacefadabade', - uri + ' normalized to canonical form git+ssh://git@github.com/foo/repo.git#decadacefadabade' - ) - } - t.end() -}) - -test('add-remote-git#get-resolved HTTPS', function (t) { - verify('https://github.com/foo/repo') - verify('https://github.com/foo/repo#master') - verify('git+https://github.com/foo/repo.git#master') - verify('git+https://github.com/foo/repo#decadacefadabade') - // DEPRECATED - // this is an invalid URL but we normalize it - // anyway. Users shouldn't use this in the future. See note - // below for how this affected non-hosted URLs. - // See https://github.com/npm/npm/issues/8881 - verify('git+https://github.com:foo/repo.git#master') - - function verify (uri) { - t.equal( - tryGetResolved(uri, 'decadacefadabade'), - 'git+https://github.com/foo/repo.git#decadacefadabade', - uri + ' normalized to canonical form git+https://github.com/foo/repo.git#decadacefadabade' - ) - } - t.end() -}) - -test('add-remote-git#get-resolved edge cases', function (t) { - t.equal( - tryGetResolved('git+ssh://user@bananaboat.com:galbi/blah.git', 'decadacefadabade'), - 'git+ssh://user@bananaboat.com:galbi/blah.git#decadacefadabade', - 'don\'t break non-hosted scp-style locations' - ) - /* - t.equal( - tryGetResolved('git+ssh://bananaboat:galbi/blah', 'decadacefadabade'), - 'git+ssh://bananaboat:galbi/blah#decadacefadabade', - 'don\'t break non-hosted scp-style locations' - ) - - // DEPRECATED - // When we were normalizing all git URIs, git+https: was being - // automatically converted to ssh:. Some users were relying - // on this funky behavior, so after removing the aggressive - // normalization from non-hosted URIs, we brought this back. - // See https://github.com/npm/npm/issues/8881 - t.equal( - tryGetResolved('git+https://bananaboat:galbi/blah', 'decadacefadabade'), - 'git+https://bananaboat/galbi/blah#decadacefadabade', - 'don\'t break non-hosted scp-style locations' - ) - - t.equal( - tryGetResolved('git+ssh://git.bananaboat.net/foo', 'decadacefadabade'), - 'git+ssh://git.bananaboat.net/foo#decadacefadabade', - 'don\'t break non-hosted SSH URLs' - ) - - t.equal( - tryGetResolved('git+ssh://git.bananaboat.net:/foo', 'decadacefadabade'), - 'git+ssh://git.bananaboat.net:/foo#decadacefadabade', - 'don\'t break non-hosted SSH URLs' - ) - - t.equal( - tryGetResolved('git://gitbub.com/foo/bar.git', 'decadacefadabade'), - 'git://gitbub.com/foo/bar.git#decadacefadabade', - 'don\'t break non-hosted git: URLs' - ) -*/ - t.end() -}) diff --git a/deps/node/deps/npm/test/need-npm5-update/belongs-in-pacote/git-races.js b/deps/node/deps/npm/test/need-npm5-update/belongs-in-pacote/git-races.js deleted file mode 100644 index 60136125..00000000 --- a/deps/node/deps/npm/test/need-npm5-update/belongs-in-pacote/git-races.js +++ /dev/null @@ -1,219 +0,0 @@ -/* eslint-disable camelcase */ -var execFile = require('child_process').execFile -var path = require('path') -var zlib = require('zlib') - -var asyncMap = require('slide').asyncMap -var deepEqual = require('deep-equal') -var fs = require('graceful-fs') -var mkdirp = require('mkdirp') -var once = require('once') -var requireInject = require('require-inject') -var rimraf = require('rimraf') -var tar = require('tar') -var test = require('tap').test -var tmpdir = require('osenv').tmpdir -var which = require('which') - -var wd = path.resolve(tmpdir(), 'git-races') -var fixtures = path.resolve(__dirname, '../fixtures') -var testcase = 'github-com-BryanDonovan-npm-git-test' -var testcase_git = path.resolve(wd, testcase + '.git') -var testcase_path = path.resolve(wd, testcase) -var testcase_tgz = path.resolve(fixtures, testcase + '.git.tar.gz') - -var testtarballs = [] -var testrepos = {} -var testurls = {} - -/* -This test is specifically for #7202, where the bug was if you tried installing multiple git urls that -pointed at the same repo but had different comittishes, you'd sometimes get the wrong version. -The test cases, provided by @BryanDonovan, have a dependency tree like this: - - top - bar#4.0.0 - buzz#3.0.0 - foo#3.0.0 - buzz#3.0.0 - foo#4.0.0 - buzz#2.0.0 - -But what would happen is that buzz#2.0.0 would end up installed under bar#4.0.0. - -bar#4.0.0 shouldn't have gotten its own copy if buzz, and if it did, it shouldn've been buzz#3.0.0 -*/ - -;['bar', 'foo', 'buzz'].forEach(function (name) { - var mockurl = 'ssh://git@github.com/BryanDonovan/dummy-npm-' + name + '.git' - var realrepo = path.resolve(wd, 'github-com-BryanDonovan-dummy-npm-' + name + '.git') - var tgz = path.resolve(fixtures, 'github-com-BryanDonovan-dummy-npm-' + name + '.git.tar.gz') - - testrepos[mockurl] = realrepo - testtarballs.push(tgz) -}) - -function cleanup () { - process.chdir(tmpdir()) - rimraf.sync(wd) -} - -var npm = requireInject.installGlobally('../../lib/npm.js', { - 'child_process': { - 'execFile': function (cmd, args, options, cb) { - // on win 32, the following prefix is added in utils/git.js - // $ git -c core.longpaths=true clone - var i = process.platform === 'win32' ? 2 : 0 - // If it's a clone we swap any requests for any of the urls we're mocking - // with the path to the bare repo - if (args[i] === 'clone') { - var m2 = args.length - 2 - var m1 = args.length - 1 - if (testrepos[args[m2]]) { - testurls[args[m1]] = args[m2] - args[m2] = testrepos[args[m2]] - } - execFile(cmd, args, options, cb) - // here, we intercept npm validating the remote origin url on one of the - // clones we've done previously and return the original url that was requested - } else if (args[i] === 'config' && args[i + 1] === '--get' && args[i + 2] === 'remote.origin.url') { - process.nextTick(function () { - cb(null, testurls[options.cwd], '') - }) - } else { - execFile(cmd, args, options, cb) - } - } - } -}) - -function extract (tarball, target, cb) { - cb = once(cb) - fs.createReadStream(tarball).on('error', function (er) { cb(er) }) - .pipe(zlib.createGunzip()).on('error', function (er) { cb(er) }) - .pipe(tar.Extract({path: target})).on('error', function (er) { cb(er) }) - .on('end', function () { - cb() - }) -} - -// Copied from lib/utils/git, because we need to use -// it before calling npm.load and lib/utils/git uses npm.js -// which doesn't allow that. =( =( - -function prefixGitArgs () { - return process.platform === 'win32' ? ['-c', 'core.longpaths=true'] : [] -} - -var gitcmd - -function execGit (args, options, cb) { - var fullArgs = prefixGitArgs().concat(args || []) - return execFile(gitcmd, fullArgs, options, cb) -} - -function gitWhichAndExec (args, options, cb) { - if (gitcmd) return execGit(args, options, cb) - - which('git', function (err, pathtogit) { - if (err) { - err.code = 'ENOGIT' - return cb(err) - } - gitcmd = pathtogit - - execGit(args, options, cb) - }) -} - -function andClone (gitdir, repodir, cb) { - return function (er) { - if (er) return cb(er) - gitWhichAndExec(['clone', gitdir, repodir], {}, cb) - } -} - -function setup (cb) { - cleanup() - mkdirp.sync(wd) - - extract(testcase_tgz, wd, andClone(testcase_git, testcase_path, andExtractPackages)) - - function andExtractPackages (er) { - if (er) return cb(er) - asyncMap(testtarballs, function (tgz, done) { - extract(tgz, wd, done) - }, andChdir) - } - function andChdir (er) { - if (er) return cb(er) - process.chdir(testcase_path) - andLoadNpm() - } - function andLoadNpm () { - var opts = { - cache: path.resolve(wd, 'cache') - } - npm.load(opts, cb) - } -} - -// there are two (sic) valid trees that can result we don't care which one we -// get in npm@2 -var oneTree = [ - 'npm-git-test@1.0.0', [ - ['dummy-npm-bar@4.0.0', [ - ['dummy-npm-foo@3.0.0', []], - ['dummy-npm-buzz@3.0.0', []] - ]], - ['dummy-npm-buzz@3.0.0', []], - ['dummy-npm-foo@4.0.0', [ - ['dummy-npm-buzz@2.0.0', []] - ]] - ] -] -var otherTree = [ - 'npm-git-test@1.0.0', [ - ['dummy-npm-bar@4.0.0', [ - ['dummy-npm-buzz@3.0.0', []], - ['dummy-npm-foo@3.0.0', []] - ]], - ['dummy-npm-buzz@3.0.0', []], - ['dummy-npm-foo@4.0.0', [ - ['dummy-npm-buzz@2.0.0', []] - ]] - ] -] - -function toSimple (tree) { - var deps = [] - Object.keys(tree.dependencies || {}).forEach(function (dep) { - deps.push(toSimple(tree.dependencies[dep])) - }) - return [ tree['name'] + '@' + tree['version'], deps ] -} - -test('setup', function (t) { - setup(function (er) { - t.ifError(er, 'setup ran OK') - t.end() - }) -}) - -test('correct versions are installed for git dependency', function (t) { - t.comment('test for https://github.com/npm/npm/issues/7202') - npm.commands.install([], function (er) { - t.ifError(er, 'installed OK') - npm.commands.ls([], true, function (er, result) { - t.ifError(er, 'ls OK') - var simplified = toSimple(result) - if (deepEqual(simplified, oneTree) || deepEqual(simplified, otherTree)) { - t.pass('install tree is correct') - } else { - t.isDeeply(simplified, oneTree, 'oneTree matches') - t.isDeeply(simplified, otherTree, 'otherTree matches') - } - t.done() - }) - }) -}) |