Skip to content

Commit d2e2ace

Browse files
committed
test(ssh): race test counts installs and survives quoted PATH entries
1 parent b252a8b commit d2e2ace

1 file changed

Lines changed: 14 additions & 7 deletions

File tree

‎packages/ssh/src/tunnel.test.ts‎

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -898,15 +898,21 @@ describe("archive runner script", () => {
898898
yield* fs.makeDirectory(home, { recursive: true });
899899
// uutils coreutils (Ubuntu's default) mkdir exits 0 when it loses the
900900
// race to create a directory. Shim that behavior so the race covers
901-
// such hosts wherever the test runs.
902-
const hostPath = process.env.PATH ?? "";
903-
yield* fs.makeDirectory(`${root}/bin`);
901+
// such hosts wherever the test runs, and count unpacks to prove a
902+
// single install. Each shim drops its own directory from PATH.
903+
const bin = `${root}/bin`;
904+
yield* fs.makeDirectory(bin);
904905
yield* fs.writeFileString(
905-
`${root}/bin/mkdir`,
906-
`#!/bin/sh\nPATH='${hostPath}' exec mkdir -p "$@"\n`,
906+
`${bin}/mkdir`,
907+
'#!/bin/sh\nPATH=${PATH#*:}\nexec mkdir -p "$@"\n',
907908
);
908-
yield* fs.chmod(`${root}/bin/mkdir`, 0o755);
909-
const racePath = `${root}/bin:${hostPath}`;
909+
yield* fs.writeFileString(
910+
`${bin}/tar`,
911+
'#!/bin/sh\necho >> "${0%/*}/installs"\nPATH=${PATH#*:}\nexec tar "$@"\n',
912+
);
913+
yield* fs.chmod(`${bin}/mkdir`, 0o755);
914+
yield* fs.chmod(`${bin}/tar`, 0o755);
915+
const racePath = `${bin}:${process.env.PATH ?? ""}`;
910916

911917
const results = yield* Effect.all(
912918
[
@@ -920,6 +926,7 @@ describe("archive runner script", () => {
920926
assert.equal(result.exitCode, 0, result.stderr);
921927
assert.include(result.stdout, `t3 v${archiveVersion}`);
922928
}
929+
assert.equal(yield* fs.readFileString(`${bin}/installs`), "\n");
923930
const versionsDir = `${home}/.t3/runtime/versions`;
924931
assert.deepEqual(yield* fs.readDirectory(versionsDir), [archiveVersion]);
925932
assert.equal(

0 commit comments

Comments
 (0)