diff --git a/.changeset/gap-diff-base-limits-run.md b/.changeset/gap-diff-base-limits-run.md new file mode 100644 index 00000000..f446bf4e --- /dev/null +++ b/.changeset/gap-diff-base-limits-run.md @@ -0,0 +1,9 @@ +--- +'@tanstack/oracles': minor +--- + +`oracle-gaps --diff-base ` now judges only the mutants on lines changed since ``, for fast feedback after a change. Operator and authored mutants both count, and a mutant is on a changed line when any line from its first to its last is changed. Every line of a source file that git does not track is changed. The baseline still runs every test file that the run without the option runs, and each judged mutant gets the outcome it gets in the full run. An authored mutant that does not apply is reported on every run with the option, as it is without it. The run says so on its stream before the baseline, `oracle-gaps: note --diff-base : of mutants are on changed lines; the others are not judged in this run`, and in the same sentence in `summary.md`; `` counts the run without the option, with the same `--only` or `--sample`. Its `results.json` and `summary.md` inputs say `a partial run (--only, --sample, or --diff-base)`, as an `--only` or `--sample` run's do (their text used to read `(--only or --sample)`). Authored mutants are marked `inDiff` too. + +`oracle-gaps --diff-base ` refuses a revision that names no commit of the git repository that holds the package: a name git does not know, a range, a blob, an option such as `--cached`, an empty value, or a package in no repository. It exits 2 with `refused: --diff-base "" names no commit of the git repository that holds the package` and a `fix:` line, before any test runs. Before, the run went on and marked every mutant `inDiff: false`. `results.json` records the commit as `options.diffBase: { rev, commit }` (it was the revision as given), so the run identity follows the commit and not the name. + +Before, `--diff-base` only added `inDiff` to each operator mutant in `results.json`, and every mutant still ran. Run a full check without `--diff-base` to judge the other lines. diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml index 345e10c8..c9842dcb 100644 --- a/.github/workflows/pr.yml +++ b/.github/workflows/pr.yml @@ -373,12 +373,16 @@ jobs: uses: tanstack/config/.github/setup@e4b48f16568324f76f467aa4c2aac2f05db632c3 - run: pnpm --filter @tanstack/oracles run build # The same partition of the static oracle that Linux runs, by pattern. + # Vitest runs through node, not `pnpm exec`: on Windows the latter goes + # through cmd.exe, whose command line holds 8191 characters, and a + # shard's pattern of test names passed that with #290's tests ("The + # command line is too long"). - name: Gap report static oracle shell: bash working-directory: packages/oracles env: SHARD: ${{ matrix.shard }} - run: pnpm exec vitest --run --config oracle-gaps/vitest.config.mjs gap-report-static -t "$(node scripts/pr-shards.mjs pattern oracle-gaps-static-windows "$SHARD")" + run: node node_modules/vitest/vitest.mjs --run --config oracle-gaps/vitest.config.mjs gap-report-static -t "$(node scripts/pr-shards.mjs pattern oracle-gaps-static-windows "$SHARD")" windows-gap-classify: name: Windows gap report classify, probe-form, and mutant-validity oracles # Gated: runs when gaps changed (scripts/classify-changes.sh). @@ -426,7 +430,8 @@ jobs: env: SHARD: ${{ matrix.shard }} # The verbose reporter prints each test with its duration, which sizes the shards. - run: pnpm exec vitest --run --reporter=verbose --config oracle-gaps/vitest.config.mjs gap-report-oracle -t "$(node scripts/pr-shards.mjs pattern oracle-gaps-fixed-seed-windows "$SHARD")" + # Through node, not `pnpm exec`, for cmd.exe's command-line length (see the static job). + run: node node_modules/vitest/vitest.mjs --run --reporter=verbose --config oracle-gaps/vitest.config.mjs gap-report-oracle -t "$(node scripts/pr-shards.mjs pattern oracle-gaps-fixed-seed-windows "$SHARD")" windows-gap-cli: name: Windows gap CLI on a fixture # Gated: runs when framework or gaps changed (scripts/classify-changes.sh). diff --git a/packages/oracles/oracle-gaps/args.mjs b/packages/oracles/oracle-gaps/args.mjs index 010c8c51..37f2ca75 100644 --- a/packages/oracles/oracle-gaps/args.mjs +++ b/packages/oracles/oracle-gaps/args.mjs @@ -1,5 +1,6 @@ // The CLI's arguments, shared by the CLI (index.mjs) and the daemon // (daemon.mjs), which parses each request's arguments the same way. +import { spawnSync } from 'node:child_process' import { existsSync, readFileSync, readdirSync, statSync } from 'node:fs' import { randomBytes } from 'node:crypto' import { availableParallelism } from 'node:os' @@ -185,6 +186,12 @@ function optionsOf(args, cwd) { // Authored mutants are the author's files: one that cannot be read // refuses the run before any work. if (mutants) loadAuthored(mutants) + // The commit `--diff-base` names, resolved once: the run marks lines + // changed since that commit, and a name git does not know would mark none. + const diffBase = + args[`diff-base`] === undefined + ? undefined + : commitOf(pkg, `diff-base`, args[`diff-base`]) // Each source as the package names it (packagePath), a file of the // package. const sources = args.source.split(`,`).map((source) => { @@ -211,7 +218,7 @@ function optionsOf(args, cwd) { ), sources, seed: args.seed, - diffBase: args[`diff-base`], + diffBase, // Each run's output is a directory of its own under the package's state // in the OS temp directory (`stateDirOf`), so runs of one package and of // two packages never collide (maintainer decision, 2026-11-10: @@ -268,6 +275,26 @@ export function packagePath(pkg, path) { return posix(named) } +/** + * The commit that `rev`, the value of `--