Skip to content

Commit 32bcc03

Browse files
cdervclaude
andauthored
Fix vacuous-pass bugs in verify.ts (#14705)
Verifier audit findings, each verified against the source: - ensurePptxMaxSlides passed 'true' into the rels slot instead of isSlideMax, so the slide{N+1}-must-not-exist assertion never ran - the verifier could only fail when the deck had FEWER slides than the max, the inverse of its purpose. Two live regression tests (9681, 11896: no extra blank slides) were neutered by this. - ensureHtmlElementContents skipped selectors that matched nothing - all content assertions silently vacuous when the selector is absent (e.g. jupyter display-error tests pass if error output disappears entirely). Now asserts the selector matched. - verifyYamlFile resolved successfully when the yaml file was missing or empty; now fails loudly before running the predicate. - ensurePptxRegexMatches MOVED the pptx into its temp dir (destroying it for any later verifier in the same test); now copies like withPptxContent does. Like the previous commit, these assertions were dead until now and may surface genuine regressions on their first live CI run. Co-authored-by: Claude <noreply@anthropic.com>
1 parent a90065c commit 32bcc03

1 file changed

Lines changed: 32 additions & 27 deletions

File tree

‎tests/verify.ts‎

Lines changed: 32 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -429,23 +429,26 @@ export const ensureHtmlElementContents = (
429429
const doc = new DOMParser().parseFromString(htmlInput, "text/html")!;
430430
options.selectors.forEach((sel) => {
431431
const el = doc.querySelector(sel);
432-
if (el !== null) {
433-
const contents = el.innerText;
434-
options.matches.forEach((regex) => {
435-
assert(
436-
asRegexp(regex).test(contents),
437-
`Required match ${String(regex)} is missing from selector ${sel} content: ${contents}.`,
438-
);
439-
});
432+
// a selector matching nothing must fail, not skip - otherwise the
433+
// content assertions are silently vacuous
434+
assert(
435+
el !== null,
436+
`Selector ${sel} matched no element in ${file}.`,
437+
);
438+
const contents = el.innerText;
439+
options.matches.forEach((regex) => {
440+
assert(
441+
asRegexp(regex).test(contents),
442+
`Required match ${String(regex)} is missing from selector ${sel} content: ${contents}.`,
443+
);
444+
});
440445

441-
options.noMatches?.forEach((regex) => {
442-
assert(
443-
!asRegexp(regex).test(contents),
444-
`Unexpected match ${String(regex)} is present from selector ${sel} content: ${contents}.`,
445-
);
446-
});
447-
448-
}
446+
options.noMatches?.forEach((regex) => {
447+
assert(
448+
!asRegexp(regex).test(contents),
449+
`Unexpected match ${String(regex)} is present from selector ${sel} content: ${contents}.`,
450+
);
451+
});
449452
});
450453
},
451454
};
@@ -1061,7 +1064,9 @@ export const ensurePptxMaxSlides = (
10611064
// callback won't be used here
10621065
() => Promise.resolve(),
10631066
`Checking Pptx for maximum ${slideNumberMax} slides`,
1064-
)(file, slideNumberMax, true);
1067+
// positional args: rels=false, isSlideMax=true - passing true in the
1068+
// rels slot silently disabled the max-slides check entirely
1069+
)(file, slideNumberMax, false, true);
10651070
};
10661071

10671072
export const ensureDocxRegexMatches = (
@@ -1173,9 +1178,10 @@ export const ensurePptxRegexMatches = (
11731178
const [_dir, stem] = dirAndStem(file);
11741179
const temp = await Deno.makeTempDir();
11751180
try {
1176-
// Move the docx to a temp dir and unzip it
1181+
// Copy (not move - later verifiers may still need the pptx) to a
1182+
// temp dir and unzip it
11771183
const zipFile = join(temp, stem + ".zip");
1178-
await Deno.rename(file, zipFile);
1184+
await Deno.copyFile(file, zipFile);
11791185
await unzip(zipFile);
11801186

11811187
// Open the core xml document and match the matches
@@ -1247,14 +1253,13 @@ export const verifyYamlFile = (
12471253
return {
12481254
name: "Project Yaml is Valid",
12491255
verify: async (_output: ExecuteOutput[]) => {
1250-
if (existsSync(file)) {
1251-
const raw = await Deno.readTextFile(file);
1252-
if (raw) {
1253-
const yaml = readYamlFromString(raw);
1254-
const isValid = func(yaml);
1255-
assert(isValid, "Project Metadata isn't valid");
1256-
}
1257-
}
1256+
// missing or empty yaml must fail, not skip the predicate
1257+
assert(existsSync(file), `Yaml file ${file} doesn't exist`);
1258+
const raw = await Deno.readTextFile(file);
1259+
assert(raw.trim().length > 0, `Yaml file ${file} is empty`);
1260+
const yaml = readYamlFromString(raw);
1261+
const isValid = func(yaml);
1262+
assert(isValid, "Project Metadata isn't valid");
12581263
},
12591264
};
12601265
};

0 commit comments

Comments
 (0)