Semver check tests: double trailing slash, and a process started outside the target repo
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
84a34b8735
commit
32f5700b2a
1 changed files with 18 additions and 5 deletions
|
|
@ -204,11 +204,12 @@ function withTempGitRepo(fn) {
|
|||
}
|
||||
}
|
||||
|
||||
// Runs the checker with `cwd` as its working directory, which is never the
|
||||
// repository that holds the checker: the release scripts do not run it from there either.
|
||||
function runChecker(cwd, args, { env, script = checkerPath } = {}) {
|
||||
// Runs the checker on the repository at `cwd` (--cwd). The process itself starts in
|
||||
// `processCwd`, by default that same repository, never the one that holds the checker:
|
||||
// the release scripts do not run it from there either.
|
||||
function runChecker(cwd, args, { env, script = checkerPath, processCwd = cwd } = {}) {
|
||||
return execFileSync(process.execPath, [script, ...args, "--cwd", cwd], {
|
||||
cwd,
|
||||
cwd: processCwd,
|
||||
env,
|
||||
encoding: "utf8",
|
||||
stdio: ["ignore", "pipe", "pipe"],
|
||||
|
|
@ -484,7 +485,7 @@ test("CLI: a missing changelog fails and names the path; stray positional words
|
|||
|
||||
test("measured: the baseline path may use backslashes or a trailing slash", () => {
|
||||
withReleasedBaseline({ baseline: { "GameCult.Widget.dll": oldWidget() } }, (dir) => {
|
||||
for (const path of [`${PLUGINS}/`, PLUGINS.replace(/\//g, "\\")]) {
|
||||
for (const path of [`${PLUGINS}/`, `${PLUGINS}//`, PLUGINS.replace(/\//g, "\\")]) {
|
||||
const args = measuredArgs(dir, "1.1.0", [trimmedWidget()]);
|
||||
args[args.indexOf("--api-baseline-path") + 1] = path;
|
||||
assert.match(runCheckerExpectFailure(dir, args), /Gone/);
|
||||
|
|
@ -492,6 +493,18 @@ test("measured: the baseline path may use backslashes or a trailing slash", () =
|
|||
});
|
||||
});
|
||||
|
||||
test("measured: reads the repository named by --cwd, not the directory the process started in", () => {
|
||||
withReleasedBaseline({ baseline: { "GameCult.Widget.dll": oldWidget() } }, (dir) => {
|
||||
const elsewhere = mkdtempSync(join(tmpdir(), "cultlib-semver-elsewhere-"));
|
||||
try {
|
||||
const output = runCheckerExpectFailure(dir, measuredArgs(dir, "1.1.0", [trimmedWidget()]), { processCwd: elsewhere });
|
||||
assert.match(output, /Gone/);
|
||||
} finally {
|
||||
rmSync(elsewhere, { recursive: true, force: true });
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
test("measured: leaves no temporary files behind, passing or failing", () => {
|
||||
withReleasedBaseline({ baseline: { "GameCult.Widget.dll": oldWidget() } }, (dir) => {
|
||||
const scratch = mkdtempSync(join(tmpdir(), "cultlib-semver-scratch-"));
|
||||
|
|
|
|||
Loading…
Reference in a new issue