From 3917dc017470240321bd1d8454998d99d372c1c0 Mon Sep 17 00:00:00 2001 From: DongHyeonka Date: Fri, 20 Nov 2026 13:26:54 +0900 Subject: [PATCH] =?UTF-8?q?build(app-bootstrap):=20test=EA=B0=80=20Approva?= =?UTF-8?q?lTests=20=EC=8A=A4=ED=81=AC=EB=A6=BD=ED=8A=B8=EB=A5=BC=20GitHub?= =?UTF-8?q?=EC=97=90=EC=84=9C=20=EB=82=B4=EB=A0=A4=EB=B0=9B=EC=A7=80=20?= =?UTF-8?q?=EC=95=8A=EB=8A=94=EB=8B=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit :app-bootstrap:test가 EnvelopeContractTest를 돌리면 ApprovalTests 31.0.0이 GitHub 저장소 ApprovalTests.CommonScripts의 main 브랜치에서 approve_all.py와 remove_abandoned_files.py를 받아 leaf 폴더 .approval_tests_temp/에 실행 권한으로 쓴다(LoggingUtils.downloadScriptIfMissing, 3초 시한, 실패는 삼킨다). 시험이 바깥 네트워크에 기대고, 고정되지 않은 내용이 실행 파일로 소스 폴더에 남는다. 또 실패한 승인 비교가 시험 소스의 approved/ 폴더 안에 남기는 *.received.* 파일을 Git이 무시하지 않아 git add -A로 커밋될 수 있다. app-bootstrap의 모든 Test 태스크(tasks.withType(Test).configureEach)에 환경 변수 APPROVALTESTS_DISABLE_SCRIPT_DOWNLOADS=1을 준다. 라이브러리가 내려받기를 끄는 길은 이 환경 변수 하나다(시스템 속성·PackageSettings 칸이 없다). test만이 아니라 모두에 주는 이유: tag lane 셋(documentContractTest·repositoryContractTest·publicPathSnapshotTest)이 같은 test source set의 클래스를 고르고, architectureTest의 실행 classpath에도 ApprovalTests가 있다. 환경 변수는 Test 태스크의 캐시 입력이 아니라(@Internal) 캐시 키는 그대로다. 루트 .gitignore는 Java 소스 폴더 아래의 received 파일만 무시한다 (src/**/src/*/java/**/*.received.*). 다른 곳의 fixture 이름(예: test/resources 아래 payment.received.json 같은 이름)은 가리지 않는다. approved 스냅숏은 매개변수가 이름에 ".received."를 넣어도 무시하지 않는다(!src/**/src/*/java/**/*.approved.*). 버린 대안: - 프로젝트 폴더(APPROVALTESTS_PROJECT_DIRECTORY)를 build/ 아래로 옮기고, 스냅숏 소스 찾기를 ContractSnapshots.verify로 바꾸기: 라이브러리는 같은 폴더를 시험 소스를 찾는 뿌리로도 쓴다. 파생 서비스가 Approvals.verify를 직접 부르는 새 시험을 쓰면 스냅숏을 못 찾고 실패한다. 남는 폴더(.gitignore와 로그 둘)는 저장소 파일 트리 입력이 이미 빼고(**/.approval_tests_temp/**), 라이브러리가 그 안에 쓰는 .gitignore(*)로 Git도 무시한다. - test 태스크에만 환경 변수: 같은 클래스를 고르는 tag lane에는 닿지 않는다. - .gitignore에 *.received.* 한 줄: 저장소 어디서든 이름에 ".received."가 든 fixture를 가린다. 위험·한계: - 라이브러리는 스크립트가 없을 때만 받는다. 이미 시험을 돌린 checkout에는 받아 둔 두 .py가 .approval_tests_temp/를 지울 때까지 남는다. - Gradle 설정 없이 IDE의 JUnit runner로 돌리면 여전히 내려받는다. - 매개변수가 이름에 ".approved."를 넣은 received 파일은 무시되지 않고 git status에 보인다(approved 스냅숏을 가리지 않는 쪽을 골랐다). 검증(desktop, 기준 442712ee = main): - 탐침(docker --network none / bridge, 빈 캐시): main 트리 3bd57d82는 offline :app-bootstrap:test rc=0, online --rerun 뒤 leaf .approval_tests_temp/에 approve_all.py·remove_abandoned_files.py(mode 744)가 생기고, 스냅숏 한 줄을 바꿔 실패시키면 received 파일이 git status에 ?? 로 보인다. 이 트리 7aac4cee는 offline rc=0, online --rerun 뒤 .py가 없고 폴더에는 .gitignore와 로그 둘만, git status --porcelain이 비어 있다. 실패시키면 git status에는 바꾼 approved 파일만 보인다. 설정 단계에서 leaf의 Test 태스크 여덟 모두 환경 변수가 1이다(main은 모두 null). - 깨끗한 worktree(트리 7aac4cee): scripts/verify.sh pr --no-cache rc=0(530 executed, FROM-CACHE 0, 시험 7,269 실패 0), scripts/verify.sh main --no-cache rc=0(바깥 446 executed·FROM-CACHE 0, 시험 1,980 실패 0). --- .gitignore | 8 ++++++++ src/bootstrap/app/build.gradle | 21 ++++++++++++++++++--- 2 files changed, 26 insertions(+), 3 deletions(-) diff --git a/.gitignore b/.gitignore index 122dbbe7..ae53be55 100644 --- a/.gitignore +++ b/.gitignore @@ -11,6 +11,14 @@ build/ .settings/ # jqwik property-test runtime state .jqwik-database +# ApprovalTests writes .received. next to each .approved. snapshot, under the +# test's source folder, when it compares and deletes it when they match; a failed comparison leaves +# it behind. Approve by copying it over the approved file, never by committing it. Only Java source +# folders: fixtures elsewhere may carry ".received." in their names. An approved snapshot is never +# ignored, even when a test parameter puts ".received." into its name; in turn a received file whose +# parameter puts ".approved." into its name shows up in `git status`. +src/**/src/*/java/**/*.received.* +!src/**/src/*/java/**/*.approved.* .DS_Store # Local Claude Code state (worktrees, settings.local.json, notes) stays out. The shared project # settings, path rules, skills and subagent definitions are committed: everyone who opens the repository gets them (CLAUDE.md). diff --git a/src/bootstrap/app/build.gradle b/src/bootstrap/app/build.gradle index cfefa7b2..4bf8e1e7 100644 --- a/src/bootstrap/app/build.gradle +++ b/src/bootstrap/app/build.gradle @@ -347,9 +347,9 @@ def repositoryRootForContractTests = rootProject.projectDir // fresh checkout (the files carry their source's modification time). // Every whole-repository file-tree input below also leaves directories out: Gradle then drops every // directory entry, not only empty ones, and keeps the files. :app-bootstrap:test writes -// .approval_tests_temp/ here (ApprovalTests' .gitignore, logs and the scripts it downloads) when it -// executes, not when it comes from the cache, so the architecture and repository-contract keys -// followed whether the same build had executed `test`, and a pull request missed main's entries. +// .approval_tests_temp/ here (ApprovalTests' .gitignore and logs) when it executes, not when it comes +// from the cache, so the architecture and repository-contract keys followed whether the same build +// had executed `test`, and a pull request missed main's entries. // No include reaches those files today; the exclude keeps it that way when an include widens. // These lanes judge files, not directories. The one directory rule, no subdirectory and no unknown // file under docs/registries, keeps its own input (registryCatalog). @@ -452,6 +452,21 @@ tasks.named('test', Test) { .ignoreEmptyDirectories() .withPropertyName('approvedSnapshots') } +// ApprovalTests (EnvelopeContractTest) writes its logs to .approval_tests_temp/ in this leaf, the +// working directory, on every comparison. Unless told not to, it also downloads two helper scripts +// (approve_all.py, remove_abandoned_files.py) from the main branch of a GitHub repository into the +// same folder and marks them executable (org.approvaltests.internal.logs.LoggingUtils): the test +// reached outside the network and left unpinned fetched executables in the source tree. The library +// reads only this environment variable for it, no system property or package setting. Every Test +// task of this leaf gets it, not only `test`: the tag lanes run classes of the same source set and +// architectureTest has its runtime classpath, ApprovalTests included. The folder and its logs stay: +// Git ignores them (the library writes a .gitignore of `*` there) and the whole-repository inputs +// above exclude them. The library fetches a script only when it is missing, so a checkout that ran +// the tests before keeps the two it fetched until .approval_tests_temp/ is removed. A run from an +// IDE, without this setting, still downloads them. +tasks.withType(Test).configureEach { + environment 'APPROVALTESTS_DISABLE_SCRIPT_DOWNLOADS', '1' +} // 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