From 5e9298bf4a6b6f1227e8d82a39f9325d267c16e1 Mon Sep 17 00:00:00 2001 From: merceyz Date: Thu, 17 Nov 2022 19:19:43 +0100 Subject: [PATCH 1/2] test: fix constraints test to handle paths containing spaces --- .../pkg-tests-specs/sources/commands/constraints.test.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/packages/acceptance-tests/pkg-tests-specs/sources/commands/constraints.test.js b/packages/acceptance-tests/pkg-tests-specs/sources/commands/constraints.test.js index 9689af891067..80f4be813687 100644 --- a/packages/acceptance-tests/pkg-tests-specs/sources/commands/constraints.test.js +++ b/packages/acceptance-tests/pkg-tests-specs/sources/commands/constraints.test.js @@ -1,3 +1,4 @@ +const {npath} = require(`@yarnpkg/fslib`); const { fs: {writeFile}, } = require(`pkg-tests-core`); @@ -110,7 +111,7 @@ describe(`Commands`, () => { ({code, stdout, stderr} = error); } - stdout = stdout.replace(/[^( ]+[\\/](yarn\.config)/g, `/path/to/$1`); + stdout = stdout.replace(new RegExp(npath.join(npath.fromPortablePath(path), `yarn.config.js`).replace(/\\/g, `\\\\`), `g`), `/path/to/yarn.config.js`); stdout = stdout.replace(/(Module|Object)\.(exports\.)/g, `$2`); expect({code, stdout, stderr}).toMatchSnapshot(); From d12aa306d96ddcbd625b0f4efab233b814e90dee Mon Sep 17 00:00:00 2001 From: merceyz Date: Thu, 17 Nov 2022 22:44:57 +0100 Subject: [PATCH 2/2] test: avoid using regexp --- .../pkg-tests-specs/sources/commands/constraints.test.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/packages/acceptance-tests/pkg-tests-specs/sources/commands/constraints.test.js b/packages/acceptance-tests/pkg-tests-specs/sources/commands/constraints.test.js index 80f4be813687..559456b9fa8a 100644 --- a/packages/acceptance-tests/pkg-tests-specs/sources/commands/constraints.test.js +++ b/packages/acceptance-tests/pkg-tests-specs/sources/commands/constraints.test.js @@ -111,7 +111,8 @@ describe(`Commands`, () => { ({code, stdout, stderr} = error); } - stdout = stdout.replace(new RegExp(npath.join(npath.fromPortablePath(path), `yarn.config.js`).replace(/\\/g, `\\\\`), `g`), `/path/to/yarn.config.js`); + // TODO: Use .replaceAll when we drop support for Node.js v14 + stdout = stdout.split(npath.join(npath.fromPortablePath(path), `yarn.config.js`)).join(`/path/to/yarn.config.js`); stdout = stdout.replace(/(Module|Object)\.(exports\.)/g, `$2`); expect({code, stdout, stderr}).toMatchSnapshot();