uv
ba7f370f - Add a declarative test framework

Commit
1 year ago
Add a declarative test framework While reviewing the index PRs, the tests all followed the same structure; they weren't so much test logic as a sequence of writing files, a test context command and snapshotting output and files. Instead of defining them in code, we can write them as toml scenarios: ```toml [[step]] input."pyproject.toml" = """ [...] """ command = "add" args = ["git+https://github.com/astral-test/uv-public-pypackage", "--tag=0.0.1"] output = """ [...] """ snapshot."pyproject.toml" = ''' [...] ''' snapshot."uv.lock" = ''' [...] ''' ``` The tests now have a shared schema and can be written without code. We can change the tests without recompiling and massively reduce the code size in the `uv` crate (previously, each time you would apply snapshot changes you would have to wait for a recompile). The tests become easier to maintain (toml can be edited by Python should need be) and by decoupling the test declaration from code we can add improve the test runner more easily. I don't expect all tests to be migrated, there's actual custom code in a number of tests. **Migration Strategy** Procedural and declarative tests can coexist in the same file, there is no breaking change involved. If we want to migrate existing test, we can move the existing testing to more concise abstractions using the `TestContext` with rust refactoring, then using regex to migrate many simple procedural tests.
Author
Committer
Parents
Loading