test: clean up tests writing to tracked files, prevent future violations - #14772
Open
Kha wants to merge 4 commits into
Open
test: clean up tests writing to tracked files, prevent future violations#14772Kha wants to merge 4 commits into
Kha wants to merge 4 commits into
Conversation
This PR stops the test suite from leaving scratch files inside the tracked source tree, so that a test run no longer shows up as a dirty working copy. The `ltarStable` Lake test now copies its package into `work/` (already ignored, and the idiom `srcHash` uses) instead of appending a comment to the tracked `Test/A.lean` and dropping `out*.jsonl`, `bundles*.txt`, `staging/` and `Test/A.lean.bak` next to it. The two `compact_closure` compile tests adopt the `_tmp_` prefix that `tests/compile/.gitignore` documents. The remaining cases are cleanup targets that no ignore rule covered: `manifest/lake-packages`, `toml/toml-test`, `bench/size/install`, `clone/lean-toolchain`, `init/mathlib_standards` and `rebuild/Foo/`. Scratch `produced.*` output under `tests/pkg` is now covered by one rule in `tests/pkg/.gitignore` rather than per-package copies. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This PR stops several Lake tests from editing files inside the checked-in source tree, so that a test run no longer shows up as a dirty working copy. `copy_to_work` in `tests/lake/tests/common.sh` replaces the copy-into-`work/` preamble seven tests had spelled out, and additionally makes the copies writable, since `cp` propagates the source mode. `shake` and `updateUnknown` move onto it too: `shake` copied `input/*` over its own test directory, which had left `DepMain.lean` tracked because `.gitignore` transposed the name to `MainDep.lean`, and `updateUnknown` rewrote its tracked `lakefile.toml` in place and leaked `lakefile.toml.bak` whenever a run died before the restoring `mv`. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This PR makes CI fail when a test writes into the checked-in source tree, so that scratch output has to go to an ignored path instead. Tracked files are made read-only for the duration of the test run, and `git status` is compared before and after it. The two halves catch different things: the comparison finds byproducts a test leaves behind, while the read-only bit also catches a test that edits a tracked file and restores it afterwards, which the comparison cannot see. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
The Windows job runs the test suite as well, and MSYS2 honors `chmod`; `tests/lake/tests/cache` already relies on that. The tree comparison never needed the exemption at all, it only inherited it because `tree-before` is captured in the `chmod` step. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes even more tests writing to tracked files, which can create a mess with version control. Makes tracked files read-only during CI test runs and checks for new untracked and non-ignored files afterwards to prevent future violations.