diff --git a/documentation/agent-notes.md b/documentation/agent-notes.md index 5b1febb..79804a2 100644 --- a/documentation/agent-notes.md +++ b/documentation/agent-notes.md @@ -2304,6 +2304,13 @@ into `.conformance-artifacts/`, which `.gitignore` covers, and IGNORED rather than merely uncommitted. A set comparison of `git status --porcelain` alone passes happily over a visible working directory; that is why the second half of that test exists. +**THAT TEST RUNS ALONE, AFTER EVERY OTHER TEST FILE.** Vitest runs files in parallel, and three of +them write into the working tree for a moment: the README usage case, the `tsup` build it spawns, +and the phi-scan override-gate case. A `git status` taken beside them compares their leftovers, not +the run's, and the release Verify step on `d906bda` went red that way. `vitest.config.ts` gives the +file a project of its own with a later `sequence.groupOrder` and says why there. Do not answer a red +from it by loosening the set comparison. + **SIZE IS THE SECOND REASON AND IT IS INDEPENDENT OF THE FIRST.** The Schematron is about 1 MB and its vocabulary file is about 65 MB. Neither belongs in an npm package, and the corpus is CC0 so licence is not what forbids vendoring it. diff --git a/vitest.config.ts b/vitest.config.ts index 24929e2..7bd6e2a 100644 --- a/vitest.config.ts +++ b/vitest.config.ts @@ -1,4 +1,5 @@ import { cosyteVitest } from "@cosyte/vitest-config"; +import { configDefaults } from "vitest/config"; /** * Vitest config for @cosyte/ccda from the shared @cosyte/vitest-config standard. @@ -35,12 +36,51 @@ import { cosyteVitest } from "@cosyte/vitest-config"; * The measurement that sized them is in the `CHANGELOG.md` entry for * `PARSER-TESTTIMEOUT-ASSERTS-AN-IDLE-BOX`, dated, where it cannot drift out from under this file. * Re-measure rather than inherit it, and do not put a number back here. + * + * **THE WORKING-TREE SNAPSHOT RUNS ALONE, AFTER EVERY OTHER FILE, AND THAT IS WHAT MAKES IT A + * MEASUREMENT.** `test/conformance/working-tree-is-clean.test.ts` takes `git status` of the real + * working tree before and after a conformance run and requires the two sets to be equal. Vitest runs + * test files in parallel, and other files write into that same tree for a moment: the README usage + * case in `test/docs-content.test.ts` writes `.cosyte-usage-stdout/` and removes it in `afterAll`, the + * `pnpm build` it spawns has `tsup` write and delete `tsup.config.bundled_.mjs` at the root, and + * the override-gate case in `test/scripts/phi-scan.test.ts` appends to the tracked + * `phi-scan-overrides.md` and restores it. A snapshot taken inside one of those windows compares + * another file's leftovers, not the run's. The release Verify step on `d906bda` went red that way, + * with `.cosyte-usage-stdout/` in the "before" set and gone from the "after" one. So the file has a + * project of its own, with a later `sequence.groupOrder`: Vitest starts that group only after the + * group before it has finished, so nothing else is writing while the snapshot is taken. The + * assertion itself is unchanged. Do not answer a red from it by loosening the comparison or by + * moving the run into a temporary directory. A new test that has to see the tree while nothing + * else writes to it joins the second project; every other file stays in the first, which still + * runs in parallel. */ +const WORKING_TREE_SNAPSHOT = "test/conformance/working-tree-is-clean.test.ts"; + export default cosyteVitest({ coverageDirs: ["parser", "model", "model/types", "helpers", "serialize", "profiles", "builder", "edit"], test: { globals: false, environment: "node", - include: ["test/**/*.test.ts", "src/**/*.test.ts"], + // `extends: true` CONCATENATES `include` rather than replacing it, so the globs live on the + // first project only: set at the root, they would pull the whole suite into the second one. + projects: [ + { + extends: true, + test: { + name: "suite", + include: ["test/**/*.test.ts", "src/**/*.test.ts"], + exclude: [...configDefaults.exclude, WORKING_TREE_SNAPSHOT], + sequence: { groupOrder: 0 }, + }, + }, + { + extends: true, + test: { + name: "working-tree", + include: [WORKING_TREE_SNAPSHOT], + sequence: { groupOrder: 1 }, + }, + }, + ], }, });