-
Notifications
You must be signed in to change notification settings - Fork 93
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
17 changed files
with
253 additions
and
56 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -23,6 +23,7 @@ module.exports = { | |
"semi": [ | ||
"error", | ||
"always" | ||
] | ||
], | ||
"no-extra-boolean-cast": 0 | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,7 +4,6 @@ node_js: | |
- "10" | ||
- "9" | ||
- "8" | ||
- "6" | ||
sudo: false | ||
cache: | ||
directories: | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
/* eslint-disable no-octal */ | ||
// vim: expandtab:ts=2:sw=2 | ||
|
||
const | ||
assertions = require('./assertions'), | ||
childProcess = require('./child-process').childProcess, | ||
os = require('os'), | ||
rimraf = require('rimraf'), | ||
testCases = [ | ||
{ signal: 'SIGINT', expectExists: false }, | ||
{ signal: 'SIGTERM', expectExists: true } | ||
]; | ||
|
||
// skip tests on win32 | ||
const isWindows = os.platform() === 'win32'; | ||
const tfunc = isWindows ? xit : it; | ||
|
||
describe('tmp', function () { | ||
describe('issue121 - clean up on terminating signals', function () { | ||
for (let tc of testCases) { | ||
tfunc('for signal ' + tc.signal, function (done) { | ||
// increase timeout so that the child process may fail | ||
this.timeout(20000); | ||
issue121Tests(tc.signal, tc.expectExists)(done); | ||
}); | ||
} | ||
}); | ||
}); | ||
|
||
function issue121Tests(signal, expectExists) { | ||
return function (done) { | ||
childProcess(this, 'issue121.json', function (err, stderr, stdout) { | ||
if (err) return done(err); | ||
else if (stderr) return done(new Error(stderr)); | ||
|
||
try { | ||
if (expectExists) { | ||
assertions.assertExists(stdout); | ||
} | ||
else { | ||
assertions.assertDoesNotExist(stdout); | ||
} | ||
done(); | ||
} catch (err) { | ||
done(err); | ||
} finally { | ||
// cleanup | ||
if (expectExists) { | ||
rimraf.sync(stdout); | ||
} | ||
} | ||
}, signal); | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
/* eslint-disable no-octal */ | ||
// vim: expandtab:ts=2:sw=2 | ||
|
||
var | ||
assert = require('assert'), | ||
assertions = require('./assertions'), | ||
childProcess = require('./child-process').childProcess; | ||
|
||
describe('tmp', function () { | ||
describe('issue129: safely install sigint listeners', function () { | ||
it('when simulating sandboxed behavior', function (done) { | ||
childProcess(this, 'issue129-sigint.json', function (err, stderr, stdout) { | ||
if (err) return done(err); | ||
if (!stdout && !stderr) return done(new Error('stderr or stdout expected')); | ||
if (stderr) { | ||
try { | ||
assertions.assertDoesNotStartWith(stderr, 'EEXISTS:MULTIPLE'); | ||
assertions.assertDoesNotStartWith(stderr, 'ENOAVAIL:EXISTING'); | ||
} catch (err) { | ||
return done(err); | ||
} | ||
} | ||
if (stdout) { | ||
try { | ||
assert.equal(stdout, 'EOK', 'existing listeners should have been removed and called'); | ||
} catch (err) { | ||
return done(err); | ||
} | ||
} | ||
done(); | ||
}); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
/* eslint-disable no-octal */ | ||
// vim: expandtab:ts=2:sw=2 | ||
|
||
const | ||
tmp = require('../../lib/tmp'); | ||
|
||
// https://github.com/raszi/node-tmp/issues/121 | ||
module.exports = function () { | ||
|
||
tmp.setGracefulCleanup(); | ||
|
||
const result = tmp.dirSync({ unsafeCleanup: true }); | ||
|
||
this.out(result.name, function () { }); | ||
|
||
setTimeout(function () { | ||
throw new Error('ran into timeout'); | ||
}, 10000); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
{ | ||
"graceful": true, | ||
"tc": "issue121" | ||
} |
Oops, something went wrong.