문제 --with-create(NEVER)와 --with-create --keyed(KEYED)가 만드는 코드는 단위 테스트가 텍스트로만 본다. FE-GATE-020의 두 드릴(test:feature-scaffold, test:sample-removal)은 기본 기능 하나만 만들어 게이트를 돈다. 그래서 쓰기 slice의 타입·lint·테스트·빌드가 머지 게이트에서 깨져도 모른다(16 5.3절의 "생성 결과를 매번 게이트로 돌린다"는 전제). 고른 방법 - scripts/test-feature-scaffold.ts: 기본 기능(scaffold-feature) 옆에 scaffold-write-feature를 --with-create --keyed로 하나 더 만들고, 둘 다 만들어졌을 때 같은 게이트를 한 번 돈다. 바꾼 것은 WRITE_FEATURE_ID 상수, create-feature-write 검사 한 개, 게이트 조건(created && createdWrite), 머리 주석이다. - scripts/test-sample-removal.ts: 참조 기능을 지운 복사본의 create:feature 인자에 --with-create 한 개를 더했다. 쓰기 slice도 샘플에 기대지 않는다는 증거다. - 세 변형(기본, NEVER, KEYED)이 모두 드릴의 게이트를 지난다. - reference/create-feature.md의 드릴 설명을 맞췄다. 버린 대안 - 드릴 기능 하나를 --with-create로 바꾸기: 기본 변형이 게이트에서 빠진다. 위험·한계 - test:feature-scaffold는 기능 하나만큼(create:feature 한 번과 그 기능의 테스트) 길어진다. 게이트는 한 번만 돈다. - 다른 작업(게이트 담당)이 같은 두 파일의 명령 목록을 고칠 수 있다. 내 수정은 위 줄로 좁혔다. 검증 - flock 아래 CHOKIDAR_USEPOLLING=1 corepack pnpm test:feature-scaffold: rc=0, "feature scaffold: PASS (17 checks)" (생성 2 + 게이트 15), 162초. - 같은 조건 corepack pnpm test:sample-removal: rc=0, "reference-feature removal: PASS (23 checks, no fixture IDs)". 참조 기능을 지운 복사본에서 --with-create 기능을 만든 뒤 scaffold-* 게이트 9개가 모두 통과했다. 첫 실행은 tests/unit/create-feature.test.ts에 샘플 ID 문자열이 있어 fixture-id-residue로 실패했고, 그 테스트를 앞 커밋에서 고친 뒤 통과했다. Refs: docs/reviews/2026-11-03-maturity-review/09-app-core.md 09-06 Refs: docs/reviews/2026-11-03-maturity-review/16-structure-patterns.md 16-01
87 lines
3.2 KiB
TypeScript
87 lines
3.2 KiB
TypeScript
import { mkdir, rm, writeFile } from "node:fs/promises";
|
|
|
|
import {
|
|
createRemovalFixtureRoot,
|
|
prepareRemovalFixture,
|
|
REMOVAL_FIXTURE_COPY_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 a default feature and a `--with-create --keyed` one, 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";
|
|
/** 1103/09-06. The `--with-create --keyed` slice, in its own context. */
|
|
const WRITE_FEATURE_ID = "scaffold-write-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,
|
|
"README.md",
|
|
"CHANGELOG.md",
|
|
"docs",
|
|
]);
|
|
const created = check("create-feature", "create:feature", [FEATURE_ID]);
|
|
const createdWrite = check("create-feature-write", "create:feature", [
|
|
WRITE_FEATURE_ID,
|
|
"--with-create",
|
|
"--keyed",
|
|
]);
|
|
const checks: RemovalCheck[] = [created, createdWrite];
|
|
if (created.passed && createdWrite.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 });
|
|
}
|