diff options
Diffstat (limited to 'deps/npm/test')
-rw-r--r-- | deps/npm/test/common-tap.js | 2 | ||||
-rw-r--r-- | deps/npm/test/tap/ignore-shrinkwrap.js | 11 | ||||
-rw-r--r-- | deps/npm/test/tap/lifecycle-signal.js | 17 | ||||
-rw-r--r-- | deps/npm/test/tap/lifecycle-signal/package.json | 3 | ||||
-rw-r--r-- | deps/npm/test/tap/noargs-install-config-save.js | 17 | ||||
-rw-r--r-- | deps/npm/test/tap/outdated-include-devdependencies.js | 19 | ||||
-rw-r--r-- | deps/npm/test/tap/outdated-new-versions.js | 10 | ||||
-rw-r--r-- | deps/npm/test/tap/outdated.js | 22 | ||||
-rw-r--r-- | deps/npm/test/tap/outdated/README.md | 1 | ||||
-rw-r--r-- | deps/npm/test/tap/outdated/package.json | 4 | ||||
-rw-r--r-- | deps/npm/test/tap/peer-deps-invalid.js | 3 | ||||
-rw-r--r-- | deps/npm/test/tap/peer-deps-without-package-json.js | 5 | ||||
-rw-r--r-- | deps/npm/test/tap/publish-config.js | 5 | ||||
-rw-r--r-- | deps/npm/test/tap/uninstall-package.js | 35 | ||||
-rw-r--r-- | deps/npm/test/tap/uninstall-package/package.json | 6 |
15 files changed, 113 insertions, 47 deletions
diff --git a/deps/npm/test/common-tap.js b/deps/npm/test/common-tap.js new file mode 100644 index 0000000000..a13a0a7cde --- /dev/null +++ b/deps/npm/test/common-tap.js @@ -0,0 +1,2 @@ +var port = exports.port = 1337 +exports.registry = "http://localhost:" + port diff --git a/deps/npm/test/tap/ignore-shrinkwrap.js b/deps/npm/test/tap/ignore-shrinkwrap.js index c76954694b..29dc9afeea 100644 --- a/deps/npm/test/tap/ignore-shrinkwrap.js +++ b/deps/npm/test/tap/ignore-shrinkwrap.js @@ -1,3 +1,4 @@ +var common = require("../common-tap.js") var test = require("tap").test var npm = require("../../") var pkg = './ignore-shrinkwrap' @@ -16,8 +17,8 @@ var customMocks = { } } -test("ignore-shrinkwrap: using the option", function(t) { - mr({port: 1337, mocks: customMocks}, function (s) { +test("ignore-shrinkwrap: using the option", function (t) { + mr({port: common.port, mocks: customMocks}, function (s) { s._server.on("request", function (req, res) { switch (req.url) { case "/shrinkwrap.js": @@ -35,8 +36,8 @@ test("ignore-shrinkwrap: using the option", function(t) { }) }) -test("ignore-shrinkwrap: NOT using the option", function(t) { - mr({port: 1337, mocks: customMocks}, function (s) { +test("ignore-shrinkwrap: NOT using the option", function (t) { + mr({port: common.port, mocks: customMocks}, function (s) { s._server.on("request", function (req, res) { switch (req.url) { case "/shrinkwrap.js": @@ -65,7 +66,7 @@ function createChild (ignoreShrinkwrap) { return spawn(node, args, { cwd: pkg, env: { - npm_config_registry: "http://localhost:1337", + npm_config_registry: common.registry, npm_config_cache_lock_stale: 1000, npm_config_cache_lock_wait: 1000, HOME: process.env.HOME, diff --git a/deps/npm/test/tap/lifecycle-signal.js b/deps/npm/test/tap/lifecycle-signal.js new file mode 100644 index 0000000000..f7318c7d6f --- /dev/null +++ b/deps/npm/test/tap/lifecycle-signal.js @@ -0,0 +1,17 @@ +var test = require("tap").test +var npm = require.resolve("../../bin/npm-cli.js") +var node = process.execPath +var spawn = require("child_process").spawn +var path = require("path") +var pkg = path.resolve(__dirname, "lifecycle-signal") + +test("lifecycle signal abort", function (t) { + var child = spawn(node, [npm, "install"], { + cwd: pkg + }) + child.on("close", function (code, signal) { + t.equal(code, null) + t.equal(signal, "SIGSEGV") + t.end() + }) +}) diff --git a/deps/npm/test/tap/lifecycle-signal/package.json b/deps/npm/test/tap/lifecycle-signal/package.json new file mode 100644 index 0000000000..6b7f2f1c5c --- /dev/null +++ b/deps/npm/test/tap/lifecycle-signal/package.json @@ -0,0 +1,3 @@ +{ "name":"lifecycle-signal", + "version":"1.2.5", + "scripts": {"preinstall":"node -e 'process.kill(process.pid,\"SIGSEGV\")'"}} diff --git a/deps/npm/test/tap/noargs-install-config-save.js b/deps/npm/test/tap/noargs-install-config-save.js index b7bf3a35f9..ceff77bd4d 100644 --- a/deps/npm/test/tap/noargs-install-config-save.js +++ b/deps/npm/test/tap/noargs-install-config-save.js @@ -1,3 +1,4 @@ +var common = require("../common-tap.js") var test = require("tap").test var npm = require.resolve("../../bin/npm-cli.js") var osenv = require("osenv") @@ -18,6 +19,7 @@ pkg += path.sep + "noargs-install-config-save" function writePackageJson() { rimraf.sync(pkg) mkdirp.sync(pkg) + mkdirp.sync(pkg + "/cache") fs.writeFileSync(pkg + "/package.json", JSON.stringify({ "author": "Rocko Artischocko", @@ -32,7 +34,8 @@ function writePackageJson() { function createChild (args) { var env = { npm_config_save: true, - npm_config_registry: "http://localhost:1337", + npm_config_registry: common.registry, + npm_config_cache: pkg + "/cache", HOME: process.env.HOME, Path: process.env.PATH, PATH: process.env.PATH @@ -43,7 +46,6 @@ function createChild (args) { return spawn(node, args, { cwd: pkg, - stdio: "inherit", env: env }) } @@ -52,7 +54,7 @@ test("does not update the package.json with empty arguments", function (t) { writePackageJson() t.plan(1) - mr(1337, function (s) { + mr(common.port, function (s) { var child = createChild([npm, "install"]) child.on("close", function (m) { var text = JSON.stringify(fs.readFileSync(pkg + "/package.json", "utf8")) @@ -67,7 +69,7 @@ test("updates the package.json (adds dependencies) with an argument", function ( writePackageJson() t.plan(1) - mr(1337, function (s) { + mr(common.port, function (s) { var child = createChild([npm, "install", "underscore"]) child.on("close", function (m) { var text = JSON.stringify(fs.readFileSync(pkg + "/package.json", "utf8")) @@ -76,4 +78,9 @@ test("updates the package.json (adds dependencies) with an argument", function ( t.end() }) }) -})
\ No newline at end of file +}) + +test("cleanup", function (t) { + rimraf.sync(pkg + "/cache") + t.end() +}) diff --git a/deps/npm/test/tap/outdated-include-devdependencies.js b/deps/npm/test/tap/outdated-include-devdependencies.js index dbc204d743..b78948a24e 100644 --- a/deps/npm/test/tap/outdated-include-devdependencies.js +++ b/deps/npm/test/tap/outdated-include-devdependencies.js @@ -1,18 +1,18 @@ +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 port = 1331 -var address = "http://localhost:" + port var pkg = __dirname + '/outdated-include-devdependencies' - +mkdirp.sync(pkg + "/cache") test("includes devDependencies in outdated", function (t) { process.chdir(pkg) - mr(port, function (s) { - npm.load({registry: address}, function () { + mr(common.port, function (s) { + npm.load({cache: pkg + "/cache", registry: common.registry}, function () { npm.outdated(function (er, d) { t.equal("1.5.1", d[0][3]) s.close() @@ -20,4 +20,9 @@ test("includes devDependencies in outdated", function (t) { }) }) }) -})
\ No newline at end of file +}) + +test("cleanup", function (t) { + rimraf.sync(pkg + "/cache") + t.end() +}) diff --git a/deps/npm/test/tap/outdated-new-versions.js b/deps/npm/test/tap/outdated-new-versions.js index b3018230f5..1779736177 100644 --- a/deps/npm/test/tap/outdated-new-versions.js +++ b/deps/npm/test/tap/outdated-new-versions.js @@ -1,14 +1,11 @@ +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 port = 1331 -var address = "http://localhost:" + port var pkg = __dirname + "/outdated-new-versions" mkdirp.sync(pkg + "/cache") @@ -16,8 +13,9 @@ mkdirp.sync(pkg + "/cache") test("dicovers new versions in outdated", function (t) { process.chdir(pkg) t.plan(2) - mr(port, function (s) { - npm.load({cache: pkg + "/cache", registry: address}, function () { + + mr(common.port, function (s) { + npm.load({cache: pkg + "/cache", registry: common.registry}, function () { npm.outdated(function (er, d) { for (var i = 0; i < d.length; i++) { if (d[i][1] === "underscore") diff --git a/deps/npm/test/tap/outdated.js b/deps/npm/test/tap/outdated.js index 67af4fcccd..3a9951b3c4 100644 --- a/deps/npm/test/tap/outdated.js +++ b/deps/npm/test/tap/outdated.js @@ -1,3 +1,4 @@ +var common = require("../common-tap.js") var fs = require("fs") var test = require("tap").test var rimraf = require("rimraf") @@ -5,16 +6,18 @@ var npm = require("../../") var mr = require("npm-registry-mock") // config -var port = 1331 -var address = "http://localhost:" + port var pkg = __dirname + '/outdated' test("it should not throw", function (t) { - rimraf.sync(pkg + "/node_modules") + cleanup() process.chdir(pkg) - mr(port, function (s) { - npm.load({registry: address}, function () { + mr(common.port, function (s) { + npm.load({ + cache: pkg + "/cache", + loglevel: 'silent', + registry: common.registry } + , function () { npm.install(".", function (err) { npm.outdated(function (er, d) { console.log(d) @@ -27,6 +30,11 @@ test("it should not throw", function (t) { }) test("cleanup", function (t) { - rimraf.sync(pkg + "/node_modules") + cleanup() t.end() -})
\ No newline at end of file +}) + +function cleanup () { + rimraf.sync(pkg + "/node_modules") + rimraf.sync(pkg + "/cache") +} diff --git a/deps/npm/test/tap/outdated/README.md b/deps/npm/test/tap/outdated/README.md new file mode 100644 index 0000000000..aca67ff17d --- /dev/null +++ b/deps/npm/test/tap/outdated/README.md @@ -0,0 +1 @@ +# just a test diff --git a/deps/npm/test/tap/outdated/package.json b/deps/npm/test/tap/outdated/package.json index 3a76d534fc..821a94b883 100644 --- a/deps/npm/test/tap/outdated/package.json +++ b/deps/npm/test/tap/outdated/package.json @@ -1,8 +1,10 @@ { "name": "bla", + "description": "fixture", "version": "0.0.1", "main": "index.js", "dependencies": { "underscore": "1.3.1" - } + }, + "repository": "git://github.com/robertkowalski/bogusfixture" } diff --git a/deps/npm/test/tap/peer-deps-invalid.js b/deps/npm/test/tap/peer-deps-invalid.js index 3b823db01c..50c961e7b9 100644 --- a/deps/npm/test/tap/peer-deps-invalid.js +++ b/deps/npm/test/tap/peer-deps-invalid.js @@ -1,3 +1,4 @@ +var common = require('../common-tap.js') var fs = require("fs") var test = require("tap").test var rimraf = require("rimraf") @@ -42,7 +43,7 @@ test("setup", function(t) { return res.end(failFile) } }) - server.listen(1337, function() { + server.listen(common.port, function() { t.pass("listening") t.end() }) diff --git a/deps/npm/test/tap/peer-deps-without-package-json.js b/deps/npm/test/tap/peer-deps-without-package-json.js index 8c5b5483a2..9f987c5ee5 100644 --- a/deps/npm/test/tap/peer-deps-without-package-json.js +++ b/deps/npm/test/tap/peer-deps-without-package-json.js @@ -1,3 +1,4 @@ +var common = require('../common-tap.js') var fs = require("fs") var test = require("tap").test var rimraf = require("rimraf") @@ -25,7 +26,7 @@ test("setup", function(t) { s.setHeader('content-type', 'application/javascript') s.end(js) }) - server.listen(1337, function() { + server.listen(common.port, function () { t.pass('listening') t.end() }) @@ -38,7 +39,7 @@ test("installing a peerDependencies-using package without a package.json present process.chdir(__dirname + "/peer-deps-without-package-json") npm.load(function () { - npm.install('http://localhost:1337/', function (err) { + npm.install(common.registry, function (err) { if (err) { t.fail(err) } else { diff --git a/deps/npm/test/tap/publish-config.js b/deps/npm/test/tap/publish-config.js index af55a286dd..2a6f9523c4 100644 --- a/deps/npm/test/tap/publish-config.js +++ b/deps/npm/test/tap/publish-config.js @@ -1,3 +1,4 @@ +var common = require('../common-tap.js') var test = require('tap').test var fs = require('fs') var osenv = require('osenv') @@ -9,7 +10,7 @@ require('mkdirp').sync(pkg) fs.writeFileSync(pkg + '/package.json', JSON.stringify({ name: 'npm-test-publish-config', version: '1.2.3', - publishConfig: { registry: 'http://localhost:13370' } + publishConfig: { registry: common.registry } }), 'utf8') var spawn = require('child_process').spawn @@ -25,7 +26,7 @@ test(function (t) { res.statusCode = 500 res.end('{"error":"sshhh. naptime nao. \\^O^/ <(YAWWWWN!)"}') child.kill() - }).listen(13370, function () { + }).listen(common.port, function () { t.pass('server is listening') // don't much care about listening to the child's results diff --git a/deps/npm/test/tap/uninstall-package.js b/deps/npm/test/tap/uninstall-package.js index d6bfa0d8fc..0682701250 100644 --- a/deps/npm/test/tap/uninstall-package.js +++ b/deps/npm/test/tap/uninstall-package.js @@ -1,24 +1,41 @@ var test = require("tap").test , npm = require("../../") + , rimraf = require("rimraf") + , mr = require("npm-registry-mock") + , common = require("../common-tap.js") + , pkg = __dirname + "/uninstall-package" test("returns a list of removed items", function (t) { t.plan(1) - - setup(function () { - npm.install(".", function (err) { - if (err) return t.fail(err) - npm.uninstall("once", "ini", "lala", function (err, d) { + mr(common.port, function (s) { + setup(function () { + npm.install(".", function (err) { if (err) return t.fail(err) - t.same(d.sort(), ["once", "ini"].sort()) - t.end() + npm.uninstall("underscore", "request", "lala", function (err, d) { + if (err) return t.fail(err) + t.same(d.sort(), ["underscore", "request"].sort()) + s.close() + t.end() + }) }) }) }) }) +test("cleanup", function (t) { + cleanup() + t.end() +}) + function setup (cb) { - process.chdir(__dirname + "/uninstall-package") - npm.load(function () { + cleanup() + process.chdir(pkg) + npm.load({cache: pkg + "/cache", registry: common.registry}, function () { cb() }) } + +function cleanup () { + rimraf.sync(pkg + "/node_modules") + rimraf.sync(pkg + "/cache") +} diff --git a/deps/npm/test/tap/uninstall-package/package.json b/deps/npm/test/tap/uninstall-package/package.json index e445a1c6d4..49ce42a89d 100644 --- a/deps/npm/test/tap/uninstall-package/package.json +++ b/deps/npm/test/tap/uninstall-package/package.json @@ -1,9 +1,11 @@ { "name": "beep", "version": "0.0.0", + "author": "Rockbert", + "description": "i am a fixture", "main": "index.js", "dependencies": { - "once": "*", - "ini": "*" + "underscore": "~1.3.1", + "request": "~0.9.0" } } |