Skip to content

Commit

Permalink
test: properly clean up temp directory
Browse files Browse the repository at this point in the history
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 <evanlucas@me.com>
  • Loading branch information
silverwind committed Jul 11, 2015
1 parent 2ba8460 commit d4ceb16
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions test/sequential/test-chdir.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,28 @@ assert.equal(true, process.cwd() === __dirname);

var dir = path.resolve(common.fixturesDir,
'weird \uc3a4\uc3ab\uc3af characters \u00e1\u00e2\u00e3');
fs.mkdirSync(dir);

try {
fs.mkdirSync(dir);
} catch (e) {
if (e.code !== 'EEXIST') {
cleanup();
throw e;
}
}

process.chdir(dir);
assert(process.cwd() == dir);

process.chdir('..');
assert(process.cwd() == path.resolve(common.fixturesDir));
fs.rmdirSync(dir);
cleanup();

assert.throws(function() { process.chdir({}); }, TypeError, 'Bad argument.');
assert.throws(function() { process.chdir(); }, TypeError, 'Bad argument.');
assert.throws(function() { process.chdir('x', 'y'); },
TypeError, 'Bad argument.');

function cleanup() {
fs.rmdirSync(dir);
}

0 comments on commit d4ceb16

Please sign in to comment.