diff options
author | isaacs <i@izs.me> | 2014-08-14 23:17:51 +0400 |
---|---|---|
committer | isaacs <i@izs.me> | 2014-08-15 00:35:39 +0400 |
commit | 9243d207896ea307082256604c10817f7c318d68 (patch) | |
tree | 50099085877bccca676cdcd70ccbd7bc63a5cac4 /test | |
parent | 021770b9cb07451509f0a44afff6c106311d8cf6 (diff) |
test lifecycle path modification
Diffstat (limited to 'test')
-rw-r--r-- | test/tap/lifecycle-path.js | 61 | ||||
-rw-r--r-- | test/tap/lifecycle-path/package.json | 1 | ||||
-rw-r--r-- | test/tap/lifecycle-path/print-path.js | 1 |
3 files changed, 63 insertions, 0 deletions
diff --git a/test/tap/lifecycle-path.js b/test/tap/lifecycle-path.js new file mode 100644 index 000000000..34684a0c3 --- /dev/null +++ b/test/tap/lifecycle-path.js @@ -0,0 +1,61 @@ +var test = require("tap").test +var common = require("../common-tap.js") +var path = require("path") +var rimraf = require("rimraf") +var mkdirp = require("mkdirp") +var pkg = path.resolve(__dirname, "lifecycle-path") +var fs = require("fs") +var link = path.resolve(pkg, "node-bin") + +// Without the path to the shell, nothing works usually. +var PATH +if (process.platform === "win32") { + PATH = "C:\\Windows\\system32;C:\\Windows" +} else { + PATH = "/bin:/usr/bin" +} + +test("setup", function (t) { + rimraf.sync(link) + fs.symlinkSync(path.dirname(process.execPath), link, "dir") + t.end() +}) + +test("make sure the path is correct", function (t) { + common.npm(["run-script", "path"], { + cwd: pkg, + env: { + PATH: PATH, + stdio: [ 0, "pipe", 2 ] + } + }, function (er, code, stdout, stderr) { + if (er) throw er + t.equal(code, 0, "exit code") + // remove the banner, we just care about the last line + stdout = stdout.trim().split(/\r|\n/).pop() + var pathSplit = process.platform === "win32" ? ";" : ":" + var root = path.resolve(__dirname, "../..") + var actual = stdout.split(pathSplit).map(function (p) { + if (p.indexOf(root) === 0) { + p = "{{ROOT}}" + p.substr(root.length) + } + return p.replace(/\\/g, "/") + }) + + // get the ones we tacked on, then the system-specific requirements + var expect = [ + "{{ROOT}}/bin/node-gyp-bin", + "{{ROOT}}/test/tap/lifecycle-path/node_modules/.bin" + ].concat(PATH.split(pathSplit).map(function (p) { + return p.replace(/\\/g, "/") + })) + t.same(actual, expect) + t.end() + }) +}) + +test("clean", function (t) { + rimraf.sync(link) + t.end() +}) + diff --git a/test/tap/lifecycle-path/package.json b/test/tap/lifecycle-path/package.json new file mode 100644 index 000000000..42e792e46 --- /dev/null +++ b/test/tap/lifecycle-path/package.json @@ -0,0 +1 @@ +{"name":"glorb","version":"1.2.3","scripts":{"path":"./node-bin/node print-path.js"}} diff --git a/test/tap/lifecycle-path/print-path.js b/test/tap/lifecycle-path/print-path.js new file mode 100644 index 000000000..c7ad00b3d --- /dev/null +++ b/test/tap/lifecycle-path/print-path.js @@ -0,0 +1 @@ +console.log(process.env.PATH) |