From b6e301a9e0ccdebda1ff558e9aa6cf4497412860 Mon Sep 17 00:00:00 2001 From: Rich Trott Date: Fri, 5 Jul 2019 14:15:19 -0700 Subject: [PATCH] test: add test-fs-writeFileSync-invalid-windows Add a known_issues test for the Windows returning ENOTFOUND where EINVAL is more appropriate. This happens with various functions in the `fs` module when an invalid path is used. Refs: https://github.com/nodejs/node/issues/8987 PR-URL: https://github.com/nodejs/node/pull/28569 Reviewed-By: Colin Ihrig Reviewed-By: Luigi Pinca Reviewed-By: Ruben Bridgewater --- .../test-fs-writeFileSync-invalid-windows.js | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 test/known_issues/test-fs-writeFileSync-invalid-windows.js diff --git a/test/known_issues/test-fs-writeFileSync-invalid-windows.js b/test/known_issues/test-fs-writeFileSync-invalid-windows.js new file mode 100644 index 00000000000..614b7427c02 --- /dev/null +++ b/test/known_issues/test-fs-writeFileSync-invalid-windows.js @@ -0,0 +1,21 @@ +'use strict'; + +const common = require('../common'); + +// Test that using an invalid file name with writeFileSync() on Windows returns +// EINVAL. With libuv 1.x, it returns ENOTFOUND. This should be fixed when we +// update to libuv 2.x. +// +// Refs: https://github.com/nodejs/node/issues/8987 + +const assert = require('assert'); +const fs = require('fs'); + +if (!common.isWindows) { + // Change to `common.skip()` when the test is moved out of `known_issues`. + assert.fail('Windows-only test'); +} + +assert.throws(() => { + fs.writeFileSync('fhqwhgads??', 'come on'); +}, { code: 'EINVAL' });