diff options
author | isaacs <i@izs.me> | 2013-12-11 10:20:26 -0800 |
---|---|---|
committer | isaacs <i@izs.me> | 2013-12-11 10:20:26 -0800 |
commit | a22de4f7eed04f14e590fdc5c8739d2ee17753e5 (patch) | |
tree | ac02ad050e8ca27e6d792d6923f9d0c0d508b298 /deps/npm/test | |
parent | f16edd2632930e3fbfead4d6d52eeac87824f1a6 (diff) | |
download | node-a22de4f7eed04f14e590fdc5c8739d2ee17753e5.tar.gz |
npm: Upgrade to 1.3.17
Diffstat (limited to 'deps/npm/test')
23 files changed, 440 insertions, 12 deletions
diff --git a/deps/npm/test/disabled/outdated-depth-integer.js b/deps/npm/test/disabled/outdated-depth-integer.js new file mode 100644 index 000000000..9e4087a4c --- /dev/null +++ b/deps/npm/test/disabled/outdated-depth-integer.js @@ -0,0 +1,52 @@ +var common = require('../common-tap') + , test = require('tap').test + , rimraf = require('rimraf') + , npm = require('../../') + , mr = require('npm-registry-mock') + , pkg = __dirname + '/outdated-depth' + +function cleanup () { + rimraf.sync(pkg + '/node_modules') + rimraf.sync(pkg + '/cache') +} + +test('outdated depth integer', function (t) { + // todo: update with test-package-with-one-dep once the new + // npm-registry-mock is published + var expected = [ + pkg, + 'underscore', + '1.3.1', + '1.3.1', + '1.5.1', + '1.3.1' + ] + + process.chdir(pkg) + + mr(common.port, function (s) { + npm.load({ + cache: pkg + '/cache' + , loglevel: 'silent' + , registry: common.registry + , depth: 5 + } + , function () { + npm.install('request@0.9.0', function (er) { + if (er) throw new Error(er) + npm.outdated(function (err, d) { + if (err) throw new Error(err) + t.deepEqual(d[0], expected) + s.close() + t.end() + }) + }) + } + ) + }) +}) + +test("cleanup", function (t) { + cleanup() + t.end() +})
\ No newline at end of file diff --git a/deps/npm/test/disabled/outdated-depth-integer/README.md b/deps/npm/test/disabled/outdated-depth-integer/README.md new file mode 100644 index 000000000..aca67ff17 --- /dev/null +++ b/deps/npm/test/disabled/outdated-depth-integer/README.md @@ -0,0 +1 @@ +# just a test diff --git a/deps/npm/test/disabled/outdated-depth-integer/index.js b/deps/npm/test/disabled/outdated-depth-integer/index.js new file mode 100644 index 000000000..33c1891f8 --- /dev/null +++ b/deps/npm/test/disabled/outdated-depth-integer/index.js @@ -0,0 +1 @@ +module.exports = true diff --git a/deps/npm/test/disabled/outdated-depth-integer/package.json b/deps/npm/test/disabled/outdated-depth-integer/package.json new file mode 100644 index 000000000..df269dc72 --- /dev/null +++ b/deps/npm/test/disabled/outdated-depth-integer/package.json @@ -0,0 +1,10 @@ +{ + "name": "whatever", + "description": "yeah idk", + "version": "1.2.3", + "main": "index.js", + "dependencies": { + "underscore": "1.3.1" + }, + "repository": "git://github.com/luk-/whatever" +} diff --git a/deps/npm/test/disabled/startstop/package.json b/deps/npm/test/disabled/startstop/package.json deleted file mode 100644 index bee2a2fd3..000000000 --- a/deps/npm/test/disabled/startstop/package.json +++ /dev/null @@ -1,3 +0,0 @@ -{"name":"startstop" -,"version":"1.2.3" -,"scripts":{"start":"echo 'start'","stop":"echo 'stop'"}} diff --git a/deps/npm/test/packages/npm-test-blerg/package.json b/deps/npm/test/packages/npm-test-blerg/package.json index 0db81d680..de5eccb66 100644 --- a/deps/npm/test/packages/npm-test-blerg/package.json +++ b/deps/npm/test/packages/npm-test-blerg/package.json @@ -1,5 +1,5 @@ { "name":"npm-test-blerg" -, "version" : "0.0.0" +, "version" : "0.0.1" , "scripts" : { "test" : "node test.js" } , "publishConfig": {"tag": "foo"} } diff --git a/deps/npm/test/tap/dedupe.js b/deps/npm/test/tap/dedupe.js new file mode 100644 index 000000000..3f57bf02b --- /dev/null +++ b/deps/npm/test/tap/dedupe.js @@ -0,0 +1,29 @@ +var test = require("tap").test + , fs = require("fs") + , path = require("path") + , existsSync = fs.existsSync || path.existsSync + , npm = require("../../") + , rimraf = require("rimraf") + +test("dedupe finds the common module and moves it up one level", function (t) { + t.plan(1) + + setup(function () { + npm.install(".", function (err) { + if (err) return t.fail(err) + npm.dedupe(function(err) { + if (err) return t.fail(err) + t.ok(existsSync(path.join(__dirname, "dedupe", "node_modules", "minimist"))) + }) + }) + }) +}) + +function setup (cb) { + process.chdir(path.join(__dirname, "dedupe")) + npm.load(function () { + rimraf.sync(path.join(__dirname, "dedupe", "node_modules")) + fs.mkdirSync(path.join(__dirname, "dedupe", "node_modules")) + cb() + }) +} diff --git a/deps/npm/test/tap/dedupe/package.json b/deps/npm/test/tap/dedupe/package.json new file mode 100644 index 000000000..842d4b2b2 --- /dev/null +++ b/deps/npm/test/tap/dedupe/package.json @@ -0,0 +1,9 @@ +{ + "author": "Dedupe tester", + "name": "dedupe", + "version": "0.0.0", + "dependencies": { + "optimist": "0.6.0", + "clean": "2.1.6" + } +} diff --git a/deps/npm/test/tap/ignore-shrinkwrap.js b/deps/npm/test/tap/ignore-shrinkwrap.js index 29dc9afee..ce1c66425 100644 --- a/deps/npm/test/tap/ignore-shrinkwrap.js +++ b/deps/npm/test/tap/ignore-shrinkwrap.js @@ -1,6 +1,5 @@ var common = require("../common-tap.js") var test = require("tap").test -var npm = require("../../") var pkg = './ignore-shrinkwrap' var mr = require("npm-registry-mock") diff --git a/deps/npm/test/tap/lifecycle-signal.js b/deps/npm/test/tap/lifecycle-signal.js index f7318c7d6..e39e891e1 100644 --- a/deps/npm/test/tap/lifecycle-signal.js +++ b/deps/npm/test/tap/lifecycle-signal.js @@ -6,6 +6,8 @@ var path = require("path") var pkg = path.resolve(__dirname, "lifecycle-signal") test("lifecycle signal abort", function (t) { + // windows does not use lifecycle signals, abort + if (process.platform === "win32") return t.end() var child = spawn(node, [npm, "install"], { cwd: pkg }) diff --git a/deps/npm/test/tap/outdated-depth.js b/deps/npm/test/tap/outdated-depth.js new file mode 100644 index 000000000..e33d140f0 --- /dev/null +++ b/deps/npm/test/tap/outdated-depth.js @@ -0,0 +1,50 @@ +var common = require('../common-tap') + , test = require('tap').test + , rimraf = require('rimraf') + , npm = require('../../') + , mr = require('npm-registry-mock') + , pkg = __dirname + '/outdated-depth' + +function cleanup () { + rimraf.sync(pkg + '/node_modules') + rimraf.sync(pkg + '/cache') +} + +test('outdated depth zero', function (t) { + var expected = [ + pkg, + 'underscore', + '1.3.1', + '1.3.1', + '1.5.1', + '1.3.1' + ] + + process.chdir(pkg) + + mr(common.port, function (s) { + npm.load({ + cache: pkg + '/cache' + , loglevel: 'silent' + , registry: common.registry + , depth: 0 + } + , function () { + npm.install('.', function (er) { + if (er) throw new Error(er) + npm.outdated(function (err, d) { + if (err) throw new Error(err) + t.deepEqual(d[0], expected) + s.close() + t.end() + }) + }) + } + ) + }) +}) + +test("cleanup", function (t) { + cleanup() + t.end() +})
\ No newline at end of file diff --git a/deps/npm/test/tap/outdated-depth/README.md b/deps/npm/test/tap/outdated-depth/README.md new file mode 100644 index 000000000..aca67ff17 --- /dev/null +++ b/deps/npm/test/tap/outdated-depth/README.md @@ -0,0 +1 @@ +# just a test diff --git a/deps/npm/test/tap/outdated-depth/index.js b/deps/npm/test/tap/outdated-depth/index.js new file mode 100644 index 000000000..33c1891f8 --- /dev/null +++ b/deps/npm/test/tap/outdated-depth/index.js @@ -0,0 +1 @@ +module.exports = true diff --git a/deps/npm/test/tap/outdated-depth/package.json b/deps/npm/test/tap/outdated-depth/package.json new file mode 100644 index 000000000..df269dc72 --- /dev/null +++ b/deps/npm/test/tap/outdated-depth/package.json @@ -0,0 +1,10 @@ +{ + "name": "whatever", + "description": "yeah idk", + "version": "1.2.3", + "main": "index.js", + "dependencies": { + "underscore": "1.3.1" + }, + "repository": "git://github.com/luk-/whatever" +} diff --git a/deps/npm/test/tap/outdated-git.js b/deps/npm/test/tap/outdated-git.js new file mode 100644 index 000000000..433f8b044 --- /dev/null +++ b/deps/npm/test/tap/outdated-git.js @@ -0,0 +1,28 @@ +var common = require("../common-tap.js") +var test = require("tap").test +var npm = require("../../") +var mkdirp = require("mkdirp") +var rimraf = require("rimraf") +var mr = require("npm-registry-mock") + +// config +var pkg = __dirname + "/outdated-git" +mkdirp.sync(pkg + "/cache") + + +test("dicovers new versions in outdated", function (t) { + process.chdir(pkg) + t.plan(3) + npm.load({cache: pkg + "/cache", registry: common.registry}, function () { + npm.outdated(function (er, d) { + t.equal('git', d[0][3]) + t.equal('git', d[0][4]) + t.equal('git://github.com/robertkowalski/foo-private.git', d[0][5]) + }) + }) +}) + +test("cleanup", function (t) { + rimraf.sync(pkg + "/cache") + t.end() +}) diff --git a/deps/npm/test/tap/outdated-git/README.md b/deps/npm/test/tap/outdated-git/README.md new file mode 100644 index 000000000..d173390cb --- /dev/null +++ b/deps/npm/test/tap/outdated-git/README.md @@ -0,0 +1 @@ +just a test diff --git a/deps/npm/test/tap/outdated-git/package.json b/deps/npm/test/tap/outdated-git/package.json new file mode 100644 index 000000000..02385d582 --- /dev/null +++ b/deps/npm/test/tap/outdated-git/package.json @@ -0,0 +1,10 @@ +{ + "name": "outdated-git", + "author": "Rocko Artischocko", + "description": "fixture", + "version": "0.0.1", + "main": "index.js", + "dependencies": { + "foo-private": "git://github.com/robertkowalski/foo-private.git" + } +} diff --git a/deps/npm/test/tap/outdated-json.js b/deps/npm/test/tap/outdated-json.js new file mode 100644 index 000000000..f54642fab --- /dev/null +++ b/deps/npm/test/tap/outdated-json.js @@ -0,0 +1,70 @@ +var common = require("../common-tap.js") + , test = require("tap").test + , rimraf = require("rimraf") + , npm = require("../../") + , mr = require("npm-registry-mock") + , path = require("path") + , spawn = require('child_process').spawn + , node = process.execPath + , npmc = require.resolve('../../') + , pkg = __dirname + '/outdated-new-versions' + , args = [ npmc + , 'outdated' + , '--json' + , '--silent' + , '--registry=' + common.registry + , '--cache=' + pkg + '/cache' + ] + +var expected = { underscore: + { current: '1.3.3' + , wanted: '1.3.3' + , latest: '1.5.1' + , location: 'node_modules' + path.sep + 'underscore' + } + , request: + { current: '0.9.5' + , wanted: '0.9.5' + , latest: '2.27.0' + , location: 'node_modules' + path.sep + 'request' + } + } + +test("it should log json data", function (t) { + cleanup() + process.chdir(pkg) + + mr(common.port, function (s) { + npm.load({ + cache: pkg + "/cache", + loglevel: 'silent', + registry: common.registry } + , function () { + npm.install(".", function (err) { + var child = spawn(node, args) + , out = '' + child.stdout + .on('data', function (buf) { + out += buf.toString() + }) + .pipe(process.stdout) + child.on('exit', function () { + out = JSON.parse(out) + t.deepEqual(out, expected) + s.close() + t.end() + }) + }) + }) + }) +}) + +test("cleanup", function (t) { + cleanup() + t.end() +}) + +function cleanup () { + rimraf.sync(pkg + "/node_modules") + rimraf.sync(pkg + "/cache") +} diff --git a/deps/npm/test/tap/prepublish.js b/deps/npm/test/tap/prepublish.js index 56d7158b0..355ce1a23 100644 --- a/deps/npm/test/tap/prepublish.js +++ b/deps/npm/test/tap/prepublish.js @@ -69,12 +69,14 @@ test('test', function (t) { } function onend () { c = c.trim() - t.equal( c - , '> npm-test-prepublish@1.2.5 prepublish .' + os.EOL - + '> echo ok' + os.EOL - + os.EOL - + 'ok' + os.EOL - + 'npm-test-prepublish-1.2.5.tgz') + var regex = new RegExp("" + + "> npm-test-prepublish@1.2.5 prepublish [^\\r\\n]+\\r?\\n" + + "> echo ok\\r?\\n" + + "\\r?\\n" + + "ok\\r?\\n" + + "npm-test-prepublish-1.2.5.tgz", "ig") + + t.ok(c.match(regex)) t.end() } }) diff --git a/deps/npm/test/tap/publish-config.js b/deps/npm/test/tap/publish-config.js index 2a6f9523c..3c4624eea 100644 --- a/deps/npm/test/tap/publish-config.js +++ b/deps/npm/test/tap/publish-config.js @@ -36,7 +36,7 @@ test(function (t) { // itself functions normally. // // Make sure that we don't sit around waiting for lock files - child = spawn(node, [npm, 'publish'], { + child = spawn(node, [npm, 'publish', '--email=fancy', '--_auth=feast'], { cwd: pkg, env: { npm_config_cache_lock_stale: 1000, diff --git a/deps/npm/test/tap/startstop.js b/deps/npm/test/tap/startstop.js new file mode 100644 index 000000000..f94f3b029 --- /dev/null +++ b/deps/npm/test/tap/startstop.js @@ -0,0 +1,78 @@ +var common = require('../common-tap') + , test = require('tap').test + , path = require('path') + , spawn = require('child_process').spawn + , rimraf = require('rimraf') + , mkdirp = require('mkdirp') + , pkg = __dirname + '/startstop' + , cache = pkg + '/cache' + , tmp = pkg + '/tmp' + , node = process.execPath + , npm = path.resolve(__dirname, '../../cli.js') + +function run (command, t, parse) { + var c = '' + , node = process.execPath + , child = spawn(node, [npm, command], { + cwd: pkg + }) + + child.stderr.on('data', function (chunk) { + throw new Error('npm ' + command + ' stderr: ' + chunk.toString()) + }) + + child.stdout.on('data', function (chunk) { + c += chunk + }) + + child.stdout.on('end', function () { + if (parse) { + // custom parsing function + c = parse(c) + t.equal(c.actual, c.expected) + t.end() + return + } + + c = c.trim().split('\n') + c = c[c.length - 1] + t.equal(c, command) + t.end() + }) + +} + +function cleanup () { + rimraf.sync(pkg + '/cache') + rimraf.sync(pkg + '/tmp') +} + +test('setup', function (t) { + cleanup() + mkdirp.sync(pkg + '/cache') + mkdirp.sync(pkg + '/tmp') + t.end() + +}) + +test('npm start', function (t) { + run('start', t) +}) + +test('npm stop', function (t) { + run('stop', t) +}) + +test('npm restart', function (t) { + run ('restart', t, function (output) { + output = output.split('\n').filter(function (val) { + return val.match(/^s/) + }) + return {actual: output, expected: output} + }) +}) + +test('cleanup', function (t) { + cleanup() + t.end() +}) diff --git a/deps/npm/test/tap/startstop/package.json b/deps/npm/test/tap/startstop/package.json new file mode 100644 index 000000000..3be0cf375 --- /dev/null +++ b/deps/npm/test/tap/startstop/package.json @@ -0,0 +1,7 @@ +{"name":"startstop" +,"version":"1.2.3" +,"scripts":{ + "start":"node -e 'console.log(\"start\")'", + "stop":"node -e 'console.log(\"stop\")'" + } +} diff --git a/deps/npm/test/tap/version-no-tags.js b/deps/npm/test/tap/version-no-tags.js new file mode 100644 index 000000000..20fe933c6 --- /dev/null +++ b/deps/npm/test/tap/version-no-tags.js @@ -0,0 +1,70 @@ +var common = require('../common-tap.js') +var test = require('tap').test +var npm = require('../../') +var npmc = require.resolve('../../') +var osenv = require('osenv') +var path = require('path') +var fs = require('fs') +var rimraf = require('rimraf') +var mkdirp = require('mkdirp') +var which = require('which') +var util = require('util') +var spawn = require('child_process').spawn +var args = [ npmc + , 'version' + , 'patch' + , '--no-git-tag-version' + ] +var pkg = __dirname + '/version-no-tags' + +test("npm version <semver> without git tag", function (t) { + setup() + npm.load({ cache: pkg + '/cache', registry: common.registry}, function () { + which('git', function(err, git) { + function tagExists(tag, _cb) { + var child = spawn(git, ['tag', '-l', tag]) + var out = '' + child.stdout.on('data', function(d) { + out += data.toString() + }) + child.on('exit', function() { + return _cb(null, Boolean(~out.indexOf(tag))) + }) + } + + var child = spawn(git, ['init']) + child.stdout.pipe(process.stdout) + child.on('exit', function() { + npm.config.set('git-tag-version', false) + npm.commands.version(['patch'], function(err) { + if (err) return t.fail('Error perform version patch') + var testPkg = require(pkg+'/package') + if (testPkg.version !== '0.0.1') t.fail(testPkg.version+' !== \'0.0.1\'') + t.ok('0.0.1' === testPkg.version) + tagExists('v0.0.1', function(err, exists) { + t.equal(exists, false, 'git tag DOES exist') + t.pass('git tag does not exist') + t.end() + }) + }) + }) + }) + }) +}) + +test('cleanup', function(t) { + rimraf.sync(pkg) + t.end() +}) + +function setup() { + mkdirp.sync(pkg) + mkdirp.sync(pkg + '/cache') + fs.writeFileSync(pkg + '/package.json', JSON.stringify({ + author: "Evan Lucas", + name: "version-no-tags-test", + version: "0.0.0", + description: "Test for git-tag-version flag" + }), 'utf8') + process.chdir(pkg) +}
\ No newline at end of file |