From e236f8f17eadd79560e86550290b6d662109c389 Mon Sep 17 00:00:00 2001 From: Antoine du Hamel Date: Fri, 6 Sep 2024 19:38:42 +0200 Subject: [PATCH] test: fix `test-process-load-env-file` when path contains `'` If the repo is cloned on a path that contains a quote, the test should not fail. PR-URL: https://github.com/nodejs/node/pull/54511 Reviewed-By: Yagiz Nizipli Reviewed-By: James M Snell --- test/parallel/test-process-load-env-file.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/test/parallel/test-process-load-env-file.js b/test/parallel/test-process-load-env-file.js index 41e487b39b390c..795b8773d955cb 100644 --- a/test/parallel/test-process-load-env-file.js +++ b/test/parallel/test-process-load-env-file.js @@ -8,7 +8,7 @@ const { join } = require('node:path'); const basicValidEnvFilePath = fixtures.path('dotenv/basic-valid.env'); const validEnvFilePath = fixtures.path('dotenv/valid.env'); -const missingEnvFile = fixtures.path('dotenv/non-existent-file.env'); +const missingEnvFile = fixtures.path('dir%20with unusual"chars \'åß∂ƒ©∆¬…`/non-existent-file.env'); describe('process.loadEnvFile()', () => { @@ -85,7 +85,11 @@ describe('process.loadEnvFile()', () => { assert.match(child.stderr, /code: 'ERR_ACCESS_DENIED'/); assert.match(child.stderr, /permission: 'FileSystemRead'/); if (!common.isWindows) { - assert(child.stderr.includes(`resource: '${JSON.stringify(missingEnvFile).replaceAll('"', '')}'`)); + const resource = /^\s+resource: (['"])(.+)\1$/m.exec(child.stderr); + assert(resource); + assert.strictEqual(resource[2], resource[1] === "'" ? + missingEnvFile.replaceAll("'", "\\'") : + JSON.stringify(missingEnvFile).slice(1, -1)); } assert.strictEqual(child.code, 1); });