Skip to content

Commit ddf2583

Browse files
silverwindjasnell
authored andcommitted
test: use normalize() for unicode paths
OS X 10.11 changed the unicode normalization form of certain code points returned by system calls like getcwd() from NFC to NFD which made results in this test failing. The consensus of #2165 is to delegate the task of unicode normalization to the user, and work will continue to document how to handle unicode in a form-sensitive file system. PR-URL: #3007 Fixes: #2165 Reviewed-By: Johan Bergström <[email protected]> Reviewed-By: Jeremiah Senkpiel <[email protected]> Reviewed-By: Sakthipriyan Vairamani <[email protected]>
1 parent 63644dd commit ddf2583

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

test/parallel/test-process-chdir.js

+12-4
Original file line numberDiff line numberDiff line change
@@ -9,18 +9,26 @@ assert.notStrictEqual(process.cwd(), __dirname);
99
process.chdir(__dirname);
1010
assert.strictEqual(process.cwd(), __dirname);
1111

12-
const dir = path.resolve(common.tmpDir,
13-
'weird \uc3a4\uc3ab\uc3af characters \u00e1\u00e2\u00e3');
12+
let dirName;
13+
if (process.versions.icu) {
14+
// ICU is available, use characters that could possibly be decomposed
15+
dirName = 'weird \uc3a4\uc3ab\uc3af characters \u00e1\u00e2\u00e3';
16+
} else {
17+
// ICU is unavailable, use characters that can't be decomposed
18+
dirName = 'weird \ud83d\udc04 characters \ud83d\udc05';
19+
}
20+
const dir = path.resolve(common.tmpDir, dirName);
1421

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

1825
fs.mkdirSync(dir);
1926
process.chdir(dir);
20-
assert.strictEqual(process.cwd(), dir);
27+
assert.strictEqual(process.cwd().normalize(), dir.normalize());
2128

2229
process.chdir('..');
23-
assert.strictEqual(process.cwd(), path.resolve(common.tmpDir));
30+
assert.strictEqual(process.cwd().normalize(),
31+
path.resolve(common.tmpDir).normalize());
2432

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

0 commit comments

Comments
 (0)