Skip to content

Commit

Permalink
test: skip test-fs-readdir-ucs2 if no support
Browse files Browse the repository at this point in the history
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 <cjihrig@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Refael Ackermann <refack@gmail.com>
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
  • Loading branch information
Trott authored and MylesBorins committed Sep 5, 2017
1 parent 509205f commit 46e4a02
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 9 deletions.
1 change: 0 additions & 1 deletion test/parallel/parallel.status
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ test-fs-read-buffer-tostring-fail : PASS,FLAKY
[$system==macos]

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

[$system==solaris] # Also applies to SmartOS
Expand Down
18 changes: 10 additions & 8 deletions test/parallel/test-fs-readdir-ucs2.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,18 @@ const root = Buffer.from(`${common.tmpDir}${path.sep}`);
const filebuff = Buffer.from(filename, 'ucs2');
const fullpath = Buffer.concat([root, filebuff]);

fs.closeSync(fs.openSync(fullpath, 'w+'));
try {
fs.closeSync(fs.openSync(fullpath, 'w+'));
} catch (e) {
if (e.code === 'EINVAL')
common.skip('test requires filesystem that supports UCS2');
throw e;
}

fs.readdir(common.tmpDir, 'ucs2', (err, list) => {
if (err) throw err;
fs.readdir(common.tmpDir, 'ucs2', common.mustCall((err, list) => {
assert.ifError(err);
assert.strictEqual(1, list.length);
const fn = list[0];
assert.deepStrictEqual(filebuff, Buffer.from(fn, 'ucs2'));
assert.strictEqual(fn, filename);
});

process.on('exit', () => {
fs.unlinkSync(fullpath);
});
}));

0 comments on commit 46e4a02

Please sign in to comment.