Skip to content

Commit 46e4a02

Browse files
TrottMylesBorins
authored andcommitted
test: skip test-fs-readdir-ucs2 if no support
If the filesystem does not support UCS2, do not run the test. Backport-PR-URL: #14835 PR-URL: #14029 Fixes: #14028 Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Luigi Pinca <[email protected]> Reviewed-By: Refael Ackermann <[email protected]> Reviewed-By: Richard Lau <[email protected]>
1 parent 509205f commit 46e4a02

File tree

2 files changed

+10
-9
lines changed

2 files changed

+10
-9
lines changed

test/parallel/parallel.status

-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ test-fs-read-buffer-tostring-fail : PASS,FLAKY
1414
[$system==macos]
1515

1616
[$arch==arm || $arch==arm64]
17-
test-fs-readdir-ucs2 : PASS,FLAKY
1817
test-npm-install: PASS,FLAKY
1918

2019
[$system==solaris] # Also applies to SmartOS

test/parallel/test-fs-readdir-ucs2.js

+10-8
Original file line numberDiff line numberDiff line change
@@ -16,16 +16,18 @@ const root = Buffer.from(`${common.tmpDir}${path.sep}`);
1616
const filebuff = Buffer.from(filename, 'ucs2');
1717
const fullpath = Buffer.concat([root, filebuff]);
1818

19-
fs.closeSync(fs.openSync(fullpath, 'w+'));
19+
try {
20+
fs.closeSync(fs.openSync(fullpath, 'w+'));
21+
} catch (e) {
22+
if (e.code === 'EINVAL')
23+
common.skip('test requires filesystem that supports UCS2');
24+
throw e;
25+
}
2026

21-
fs.readdir(common.tmpDir, 'ucs2', (err, list) => {
22-
if (err) throw err;
27+
fs.readdir(common.tmpDir, 'ucs2', common.mustCall((err, list) => {
28+
assert.ifError(err);
2329
assert.strictEqual(1, list.length);
2430
const fn = list[0];
2531
assert.deepStrictEqual(filebuff, Buffer.from(fn, 'ucs2'));
2632
assert.strictEqual(fn, filename);
27-
});
28-
29-
process.on('exit', () => {
30-
fs.unlinkSync(fullpath);
31-
});
33+
}));

0 commit comments

Comments
 (0)