Skip to content

Commit d8070a9

Browse files
committed
fix(scripts): resolve PR wrapper paths physically
1 parent d1c7588 commit d8070a9

2 files changed

Lines changed: 36 additions & 1 deletion

File tree

‎scripts/pr‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,8 @@ requested_subcommand="${1-}"
4141

4242
# Select trusted wrapper code independently from the canonical repository root;
4343
# a linked wrapper may be removed by merge-run or gc before supervision ends.
44-
script_self="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/$(basename "${BASH_SOURCE[0]}")"
44+
# Physical paths keep helper argv aligned with Node's canonical module URLs.
45+
script_self="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd -P)/$(basename "${BASH_SOURCE[0]}")"
4546
script_parent_dir="$(dirname "$script_self")"
4647
canonical_repo_root="$script_parent_dir/.."
4748
pr_wrapper_components=(

‎test/scripts/pr-wrappers.test.ts‎

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -500,6 +500,40 @@ describe("scripts/pr wrappers", () => {
500500
}
501501
});
502502

503+
itPosix("executes extracted helpers through a symlinked temporary root", () => {
504+
const fixture = makeMismatchedWrapperRepo({ realModules: true });
505+
try {
506+
// Exercise the wrapper's own helper path, not a physical path reconstructed by the test.
507+
writeFileSync(
508+
join(fixture.canonical, "scripts/pr-lib/gates.sh"),
509+
`ci_dispatch() { node "$(review_artifacts_helper_path)" template "$1" "${REVIEWED_HEAD}"; }\n`,
510+
);
511+
fixture.git(fixture.canonical, ["add", "scripts/pr-lib/gates.sh"]);
512+
fixture.git(fixture.canonical, ["commit", "-m", "test: real anchor helper dispatch"]);
513+
fixture.git(fixture.canonical, ["push", "origin", "main"]);
514+
parkCanonicalOffAnchor(fixture);
515+
const temporaryAlias = join(fixture.root, "temporary-alias");
516+
symlinkSync(fixture.root, temporaryAlias, "dir");
517+
const result = spawnSync(
518+
join(fixture.linked, "scripts/pr"),
519+
["ci-dispatch", String(REVIEWED_PR)],
520+
{
521+
cwd: fixture.linked,
522+
encoding: "utf8",
523+
env: { ...fixture.env, TMPDIR: temporaryAlias },
524+
},
525+
);
526+
expect(result.status, `${result.stdout}\n${result.stderr}`).toBe(0);
527+
expect(result.stderr).toContain("running wrapper code materialized from");
528+
expect(result.stdout, "the extracted helper must not silently skip its entrypoint").toContain(
529+
REVIEWED_HEAD,
530+
);
531+
expect(JSON.parse(result.stdout).pr).toEqual({ number: REVIEWED_PR, headSha: REVIEWED_HEAD });
532+
} finally {
533+
fixture.cleanup();
534+
}
535+
});
536+
503537
itPosix("executes review artifacts from the extracted anchor dependency closure", () => {
504538
const fixture = makeMismatchedWrapperRepo({ realModules: true });
505539
try {

0 commit comments

Comments
 (0)