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.

Fixes: nodejs#14028
  • Loading branch information
Trott committed Jul 3, 2017
1 parent bec3877 commit f03541e
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 8 deletions.
1 change: 0 additions & 1 deletion test/parallel/parallel.status
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ prefix parallel
[$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: 11 additions & 7 deletions test/parallel/test-fs-readdir-ucs2.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,20 @@ 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');
return;
}
throw e;
}

fs.readdir(common.tmpDir, 'ucs2', (err, list) => {
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 f03541e

Please sign in to comment.