Skip to content

Commit 69b1115

Browse files
committed
fix test for #121
1 parent 0c5bc5c commit 69b1115

File tree

3 files changed

+14
-7
lines changed

3 files changed

+14
-7
lines changed

lib/tmp.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -597,7 +597,7 @@ function _safely_install_listener() {
597597
// it'd never had won if it wasn't a major PITA
598598
// with node v8.x and win 10 this is no longer an issue
599599
if (process.platform == 'win32') {
600-
var rl = require('readline').createInterface({
600+
const rl = require('readline').createInterface({
601601
input: process.stdin,
602602
output: process.stdout
603603
});

test/issue121-test.js

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,25 +2,26 @@
22
// vim: expandtab:ts=2:sw=2
33

44
const
5-
assert = require('assert'),
65
assertions = require('./assertions'),
76
childProcess = require('./child-process').childProcess,
87
signals = ['SIGINT', 'SIGTERM'];
98

109
describe('tmp', function () {
1110
describe('issue121 - clean up on terminating signals', function () {
12-
for (var i=0; i < signals.length; i++) {
13-
issue121Tests(signals[i]);
11+
for (var i = 0; i < signals.length; i++) {
12+
it('for signal ' + signals[i], function (done) {
13+
issue121Tests(signals[i])(done);
14+
});
1415
}
1516
});
1617
});
1718

1819
function issue121Tests(signal) {
1920
return function (done) {
20-
childProcess('issue121.json', function (err, stderr, stdout) {
21+
childProcess(this, 'issue121.json', function (err, stderr, stdout) {
2122
if (err) return done(err);
2223
else if (stderr) return done(new Error(stderr));
23-
else assertions.assertDoesNotExist(stdout);
24+
assertions.assertDoesNotExist(stdout);
2425
done();
2526
}, true);
2627
};

test/outband/issue121.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,13 @@ tmp.setGracefulCleanup();
1111

1212
// https://github.com/raszi/node-tmp/issues/121
1313
module.exports = function (signal) {
14-
fixture.apply(this, [tmp.dirSync({ unsafeCleanup: true }), tmp]);
14+
try {
15+
fixture.apply(this, [tmp.dirSync({ unsafeCleanup: true }), tmp]);
16+
}
17+
catch (ex) {
18+
console.err(ex);
19+
throw ex;
20+
}
1521

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

0 commit comments

Comments
 (0)