From 0e42c4c4c4c3566e397ae2f110078b0ea4ef7302 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tobias=20Nie=C3=9Fen?= Date: Tue, 14 Mar 2023 19:45:18 +0000 Subject: [PATCH] test: fix test-permission-deny-fs-wildcard (win32) The test fails on Windows when the working directory is not on a 'C:' drive. For example, it always fails during the coverage-windows GitHub action, which runs tests on drive 'D:'. Fixes: https://github.com/nodejs/node/issues/47093 --- .../test-permission-deny-fs-wildcard.js | 33 ++++++++++--------- 1 file changed, 18 insertions(+), 15 deletions(-) diff --git a/test/parallel/test-permission-deny-fs-wildcard.js b/test/parallel/test-permission-deny-fs-wildcard.js index 2e278cb60bddc7..ff89bbc53c80db 100644 --- a/test/parallel/test-permission-deny-fs-wildcard.js +++ b/test/parallel/test-permission-deny-fs-wildcard.js @@ -6,25 +6,28 @@ common.skipIfWorker(); const assert = require('assert'); const fs = require('fs'); +const path = require('path'); if (common.isWindows) { + const { root } = path.parse(process.cwd()); + const abs = (p) => path.join(root, p); const denyList = [ - 'C:\\tmp\\*', - 'C:\\example\\foo*', - 'C:\\example\\bar*', - 'C:\\folder\\*', - 'C:\\show', - 'C:\\slower', - 'C:\\slown', - 'C:\\home\\foo\\*', - ]; + 'tmp\\*', + 'example\\foo*', + 'example\\bar*', + 'folder\\*', + 'show', + 'slower', + 'slown', + 'home\\foo\\*', + ].map(abs); assert.ok(process.permission.deny('fs.read', denyList)); - assert.ok(process.permission.has('fs.read', 'C:\\slow')); - assert.ok(process.permission.has('fs.read', 'C:\\slows')); - assert.ok(!process.permission.has('fs.read', 'C:\\slown')); - assert.ok(!process.permission.has('fs.read', 'C:\\home\\foo')); - assert.ok(!process.permission.has('fs.read', 'C:\\home\\foo\\')); - assert.ok(process.permission.has('fs.read', 'C:\\home\\fo')); + assert.ok(process.permission.has('fs.read', abs('slow'))); + assert.ok(process.permission.has('fs.read', abs('slows'))); + assert.ok(!process.permission.has('fs.read', abs('slown'))); + assert.ok(!process.permission.has('fs.read', abs('home\\foo'))); + assert.ok(!process.permission.has('fs.read', abs('home\\foo\\'))); + assert.ok(process.permission.has('fs.read', abs('home\\fo'))); } else { const denyList = [ '/tmp/*',