diff options
author | isaacs <i@izs.me> | 2014-08-26 22:56:37 +0400 |
---|---|---|
committer | isaacs <i@izs.me> | 2014-08-26 22:56:48 +0400 |
commit | 5af493efa8a463cd1acc4a9a394699e2c0793b9c (patch) | |
tree | b7c2fb4e9ca1c5c5c4d28eb662005904e80ff15a /test | |
parent | 94cfeb381451c511501b9cc395b6c754c3178371 (diff) |
ensure lifecycle spawn errors caught properly
Possibly related to #5987 #6029
Not sure if this is a new thing in a Windows 8 system update, or a new
Node bug, but the contract whereby ENOENT spawn errors trigger a
simulated failure-exit in Node (and thus `exit` and `close` events)
seems to have changed recently.
Handle this by catching error events that are fired on the child
process, so that at least we can print out the script and package that
we were TRYING to execute, and debug it at all.
Diffstat (limited to 'test')
-rw-r--r-- | test/tap/spawn-enoent.js | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/test/tap/spawn-enoent.js b/test/tap/spawn-enoent.js new file mode 100644 index 000000000..7ea9dab56 --- /dev/null +++ b/test/tap/spawn-enoent.js @@ -0,0 +1,40 @@ +var path = require("path") +var test = require("tap").test +var fs = require("fs") +var rimraf = require("rimraf") +var mkdirp = require("mkdirp") +var common = require("../common-tap.js") + +var pkg = path.resolve(__dirname, "spawn-enoent") +var pj = JSON.stringify({ + name:"x", + version: "1.2.3", + scripts: { start: "wharble-garble-blorst" } +}, null, 2) + "\n" + + +test("setup", function (t) { + rimraf.sync(pkg) + mkdirp.sync(pkg) + fs.writeFileSync(pkg + "/package.json", pj) + t.end() +}) + +test("enoent script", function (t) { + common.npm(["start"], { + cwd: pkg, + env: { + PATH: process.env.PATH, + Path: process.env.Path, + npm_config_loglevel: "warn" + } + }, function (er, code, sout, serr) { + t.similar(serr, /npm ERR! Failed at the x@1\.2\.3 start script\./) + t.end() + }) +}) + +test("clean", function (t) { + rimraf.sync(pkg) + t.end() +}) |