mirror of
https://github.com/morluto/rea.git
synced 2026-11-22 14:35:45 +00:00
fix(process): resolve Windows root-relative commands on the selected drive (#11763)
* fix(process): resolve Windows root-relative commands on the selected drive * test(process): pin drive-less PATH entries and UNC root-relative commands A Windows PATH entry rooted without a drive now counts as relative, so programOnPath skips it. Pin that with a Windows case, test a root-relative command under a UNC working directory, and say in the relativeEntry and windowsPathCandidates docs that drive-less entries count as relative. --------- Co-authored-by: morluto <76467478+morluto@users.noreply.github.com>
This commit is contained in:
1 parent
23adfc610f
commit
5aa1fc5737
3 files changed
+68
-11
No files matched your search
@@ -1,11 +1,14 @@
|
||||
import { mkdir, writeFile } from "node:fs/promises";
|
||||
import { join } from "node:path";
|
||||
|
||||
import { expect, it } from "vitest";
|
||||
import { expect, it, onTestFinished, vi } from "vitest";
|
||||
|
||||
import { createTestTempDirectory } from "../../tests/fixtures/temporaryDirectory.js";
|
||||
import { PRODUCT_IDENTITY } from "../identity.js";
|
||||
import { resolveBuildComputerEnvironment } from "./BuildComputerEnvironment.js";
|
||||
import {
|
||||
programOnPath,
|
||||
resolveBuildComputerEnvironment,
|
||||
} from "./BuildComputerEnvironment.js";
|
||||
|
||||
const host = async () => {
|
||||
const root = await createTestTempDirectory("rea-build-environment-");
|
||||
@@ -29,6 +32,27 @@ const host = async () => {
|
||||
return { bin, archive, environment };
|
||||
};
|
||||
|
||||
it.runIf(process.platform === "win32")(
|
||||
"skips a Windows PATH entry without a drive, which follows the current drive",
|
||||
async () => {
|
||||
const root = await createTestTempDirectory("rea-build-program-drive-");
|
||||
const bin = join(root, "bin");
|
||||
await mkdir(bin);
|
||||
await writeFile(join(bin, "agent-env.exe"), "");
|
||||
// On the same drive, `\...\bin` names the same existing file.
|
||||
const cwd = vi.spyOn(process, "cwd").mockReturnValue(root);
|
||||
onTestFinished(() => cwd.mockRestore());
|
||||
const driveless = bin.slice(2);
|
||||
|
||||
expect(await programOnPath("agent-env", { PATH: driveless })).toBe(
|
||||
undefined,
|
||||
);
|
||||
expect(await programOnPath("agent-env", { PATH: bin })).toBe(
|
||||
join(bin, "agent-env.EXE"),
|
||||
);
|
||||
},
|
||||
);
|
||||
|
||||
it.skipIf(process.platform === "win32")(
|
||||
"resolves every build setting on a host that exports none of them",
|
||||
async () => {
|
||||
|
||||
Reference in new issue
Block a user