Files
clean-architecture-frontend…/scripts/test-feature-scaffold.ts
T
DongHyeonka f08c93ab2e fix(removal): 문서를 읽는 테스트 제외 목록을 모든 제거 드릴이 같이 쓴다
문제
FE-GATE-020의 제거 드릴은 정해진 목록만 fixture에 복사하고, 그 목록에
README.md·CHANGELOG.md·docs/가 없다. 그런데 fixture에서 도는 test:all에는
그 문서를 읽는 테스트 두 개(documentation-readiness,
changelog-review-ids)가 들어 있다. sample-removal 드릴만 두 테스트를
지웠고, browser-file-storage·realtime·optional-recipe 드릴은 제거 대상과
무관하게 `test` 검사에서 ENOENT로 항상 실패했다. 세 드릴의 실패는 merge
게이트를 빨갛게 하고 release 단계도 막는다.

고른 방법
- scripts/lib/removal-fixture.ts에 문서 목록
  (REMOVAL_FIXTURE_DOCUMENT_TARGETS)과 그 문서를 읽는 테스트 목록
  (REMOVAL_FIXTURE_DOCUMENT_TESTS)을 한 번만 둔다. prepareRemovalFixture는
  문서를 복사하지 않은 fixture에서 그 테스트를 지운다. 문서를 복사하는
  드릴(test:feature-scaffold)에서는 그대로 돈다.
- sample-removal 드릴의 자체 제외 두 줄을 지운다.
- 버린 대안: 모든 드릴이 문서까지 복사. capability 드릴은 문서가
  설명하는 runtime을 지우므로, 문서 테스트가 지운 경로를 실패로 본다.
  드릴마다 문서 예외가 필요해진다. 드릴마다 제외를 복사. 지금 고장의
  원인(갈라진 목록)을 되풀이한다.
- 단위 테스트가 목록을 고정한다: 문서 없이 복사하면 제외, 문서를
  복사하면 제외 없음, 제외 대상이 실제로 문서를 읽음, 다섯 드릴이 모두
  prepareRemovalFixture를 쓰고 자체 제외 목록을 두지 않음.

위험·한계
- 저장소 루트 문서를 읽는 테스트가 더 생기면 이 목록에 더해야 한다.
  더하지 않으면 capability 드릴이 다시 ENOENT로 실패한다(조용히 통과하지는
  않는다).
- 세 드릴의 실제 실행 결과는 이 커밋 메시지에 적지 않았다(공유 잠금 대기).

검증
- RED: 새 테스트 "is the only exclusion list"가 수정 전 sample 드릴의 자체
  목록 때문에 실패.
- tests/unit/removal-fixture.test.ts 12건 통과, 바꾼 파일 eslint 통과.

Refs: docs/reviews/2026-11-03-maturity-review/02-adapters-browser-files-cache.md 02-06
2026-11-04 21:01:33 +09:00

78 lines
2.9 KiB
TypeScript

import { mkdir, rm, writeFile } from "node:fs/promises";
import {
createRemovalFixtureRoot,
prepareRemovalFixture,
REMOVAL_FIXTURE_COPY_TARGETS,
REMOVAL_FIXTURE_DOCUMENT_TARGETS,
renderRemovalJunit,
requireRemovalFixtureEnvironment,
runRemovalFixtureCheck,
sealRemovalFixtureRepository,
type RemovalCheck,
} from "./lib/removal-fixture.ts";
/**
* U7. A feature from `create:feature` passes the merge gates without an edit
* and breaks no other test. A copy of the repository, sample feature
* included, gets one generated feature and then runs the gates.
* test:sample-removal repeats the generation after deleting the sample
* (decision 4), which proves the command needs nothing from it.
*/
const FEATURE_ID = "scaffold-feature";
const REPORT = "artifacts/tests/feature-scaffold.xml";
const pnpmCli = requireRemovalFixtureEnvironment("npm_execpath");
const fixtureRoot = await createRemovalFixtureRoot("feature-scaffold");
function check(name: string, script: string, extra: readonly string[] = []): RemovalCheck {
return runRemovalFixtureCheck(name, fixtureRoot, pnpmCli, script, extra);
}
try {
// verify:documentation and the documentation tests read these.
await prepareRemovalFixture(fixtureRoot, [
...REMOVAL_FIXTURE_COPY_TARGETS,
...REMOVAL_FIXTURE_DOCUMENT_TARGETS,
]);
const created = check("create-feature", "create:feature", [FEATURE_ID]);
const checks: RemovalCheck[] = [created];
if (created.passed) {
// Commits the copy with the feature, as a project would: git-based
// checks (git grep, git ls-files) then see the feature's files.
sealRemovalFixtureRepository(fixtureRoot);
checks.push(
check("typecheck", "check:types"),
check("lint", "lint"),
check("architecture", "check:architecture"),
check("registries", "check:registries"),
check("i18n", "check:i18n"),
check("design-system", "check:design-system"),
check("diagnostics", "check:diagnostics"),
check("documentation", "verify:documentation"),
check("unit", "test:unit"),
check("component", "test:component"),
check("integration", "test:integration"),
check("features", "exec", ["node", "scripts/run-vitest.ts", "run", "tests/features"]),
check("coverage", "test:coverage"),
check("ci-contract", "check:ci"),
check("build", "build"),
);
}
const failed = checks.filter((entry) => !entry.passed);
await mkdir("artifacts/tests", { recursive: true });
await writeFile(REPORT, renderRemovalJunit("feature-scaffold", checks));
if (failed.length > 0) {
process.stderr.write(
`feature scaffold failed:\n${failed
.map((entry) => ` ${entry.name}: ${entry.failure ?? "failed"}`)
.join("\n")}\n`,
);
process.exitCode = 1;
} else {
process.stdout.write(`feature scaffold: PASS (${checks.length} checks)\n`);
}
} finally {
await rm(fixtureRoot, { recursive: true, force: true });
}