Skip to content

Commit 7628f34

Browse files
committed
test(ssh): race test counts installs and survives quoted PATH entries
1 parent f91248a commit 7628f34

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
@@ -912,15 +912,21 @@ describe("archive runner script", () => {
912912
yield* fs.makeDirectory(home, { recursive: true });
913913
// uutils coreutils (Ubuntu's default) mkdir exits 0 when it loses the
914914
// race to create a directory. Shim that behavior so the race covers
915-
// such hosts wherever the test runs.
916-
const hostPath = process.env.PATH ?? "";
917-
yield* fs.makeDirectory(`${root}/bin`);
915+
// such hosts wherever the test runs, and count unpacks to prove a
916+
// single install. Each shim drops its own directory from PATH.
917+
const bin = `${root}/bin`;
918+
yield* fs.makeDirectory(bin);
918919
yield* fs.writeFileString(
919-
`${root}/bin/mkdir`,
920-
`#!/bin/sh\nPATH='${hostPath}' exec mkdir -p "$@"\n`,
920+
`${bin}/mkdir`,
921+
'#!/bin/sh\nPATH=${PATH#*:}\nexec mkdir -p "$@"\n',
921922
);
922-
yield* fs.chmod(`${root}/bin/mkdir`, 0o755);
923-
const racePath = `${root}/bin:${hostPath}`;
923+
yield* fs.writeFileString(
924+
`${bin}/tar`,
925+
'#!/bin/sh\necho >> "${0%/*}/installs"\nPATH=${PATH#*:}\nexec tar "$@"\n',
926+
);
927+
yield* fs.chmod(`${bin}/mkdir`, 0o755);
928+
yield* fs.chmod(`${bin}/tar`, 0o755);
929+
const racePath = `${bin}:${process.env.PATH ?? ""}`;
924930

925931
const results = yield* Effect.all(
926932
[
@@ -934,6 +940,7 @@ describe("archive runner script", () => {
934940
assert.equal(result.exitCode, 0, result.stderr);
935941
assert.include(result.stdout, `t3 v${archiveVersion}`);
936942
}
943+
assert.equal(yield* fs.readFileString(`${bin}/installs`), "\n");
937944
const versionsDir = `${home}/.t3/runtime/versions`;
938945
assert.deepEqual(yield* fs.readDirectory(versionsDir), [archiveVersion]);
939946
assert.equal(

0 commit comments

Comments
 (0)