FE-GATE-029는 check:design-system:fixture와 check:diagnostics:fixture가 exit 1과 머리말을 내면 통과로 센다. 거절된 파일이 하나만 있어도 그 조건이 채워진다. 그래서 검사기에서 진짜 규칙(TSX의 raw palette·hue mix·inline style, direct console·민감 context)을 지워도 029가 초록이었다. fixture 폴더에서만 도는 표식 규칙(TOOLTIP_ONLY_REQUIRED_INFORMATION, UNKNOWN_DIAGNOSTIC_EVENT)이 자기 파일을 늘 거절했기 때문이다. check-i18n.ts가 하던 파일별 판정을 scripts/lib/fixture-rejection.ts로 옮기고 세 검사기가 같이 쓴다. fixture 모드에서 어느 failure도 이름을 대지 않는 fixture 파일이 있거나 fixture 파일이 하나도 없으면, 그 목록을 찍고 exit 2로 끝난다. 029는 exit 1을 기대하므로 실패한다. 파일 이름은 경로 경계로 맞춘다(a.ts가 a.tsx·b/a.ts에 맞지 않는다). i18n 판정은 endsWith에서 이 판정으로 바뀌어 조금 엄격해진다. 표식 규칙 둘을 지운다. tooltip-only.tsx는 그 표식 말고 거절할 규칙이 없어 지운다. headless-vendor-import.tsx·hue-mix.tsx를 더하고, raw-palette.tsx는 inline style 없이 SVG fill로 바꿔 fixture 하나가 규칙 하나에 걸리게 한다. direct-console.ts에서는 표식 문자열을 뺀다. fe-design-system 스킬이 지운 tooltip 규칙을 있는 것처럼 적던 줄도 고친다. 버린 안: gates.json의 expectedDiagnosticId를 규칙 문구로 좁히기. 항목 범위가 029 정의를 바꾸지 말라고 하고, 규칙이 여럿이라 문구 하나로는 다 못 본다. 한계: 파일마다 「failure가 하나라도 있는지」를 본다. fixture 하나에 서로 다른 규칙 둘이 걸리면 하나를 지워도 다른 하나가 거절한다. 지금 fixture는 규칙 하나씩이고 시험이 failure 목록을 그대로 단언하지만, 새 fixture에 그것을 강제하지는 않는다. check-i18n.ts가 helper를 부르는지 단언하는 시험은 없다(main에도 없다). 시험: design-system-rules.test.ts·fixture-rejection.test.ts가 임시 root에서 검사기를 돌려, fixture마다 기대한 failure만 나오는지와 거절되지 않는 파일을 더하면 exit 2와 그 파일이 찍히는지 본다. helper는 경로 경계· 빈 폴더를 단위로 본다. timeout은 desktop에서 잰 가장 긴 값(test:unit 1,038 ms)이다. design-system 쪽 두 시험(가장 긴 719 ms)은 기존 describe의 3,540 ms 안이다. RED·GREEN은 PR 본문에 적는다. Refs: REV-FE-0002
44 lines
1.9 KiB
TypeScript
44 lines
1.9 KiB
TypeScript
// A `*:fixture` command passes when its checker exits 1 and prints its header
|
|
// (scripts/lib/ci-step-result.ts). One rejected file is enough for that, so a
|
|
// rule deleted from the checker hides behind the files that other rules still
|
|
// reject. A checker in fixture mode therefore asks that every fixture file is
|
|
// named by a failure of its own, and exits 2 when one is not: exit 2 is not
|
|
// the exit 1 the gate expects, so FE-GATE-029 fails (REV-FE-0002).
|
|
|
|
/**
|
|
* Whether `failure` names `file` as a whole path: at the start or after
|
|
* white space, and followed by the end, white space or `:` (a line number).
|
|
* `a.ts` is not named by a failure about `a.tsx` or `b/a.ts`.
|
|
*/
|
|
export function failureNamesFile(failure: string, file: string): boolean {
|
|
for (let at = failure.indexOf(file); at !== -1; at = failure.indexOf(file, at + 1)) {
|
|
const before = at === 0 ? "" : failure[at - 1];
|
|
const after = failure[at + file.length] ?? "";
|
|
if ((before === "" || /\s/.test(before)) && (after === "" || /[\s:]/.test(after))) return true;
|
|
}
|
|
return false;
|
|
}
|
|
|
|
/** The fixture files that no failure names. */
|
|
export function unrejectedFixtureFiles(
|
|
fixtureFiles: readonly string[],
|
|
failures: readonly string[],
|
|
): string[] {
|
|
return fixtureFiles.filter((file) => !failures.some((failure) => failureNamesFile(failure, file)));
|
|
}
|
|
|
|
/**
|
|
* The text a checker prints before it exits 2, or `undefined` when every
|
|
* fixture file is rejected. No fixture file at all is refused too: an empty or
|
|
* moved fixture folder must not pass as "every file rejected".
|
|
*/
|
|
export function fixtureRejectionFailure(
|
|
checker: string,
|
|
fixtureFiles: readonly string[],
|
|
failures: readonly string[],
|
|
): string | undefined {
|
|
const unrejected = unrejectedFixtureFiles(fixtureFiles, failures);
|
|
if (fixtureFiles.length > 0 && unrejected.length === 0) return undefined;
|
|
return `${checker} fixture was not rejected:\n${unrejected.join("\n") || "(no fixture files found)"}\n`;
|
|
}
|