From 175d46ebf10159d0cd6ecb008e632b1663eb5a80 Mon Sep 17 00:00:00 2001 From: Rich Trott Date: Sat, 1 Jul 2017 08:14:28 -0700 Subject: [PATCH] test: skip test-fs-readdir-ucs2 if no support If the filesystem does not support UCS2, do not run the test. Backport-PR-URL: https://github.com/nodejs/node/pull/14835 PR-URL: https://github.com/nodejs/node/pull/14029 Fixes: https://github.com/nodejs/node/issues/14028 Reviewed-By: Colin Ihrig Reviewed-By: Luigi Pinca Reviewed-By: Refael Ackermann Reviewed-By: Richard Lau --- test/parallel/parallel.status | 1 - test/parallel/test-fs-readdir-ucs2.js | 18 ++++++++++-------- 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/test/parallel/parallel.status b/test/parallel/parallel.status index b2eccf8eb69c75..65da4e2c75ae20 100644 --- a/test/parallel/parallel.status +++ b/test/parallel/parallel.status @@ -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 diff --git a/test/parallel/test-fs-readdir-ucs2.js b/test/parallel/test-fs-readdir-ucs2.js index de8fe5d536d7d5..4f9964333929c1 100644 --- a/test/parallel/test-fs-readdir-ucs2.js +++ b/test/parallel/test-fs-readdir-ucs2.js @@ -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); -}); +}));