Skip to content

Commit f03541e

Browse files
committed
test: skip test-fs-readdir-ucs2 if no support
If the filesystem does not support UCS2, do not run the test. Fixes: #14028
1 parent bec3877 commit f03541e

File tree

2 files changed

+11
-8
lines changed

2 files changed

+11
-8
lines changed

test/parallel/parallel.status

-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ prefix parallel
1313
[$system==macos]
1414

1515
[$arch==arm || $arch==arm64]
16-
test-fs-readdir-ucs2 : PASS,FLAKY
1716
test-npm-install: PASS,FLAKY
1817

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

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

+11-7
Original file line numberDiff line numberDiff line change
@@ -16,16 +16,20 @@ 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+
return;
25+
}
26+
throw e;
27+
}
2028

21-
fs.readdir(common.tmpDir, 'ucs2', (err, list) => {
29+
fs.readdir(common.tmpDir, 'ucs2', common.mustCall((err, list) => {
2230
assert.ifError(err);
2331
assert.strictEqual(1, list.length);
2432
const fn = list[0];
2533
assert.deepStrictEqual(filebuff, Buffer.from(fn, 'ucs2'));
2634
assert.strictEqual(fn, filename);
27-
});
28-
29-
process.on('exit', () => {
30-
fs.unlinkSync(fullpath);
31-
});
35+
}));

0 commit comments

Comments
 (0)