mirror of https://github.com/astral-sh/ruff
## Summary Add lockfiles for all mdtests which make use of external dependencies. When running tests normally, we use this lockfile when creating the temporary venv using `uv sync --locked`. A new `MDTEST_UPGRADE_LOCKFILES` environment variable is used to switch to a mode in which those lockfiles can be updated or regenerated. When using the Python mdtest runner, this environment variable is automatically set (because we use this command while developing, not to simulate exactly what happens in CI). A command-line flag is provided to opt out of this. ## Test Plan ### Using the mdtest runner #### Adding a new test (no lockfile yet) * Removed `attrs.lock` to simulate this * Ran `uv run crates/ty_python_semantic/mdtest.py -e external/`. The lockfile is generated and the test succeeds. #### Upgrading/downgrading a dependency * Changed pydantic requirement from `pydantic==2.12.2` to `pydantic==2.12.5` (also tested with `2.12.0`) * Ran `uv run crates/ty_python_semantic/mdtest.py -e external/`. The lockfile is updated and the test succeeds. ### Using cargo #### Adding a new test (no lockfile yet) * Removed `attrs.lock` to simulate this * Ran `MDTEST_EXTERNAL=1 cargo test -p ty_python_semantic --test mdtest mdtest__external` "naively", which outputs: > Failed to setup in-memory virtual environment with dependencies: Lockfile not found at '/home/shark/ruff/crates/ty_python_semantic/resources/mdtest/external/attrs.lock'. Run with `MDTEST_UPGRADE_LOCKFILES=1` to generate it. * Ran `MDTEST_UPGRADE_LOCKFILES=1 MDTEST_EXTERNAL=1 cargo test -p ty_python_semantic --test mdtest mdtest__external`. The lockfile is updated and the test succeeds. #### Upgrading/downgrading a dependency * Changed pydantic requirement from `pydantic==2.12.2` to `pydantic==2.12.5` (also tested with `2.12.0`) * Ran `MDTEST_EXTERNAL=1 cargo test -p ty_python_semantic --test mdtest mdtest__external` "naively", which outputs a similar error message as above. * Ran the command suggested in the error message (`MDTEST_EXTERNAL=1 MDTEST_UPGRADE_LOCKFILES=1 cargo test -p ty_python_semantic --test mdtest mdtest__external`). The lockfile is updated and the test succeeds. |
||
|---|---|---|
| .. | ||
| corpus | ||
| mdtest | ||
| primer | ||
| README.md | ||
README.md
Markdown files within the mdtest/ subdirectory are tests of type inference and type checking;
executed by the tests/mdtest.rs integration test.
See crates/ty_test/README.md for documentation of this test format.