From 56eefb86fa4a4038bc95fd8e53604f5ca650efb7 Mon Sep 17 00:00:00 2001 From: Sebastian Martinez Date: Wed, 20 Dec 2023 09:57:46 +0100 Subject: [PATCH] Check that the rad binary used is the same as added to PATH We weren't checking that the binary that we want to use for the test suite, is the one we end up using. --- tests/support/support.ts | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/tests/support/support.ts b/tests/support/support.ts index d8a1b337a..2064438fa 100644 --- a/tests/support/support.ts +++ b/tests/support/support.ts @@ -29,13 +29,17 @@ export const heartwoodShortSha = ( await Fs.readFile(`${supportDir}/heartwood-version`, "utf8") ).substring(0, 7); -process.env.PATH = [ - Path.join(tmpDir, "bin", heartwoodShortSha), - process.env.PATH, -].join(Path.delimiter); +const binaryPath = Path.join(tmpDir, "bin", heartwoodShortSha); +process.env.PATH = [binaryPath, process.env.PATH].join(Path.delimiter); // Assert that the `rad` CLI is installed and has the correct version. export async function assertRadInstalled(): Promise { + const { stdout: which } = await execa("which", ["rad"]); + if (Path.dirname(which) !== binaryPath) { + throw new Error( + `rad path doesn't match used rad binary: ${binaryPath} !== ${which}`, + ); + } const { stdout: version } = await execa("rad", ["--version"]); if (!version.includes(heartwoodShortSha)) { throw new Error(