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 a2efe09
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 7 deletions.
2 changes: 1 addition & 1 deletion lib/tmp.js
Expand Up @@ -597,7 +597,7 @@ function _safely_install_listener() {
// it'd never had won if it wasn't a major PITA
// with node v8.x and win 10 this is no longer an issue
if (process.platform == 'win32') {
var rl = require('readline').createInterface({
const rl = require('readline').createInterface({
input: process.stdin,
output: process.stdout
});
Expand Down
11 changes: 6 additions & 5 deletions test/issue121-test.js
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
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 a2efe09

Please sign in to comment.