From 1cfe058778bd5d63bed008da4e15229cbf60cc37 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tobias=20Nie=C3=9Fen?= Date: Wed, 15 Mar 2023 02:57:15 +0100 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 PR-URL: https://github.com/nodejs/node/pull/47095 Reviewed-By: Rafael Gonzaga Reviewed-By: Luigi Pinca Reviewed-By: Colin Ihrig Reviewed-By: Moshe Atlow --- .../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/*',