diff --git a/CHANGELOG.md b/CHANGELOG.md index e68bf2d61..14b593c51 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -53,7 +53,8 @@ latest one; the GitHub release carries the same notes. MattCozendey); a `!` program built for the CPU because no CUDA toolkit was found says so (PR #1888); colliding output requests are refused before anything is written (PR #2010 by vicmcorrea); a hyphenated - published file prints valid aliases (PR #1849 by vicmcorrea). + published file prints valid aliases (PR #1849 by vicmcorrea); + `--checkup` resolves imports from a symlinked entry's real directory. - **Fixes**: - Checker and verdict: a law names its module's own def when a Base constructor shares the name (#1236, PR #2047 by nicolas-abril); `!=` diff --git a/bend2/main.ts b/bend2/main.ts index 47259a4e2..5c44e70a0 100755 --- a/bend2/main.ts +++ b/bend2/main.ts @@ -356,6 +356,8 @@ async function cli_file(args: string[]): Promise { async function cli_checkup(file: string): Promise { const base = await book_read(BASE); let bad = false; + file = fs.realpathSync(file); + const dir = path.dirname(file); for (const raw of fs.readFileSync(file, "utf8").split("\n")) { const line = raw.trim(); if (line === "" || line.startsWith("#")) { @@ -370,7 +372,7 @@ async function cli_checkup(file: string): Promise { continue; } const at = m[1].startsWith("/") ? m[1] - : path.join(path.dirname(file), m[1]); + : path.join(dir, m[1]); cli_say(1, "--- " + m[1] + " ---\n"); let code = 1; try { diff --git a/gates/ping.ts b/gates/ping.ts index 5ab4fdd99..d897e07f0 100644 --- a/gates/ping.ts +++ b/gates/ping.ts @@ -365,6 +365,13 @@ try { check("valid body literal text does not add an independent import", header_check.code === 0 && header_run.code === 0 && header_run.out.endsWith("5n\n")); + const alias_dir = path.join(TMP, "checkup-alias"); + fs.mkdirSync(alias_dir); + const alias = path.join(alias_dir, "entry.bend"); + fs.symlinkSync(header_source, alias); + const linked = await bend([alias, "--checkup"], { BEND_NO_TELEMETRY: "1" }); + check("--checkup resolves imports from the symlink target's directory", + linked.code === 0 && linked.out === header_run.out); const no_base = path.join(TMP, "no-base.bend"); fs.writeFileSync(no_base, "def main() -> String:\n \"body\nimport Base\n\"\n");