Skip to content

Commit 648c003

Browse files
thefourtheyeFishrock123
authored andcommitted
test: use tmp directory in chdir test
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: nodejs#2589 Reviewed-By: Brendan Ashworth <[email protected]> Reviewed-By: Rich Trott <[email protected]>
1 parent bf42cc8 commit 648c003

File tree

2 files changed

+28
-38
lines changed

2 files changed

+28
-38
lines changed

test/parallel/test-process-chdir.js

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
'use strict';
2+
3+
const common = require('../common');
4+
const assert = require('assert');
5+
const fs = require('fs');
6+
const path = require('path');
7+
8+
assert.notStrictEqual(process.cwd(), __dirname);
9+
process.chdir(__dirname);
10+
assert.strictEqual(process.cwd(), __dirname);
11+
12+
const dir = path.resolve(common.tmpDir,
13+
'weird \uc3a4\uc3ab\uc3af characters \u00e1\u00e2\u00e3');
14+
15+
// Make sure that the tmp directory is clean
16+
common.refreshTmpDir();
17+
18+
fs.mkdirSync(dir);
19+
process.chdir(dir);
20+
assert.strictEqual(process.cwd(), dir);
21+
22+
process.chdir('..');
23+
assert.strictEqual(process.cwd(), path.resolve(common.tmpDir));
24+
25+
assert.throws(function() { process.chdir({}); }, TypeError, 'Bad argument.');
26+
assert.throws(function() { process.chdir(); }, TypeError, 'Bad argument.');
27+
assert.throws(function() { process.chdir('x', 'y'); },
28+
TypeError, 'Bad argument.');

test/sequential/test-chdir.js

-38
This file was deleted.

0 commit comments

Comments
 (0)