Round 10 adjudicated the wiring disagreement in the previous commit's favour (round 9's proposed assertions are green against both mutations; the structural argument holds), found no blocker and no HIGH, and then found that the previous commit had introduced a measured falsehood while writing that argument down. "Both (3) and (4) are fail-noisy" is false for (3). MEASURED, and reproduced here before fixing: a union-preserving mispartition in the plugin — move `src/components/` out of `tracked` and append it to `others` — hides a planted `pageSize: 100` in `src/components/bugPreview.tsx` with the whole suite green (43/43), where the same plant without the mutation reddens with `UNREGISTERED (1)`. Round 7 had already measured this and I wrote the opposite anyway. Why it matters more than a wording slip: fail-DIRECTION is the entire argument for tolerating a residual rather than closing it. A reader deciding whether (3) deserves work would have read "cannot hide a call site" — which is exactly the inference this issue exists to prevent. Two neighbouring sentences contradicted it in the same file, which is how it survived my own read. The residual list now states five, with their directions separated: (1), (2), (4) and (5) are fail-noisy — they redden a checkout and cannot hide a call site — while (3) is blind, tolerated only because nothing a CONSUMER computes can see it (the union it compares is unchanged), and answered by testing the derivation directly. The real-git tests that answer it catch an unconditional mispartition, not one keyed on a path pattern, and now say so. Also from round 10: - The list said "Three residuals" and enumerated four; `ABSENT_FROM_DISK` was a fifth, documented only at its declaration. Five, listed. - "No assertion can tell which is passed" was broader than measured: a `listSourceFiles.toString()` assertion DOES redden one of the two mutations. It is rejected rather than impossible — a text snapshot of one's own source is the hand-written-mirror shape this file spent nine rounds removing, and it misses the other mutation. Both places now say "no assertion comparing the two populations", with the reason. - The cross-check message said the shortfall test is "above"; it is below. This branch's own sweep of stale directional pointers missed it. - "Excluded for DIFFERENT reasons" survived above the text retracting exactly that framing. The reasons OVERLAP — both files need the binary, one also needs a checkout — and reading them as separate is what produced the round-8 blocker. - `vite-env.d.ts` claimed a renamed field always fails loudly; true for `tracked` and `others`, silent for `absentFromDisk`. - The realgit non-repo test asserts a message the missing-binary path also emits, so it passes for the wrong reason where git is absent — recorded, since that is the environment the file is excluded from. - A blank line had made the guard-inventory scope list render loose. Refs: #819
94 lines
4.6 KiB
TypeScript
94 lines
4.6 KiB
TypeScript
import { execFileSync } from 'node:child_process';
|
|
import { mkdirSync, mkdtempSync, rmSync, writeFileSync } from 'node:fs';
|
|
import { tmpdir } from 'node:os';
|
|
import { join } from 'node:path';
|
|
import { afterAll, describe, expect, it } from 'vitest';
|
|
import { type GitRunner, resolveTrackedSourceFiles } from './trackedSourceFiles';
|
|
|
|
/**
|
|
* SEPARATE FILE because these are the only tests in the SPA suite that need the `git` BINARY, not
|
|
* merely a checkout (ersatztv#819).
|
|
*
|
|
* `docker/Dockerfile`'s web-build stage runs on `node:22-bookworm-slim`, which ships no git at all,
|
|
* so this file is excluded there alongside the guard that needs an index. Keeping them apart means
|
|
* that exclusion costs two files rather than the thirteen injected-runner tests in
|
|
* `trackedSourceFiles.test.ts`, which run fine with no git and no repository.
|
|
*
|
|
* Do NOT make these skip when git is missing. A check that answers "could not tell" by passing is a
|
|
* permanent no-op, which is the whole failure mode this plugin exists to avoid.
|
|
*/
|
|
describe('resolveTrackedSourceFiles against a REAL repository (#819)', () => {
|
|
// Every test in the sibling `trackedSourceFiles.test.ts` injects a fake `GitRunner`, which proves
|
|
// the derivation's SHAPE and never that
|
|
// it works against git. `scripts/tests/test_guard_populations_derive_from_git.py` makes exactly
|
|
// this point about its own primitive — "It proves the mechanism by EXECUTING it rather than by
|
|
// recognising its shape — no monkeypatching, no stand-in for git" — and the population this
|
|
// plugin feeds is asserted for completeness, so it earns the same treatment.
|
|
const repos: string[] = [];
|
|
|
|
afterAll(() => {
|
|
for (const dir of repos) {
|
|
rmSync(dir, { recursive: true, force: true });
|
|
}
|
|
});
|
|
|
|
function repoWithOneTrackedAndOneUntracked(): string {
|
|
const dir = mkdtempSync(join(tmpdir(), 'etv-819-'));
|
|
repos.push(dir);
|
|
const git = (...args: string[]) => execFileSync('git', ['-C', dir, ...args], { encoding: 'utf8' });
|
|
|
|
git('init', '-q');
|
|
mkdirSync(join(dir, 'src'), { recursive: true });
|
|
writeFileSync(join(dir, 'src', 'tracked.ts'), 'export const a = 1;\n');
|
|
writeFileSync(join(dir, 'src', 'untracked.ts'), 'export const b = 2;\n');
|
|
// STAGED, not committed. `ls-files` reads the INDEX, so a commit adds nothing — and committing
|
|
// makes the fixture depend on the developer's global git config: under a `commit.gpgsign = true`
|
|
// that many people set, `git commit` fails and these tests go red on their machine while CI
|
|
// stays green. That is the very shape #819 exists to remove, so it must not be reintroduced by
|
|
// #819's own tests. `git add` is unaffected by signing.
|
|
git('add', 'src/tracked.ts');
|
|
return dir;
|
|
}
|
|
|
|
it('really separates a tracked file from an identical untracked sibling', () => {
|
|
const result = resolveTrackedSourceFiles(repoWithOneTrackedAndOneUntracked());
|
|
|
|
expect(result.tracked).toEqual(['src/tracked.ts']);
|
|
expect(result.others).toEqual(['src/untracked.ts']);
|
|
expect(result.absentFromDisk).toEqual([]);
|
|
});
|
|
|
|
it('really reports a tracked file deleted from the working tree as absent', () => {
|
|
const dir = repoWithOneTrackedAndOneUntracked();
|
|
rmSync(join(dir, 'src', 'tracked.ts'));
|
|
|
|
const result = resolveTrackedSourceFiles(dir);
|
|
|
|
expect(result.tracked).toEqual(['src/tracked.ts']);
|
|
expect(result.absentFromDisk).toEqual(['src/tracked.ts']);
|
|
});
|
|
|
|
// Residual: this asserts the message the MISSING-BINARY path also emits, so in an environment with
|
|
// no git it passes for the wrong reason. Not silent overall — its two siblings fail ENOENT there,
|
|
// loudly — and that is exactly the environment this file is excluded from in `docker/Dockerfile`.
|
|
it('really throws outside a repository, rather than returning an empty population', () => {
|
|
const notARepo = mkdtempSync(join(tmpdir(), 'etv-819-bare-'));
|
|
repos.push(notARepo);
|
|
mkdirSync(join(notARepo, 'src'), { recursive: true });
|
|
|
|
// `GIT_CEILING_DIRECTORIES` stops git walking up into an enclosing repository — without it this
|
|
// test depends on where TMPDIR happens to point, and reports the wrong throw when TMPDIR sits
|
|
// inside a checkout.
|
|
const ceiling: GitRunner = (args) =>
|
|
execFileSync('git', [...args], {
|
|
encoding: 'utf8',
|
|
// Same stderr suppression `runGitDefault` sets, for the same reason: without it git's own
|
|
// `fatal: not a git repository` prints on every run of this file.
|
|
stdio: ['ignore', 'pipe', 'pipe'],
|
|
env: { ...process.env, GIT_CEILING_DIRECTORIES: tmpdir() }
|
|
});
|
|
|
|
expect(() => resolveTrackedSourceFiles(notARepo, ceiling)).toThrow(/could not read the git index/);
|
|
});
|
|
});
|