Skip to content

Commit

Permalink
fix test for #121
Browse files Browse the repository at this point in the history
  • Loading branch information
silkentrance committed Sep 12, 2018
1 parent 0d0f3a7 commit 2f0bf89
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 6 deletions.
11 changes: 6 additions & 5 deletions test/issue121-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,25 +2,26 @@
// vim: expandtab:ts=2:sw=2

const
assert = require('assert'),
assertions = require('./assertions'),
childProcess = require('./child-process').childProcess,
signals = ['SIGINT', 'SIGTERM'];

describe('tmp', function () {
describe('issue121 - clean up on terminating signals', function () {
for (var i=0; i < signals.length; i++) {
issue121Tests(signals[i]);
for (var i = 0; i < signals.length; i++) {
it('for signal ' + signals[i], function (done) {
issue121Tests(signals[i])(done);
});
}
});
});

function issue121Tests(signal) {
return function (done) {
childProcess('issue121.json', function (err, stderr, stdout) {
childProcess(this, 'issue121.json', function (err, stderr, stdout) {
if (err) return done(err);
else if (stderr) return done(new Error(stderr));
else assertions.assertDoesNotExist(stdout);
assertions.assertDoesNotExist(stdout);
done();
}, true);
};
Expand Down
8 changes: 7 additions & 1 deletion test/outband/issue121.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,13 @@ tmp.setGracefulCleanup();

// https://github.com/raszi/node-tmp/issues/121
module.exports = function (signal) {
fixture.apply(this, [tmp.dirSync({ unsafeCleanup: true }), tmp]);
try {
fixture.apply(this, [tmp.dirSync({ unsafeCleanup: true }), tmp]);
}
catch (ex) {
console.err(ex);
throw ex;
}

// make sure that the process keeps running
setTimeout(function () {}, 1000000);
Expand Down

0 comments on commit 2f0bf89

Please sign in to comment.