Semver check: built and reference paths are resolved against the process, not the tool's directory
The ApiCompat tool runs from scripts/api-gate, so a relative --api-built or --api-refs failed as an unreadable assembly. The release scripts pass absolute paths; any other caller does not have to. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
0ac870f132
commit
df13b502b9
2 changed files with 19 additions and 3 deletions
|
|
@ -11,7 +11,7 @@
|
|||
import { execFileSync, spawnSync } from "node:child_process";
|
||||
import { existsSync, mkdirSync, mkdtempSync, readdirSync, readFileSync, rmSync, writeFileSync } from "node:fs";
|
||||
import { tmpdir } from "node:os";
|
||||
import { basename, dirname, join } from "node:path";
|
||||
import { basename, dirname, join, resolve } from "node:path";
|
||||
import { fileURLToPath, pathToFileURL } from "node:url";
|
||||
|
||||
// The exact heading spelling the policy mandates for a breaking-change
|
||||
|
|
@ -342,7 +342,8 @@ const UNMEASURED_NOTICE =
|
|||
function main() {
|
||||
const args = parseArgs(process.argv.slice(2));
|
||||
const { package: packageName, changelog, version, "tag-prefix": tagPrefix, cwd = process.cwd() } = args;
|
||||
const built = args["api-built"] ?? [];
|
||||
// The tool runs from scripts/api-gate, so a path given relative to this process is made absolute first.
|
||||
const built = (args["api-built"] ?? []).map((path) => resolve(path));
|
||||
if (!packageName || !changelog || !version || !tagPrefix || (built.length > 0) !== Boolean(args["api-baseline-path"])) {
|
||||
console.error(
|
||||
"usage: check-changelog-semver.mjs --package <name> --changelog <path> --version <x.y.z> --tag-prefix <prefix> [--cwd <dir>] [--first-release]\n" +
|
||||
|
|
@ -390,7 +391,7 @@ function main() {
|
|||
previousVersion,
|
||||
baselinePath: args["api-baseline-path"],
|
||||
built,
|
||||
refs: args["api-refs"] ?? [],
|
||||
refs: (args["api-refs"] ?? []).map((path) => resolve(path)),
|
||||
declaredNew: args["api-new"] ?? [],
|
||||
cwd,
|
||||
});
|
||||
|
|
|
|||
|
|
@ -820,3 +820,18 @@ test("refusals never repeat what the inputs contain", () => {
|
|||
rmSync(scratch, { recursive: true, force: true });
|
||||
}
|
||||
});
|
||||
|
||||
test("measured: built and reference paths given relative to the process are read from there", () => {
|
||||
withReleasedBaseline({ baseline: { "GameCult.Widget.dll": oldWidget() } }, (dir) => {
|
||||
const scratch = mkdtempSync(join(tmpdir(), "cultlib-semver-relative-"));
|
||||
try {
|
||||
mkdirSync(join(scratch, "refs"));
|
||||
copyFileSync(trimmedWidget(), join(scratch, "GameCult.Widget.dll"));
|
||||
const args = measuredArgs(dir, "1.1.0", ["GameCult.Widget.dll"], { refs: ["refs"] });
|
||||
// The tool is started elsewhere, so an unresolved relative path would not be found.
|
||||
assert.match(runCheckerExpectFailure(dir, args, { processCwd: scratch }), /Gone/);
|
||||
} finally {
|
||||
rmSync(scratch, { recursive: true, force: true });
|
||||
}
|
||||
});
|
||||
});
|
||||
|
|
|
|||
Loading…
Reference in a new issue