From 5d9e73721a430d89f42f925048982df0fc3d638f Mon Sep 17 00:00:00 2001 From: DongHyeonka Date: Fri, 20 Nov 2026 13:26:02 +0900 Subject: [PATCH] =?UTF-8?q?build(app-bootstrap):=20test=EA=B0=80=20?= =?UTF-8?q?=EC=8A=B9=EC=9D=B8=20=EC=8A=A4=EB=83=85=EC=88=8F=20=ED=8C=8C?= =?UTF-8?q?=EC=9D=BC=EC=9D=84=20=EC=9E=85=EB=A0=A5=EC=9C=BC=EB=A1=9C=20?= =?UTF-8?q?=EC=84=A0=EC=96=B8=ED=95=9C=EB=8B=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit EnvelopeContractTest(ApprovalTests)는 만든 JSON을 시험 소스 옆 src/test/java/.../contract/approved/*.approved.txt와 비교한다. 그런데 Gradle은 src/test/java에서 .java만 컴파일하고 src/test/resources만 복사하므로 이 파일은 :app-bootstrap:test의 입력이 아니다. 그래서 기대하는 응답 모양을 바꾸려고 스냅숏만 고친 PR은 test가 캐시에서 와(또는 UP-TO-DATE로) 비교가 돌지 않고 초록이 된다. app build.gradle의 test에 src/test/java 아래 **/*.approved.*를 RELATIVE 입력 (approvedSnapshots)으로 선언한다. 같은 폴더의 *.received.*는 출력이라 넣지 않는다. 비교마다 쓰고, 통과하면 지우고, 실패하면 남는 파일이다. 다른 저장소 파일 트리 입력과 같이 폴더 항목은 지문에 넣지 않는다(ignoreEmptyDirectories). 버린 대안: - 스냅숏을 src/test/resources로 옮기고 PackageSettings ApprovalBaseDirectory로 가리키기: 파일이 옮겨 가고, 실패해 남은 received 파일이 resources에 남아 다음 실행의 classpath 입력이 된다. - src/test/java 폴더 전체를 입력으로: .java는 이미 컴파일 결과로 들어가고, received 파일이 키를 바꾼다. - build-logic 규약으로 모든 leaf에: ApprovalTests를 쓰는 leaf는 app 하나뿐이고, 전역 입력을 바꾸면 모든 leaf의 시험 캐시가 한 번에 깨진다. 위험·한계: - 입력은 test 태스크에만 있다. 다른 lane(Test 태스크)에 스냅숏 시험을 두면 그 lane에도 같은 입력이 필요하다. 지금 org.approvaltests를 쓰는 시험은 test lane의 EnvelopeContractTest 하나다. - 입력 속성이 새로 생겨 병합 뒤 첫 빌드에서 :app-bootstrap:test 캐시 키가 한 번 바뀐다. - 실패한 비교가 남기는 *.received.*는 .gitignore에 없다(이전부터, 이 변경 밖). 검증(desktop, 기준 77078ad0): - 탐침(같은 경로 새 checkout, 빈 캐시, :app-bootstrap:test 채움 → 다시 → 스냅숏 한 줄 바꿈): 변경 전은 바꾼 뒤에도 test FROM-CACHE rc=0, 변경 후는 test가 돌아 EnvelopeContractTest > successEnvelopeShape() FAILED rc=1. 되돌리면(received 파일은 남김) FROM-CACHE. - 깨끗한 worktree(트리 3bd57d82): scripts/verify.sh pr --no-cache rc=0(530 executed, 시험 7,269 실패 0), scripts/verify.sh main --no-cache rc=0(바깥 446 executed, 시험 1,980 실패 0). --- src/bootstrap/app/build.gradle | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/bootstrap/app/build.gradle b/src/bootstrap/app/build.gradle index d00bc45f..cfefa7b2 100644 --- a/src/bootstrap/app/build.gradle +++ b/src/bootstrap/app/build.gradle @@ -440,6 +440,18 @@ tasks.named('architectureTest', Test) { tasks.named('conditionalTransportBuildContractTest', Test) { inputs.file('build.gradle').withPathSensitivity(PathSensitivity.RELATIVE).withPropertyName('buildScript') } +// The ApprovalTests snapshot tests (EnvelopeContractTest) compare what they build with the +// *.approved.* files beside their sources. Gradle compiles only the .java files under src/test/java +// and copies only src/test/resources, so without this input a change to a snapshot alone left `test` +// up to date or let it come from the build cache: the comparison did not run and the build passed. +// The .received.* files next to them are output, not input: every comparison writes one, a passing +// comparison deletes it and a failing one leaves it behind. +tasks.named('test', Test) { + inputs.files(fileTree('src/test/java') { include '**/*.approved.*' }) + .withPathSensitivity(PathSensitivity.RELATIVE) + .ignoreEmptyDirectories() + .withPropertyName('approvedSnapshots') +} // Fast developer test lane. Whole-repository ArchUnit graphs and full composition-root boot // characterizations have their own source sets, so the ordinary lane does not compile or execute -- 2.54.0