Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/npm/cli.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorChristopher Hiller <chiller@badwing.com>2014-08-03 13:34:16 +0400
committerForrest L Norvell <forrest@npmjs.com>2014-09-21 10:28:59 +0400
commita623da01bea1b2d3f3a18b9117cfd2d8e3cbdd77 (patch)
tree08115f0ea972d4a055e84bb7ccdeaf80fc417848 /test
parentbfbb1a40b81955d1bc3685cda0e8c609c66a72a4 (diff)
fixes #5867, replaces #5790: no git hooks
Specify dummy template dir when cloning to prevent copying hooks.
Diffstat (limited to 'test')
-rw-r--r--test/tap/git-cache-no-hooks.js63
-rw-r--r--test/tap/git-cache-permissions.js80
2 files changed, 63 insertions, 80 deletions
diff --git a/test/tap/git-cache-no-hooks.js b/test/tap/git-cache-no-hooks.js
new file mode 100644
index 000000000..2ae3144d6
--- /dev/null
+++ b/test/tap/git-cache-no-hooks.js
@@ -0,0 +1,63 @@
+var test = require("tap").test
+ , fs = require("fs")
+ , path = require("path")
+ , rimraf = require("rimraf")
+ , mkdirp = require("mkdirp")
+ , spawn = require("child_process").spawn
+ , npmCli = require.resolve("../../bin/npm-cli.js")
+ , node = process.execPath
+ , pkg = path.resolve(__dirname, "git-cache-no-hooks")
+ , tmp = path.join(pkg, "tmp")
+ , cache = path.join(pkg, "cache")
+
+
+test("setup", function (t) {
+ rimraf.sync(pkg)
+ mkdirp.sync(pkg)
+ mkdirp.sync(cache)
+ mkdirp.sync(tmp)
+ mkdirp.sync(path.resolve(pkg, "node_modules"))
+ t.end()
+})
+
+test("git-cache-no-hooks: install a git dependency", function (t) {
+
+ // disable git integration tests on Travis.
+ if (process.env.TRAVIS) return t.end()
+
+ var command = [ npmCli
+ , "install"
+ , "git://github.com/nigelzor/npm-4503-a.git"
+ ]
+ var child = spawn(node, command, {
+ cwd: pkg,
+ env: {
+ "npm_config_cache" : cache,
+ "npm_config_tmp" : tmp,
+ "npm_config_prefix" : pkg,
+ "npm_config_global" : "false",
+ "npm_config_umask" : "00",
+ HOME : process.env.HOME,
+ Path : process.env.PATH,
+ PATH : process.env.PATH
+ },
+ stdio: "inherit"
+ })
+
+ child.on("close", function (code) {
+ t.equal(code, 0, "npm install should succeed")
+
+ // verify permissions on git hooks
+ var repoDir = "git-github-com-nigelzor-npm-4503-a-git-40c5cb24"
+ var hooksPath = path.join(cache, "_git-remotes", repoDir, "hooks")
+ fs.readdir(hooksPath, function (err) {
+ t.equal(err && err.code, "ENOENT", "hooks are not brought along with repo")
+ t.end()
+ })
+ })
+})
+
+test("cleanup", function(t) {
+ rimraf.sync(pkg)
+ t.end()
+})
diff --git a/test/tap/git-cache-permissions.js b/test/tap/git-cache-permissions.js
deleted file mode 100644
index 27905fba5..000000000
--- a/test/tap/git-cache-permissions.js
+++ /dev/null
@@ -1,80 +0,0 @@
-var test = require("tap").test
- , fs = require("fs")
- , path = require("path")
- , rimraf = require("rimraf")
- , mkdirp = require("mkdirp")
- , spawn = require("child_process").spawn
- , npm = require("../../lib/npm")
- , npmCli = require.resolve("../../bin/npm-cli.js")
- , node = process.execPath
- , pkg = path.resolve(__dirname, "git-cache-permissions")
- , tmp = path.join(pkg, "tmp")
- , cache = path.join(pkg, "cache")
-
-
-test("setup", function (t) {
- rimraf.sync(pkg)
- mkdirp.sync(pkg)
- mkdirp.sync(cache)
- mkdirp.sync(tmp)
- mkdirp.sync(path.resolve(pkg, 'node_modules'))
- t.end()
-})
-
-test("git-cache-permissions: install a git dependency", function (t) {
-
- // disable git integration tests on Travis.
- if (process.env.TRAVIS) return t.end()
-
- var command = [ npmCli
- , "install"
- , "git://github.com/nigelzor/npm-4503-a.git"
- ]
- var child = spawn(node, command, {
- cwd: pkg,
- env: {
- npm_config_cache: cache,
- npm_config_tmp: tmp,
- npm_config_prefix: pkg,
- npm_config_global: "false",
- npm_config_umask: "00",
- HOME: process.env.HOME,
- Path: process.env.PATH,
- PATH: process.env.PATH
- },
- stdio: "inherit"
- })
-
- child.on("close", function (code) {
- t.equal(code, 0, "npm install should succeed")
-
- // verify permissions on git hooks
- var repoDir = "git-github-com-nigelzor-npm-4503-a-git-40c5cb24"
- var hooksPath = path.join(cache, "_git-remotes", repoDir, "hooks")
- fs.readdir(hooksPath, function (err, files) {
- if (err) {
- t.ok(false, "error reading hooks: " + err)
- t.end()
- }
-
- files.forEach(function (file) {
- var stats = fs.statSync(path.join(hooksPath, file))
- var message = "hook [" + file + "] should have correct permissions"
-
- // Possible error conditions and the resulting file modes on hooks
- // npm.modes.file is used directly -> "100666"
- // permissions are left untouched -> "100755"
- // we do not want permissions left untouched because of
- // https://github.com/npm/npm/issues/3117
- t.equal(stats.mode.toString(8), "100777", message)
- })
-
- t.end()
- })
- })
-})
-
-test('cleanup', function(t) {
- rimraf.sync(pkg)
- t.end()
-})