Skip to content

Commit d4ceb16

Browse files
committed
test: properly clean up temp directory
A persistent failure on OS X 10.11 uncovered a inproperly cleaned up temp directory in this test. This changes the mkdirSync call to clean up properly in case it throws. PR-URL: #2164 Reviewed-By: Evan Lucas <[email protected]>
1 parent 2ba8460 commit d4ceb16

File tree

1 file changed

+15
-2
lines changed

1 file changed

+15
-2
lines changed

test/sequential/test-chdir.js

+15-2
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,28 @@ assert.equal(true, process.cwd() === __dirname);
1111

1212
var dir = path.resolve(common.fixturesDir,
1313
'weird \uc3a4\uc3ab\uc3af characters \u00e1\u00e2\u00e3');
14-
fs.mkdirSync(dir);
14+
15+
try {
16+
fs.mkdirSync(dir);
17+
} catch (e) {
18+
if (e.code !== 'EEXIST') {
19+
cleanup();
20+
throw e;
21+
}
22+
}
23+
1524
process.chdir(dir);
1625
assert(process.cwd() == dir);
1726

1827
process.chdir('..');
1928
assert(process.cwd() == path.resolve(common.fixturesDir));
20-
fs.rmdirSync(dir);
29+
cleanup();
2130

2231
assert.throws(function() { process.chdir({}); }, TypeError, 'Bad argument.');
2332
assert.throws(function() { process.chdir(); }, TypeError, 'Bad argument.');
2433
assert.throws(function() { process.chdir('x', 'y'); },
2534
TypeError, 'Bad argument.');
35+
36+
function cleanup() {
37+
fs.rmdirSync(dir);
38+
}

0 commit comments

Comments
 (0)