Skip to content

Commit

Permalink
test: use tmp directory in chdir test
Browse files Browse the repository at this point in the history
This patch

 - makes chdir test to use the tmp directory
 - moves the test to parallel
 - renames the file to test-process-chdir as chdir is in process module

PR-URL: #2589
Reviewed-By: Brendan Ashworth <[email protected]>
Reviewed-By: Rich Trott <[email protected]>
  • Loading branch information
thefourtheye committed Sep 16, 2015
1 parent 43cb1dd commit 9aa6a43
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 38 deletions.
28 changes: 28 additions & 0 deletions test/parallel/test-process-chdir.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
'use strict';

const common = require('../common');
const assert = require('assert');
const fs = require('fs');
const path = require('path');

assert.notStrictEqual(process.cwd(), __dirname);
process.chdir(__dirname);
assert.strictEqual(process.cwd(), __dirname);

const dir = path.resolve(common.tmpDir,
'weird \uc3a4\uc3ab\uc3af characters \u00e1\u00e2\u00e3');

// Make sure that the tmp directory is clean
common.refreshTmpDir();

fs.mkdirSync(dir);
process.chdir(dir);
assert.strictEqual(process.cwd(), dir);

process.chdir('..');
assert.strictEqual(process.cwd(), path.resolve(common.tmpDir));

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.');
38 changes: 0 additions & 38 deletions test/sequential/test-chdir.js

This file was deleted.

0 comments on commit 9aa6a43

Please sign in to comment.