uv/scripts
konsti e6103dcab1
Deduplicate test command creation (#4512)
This PR refactors the command creation in the test suite to remove the
duplication.

**1)** We add the same set of test stubbing args to almost any uv
invocation in the tests:

```rust
command
    .arg("--cache-dir")
    .arg(self.cache_dir.path())
    .env("VIRTUAL_ENV", self.venv.as_os_str())
    .env("UV_NO_WRAP", "1")
    .env("HOME", self.home_dir.as_os_str())
    .env("UV_TOOLCHAIN_DIR", "")
    .env("UV_TEST_PYTHON_PATH", &self.python_path())
    .current_dir(self.temp_dir.path());

if cfg!(all(windows, debug_assertions)) {
    // TODO(konstin): Reduce stack usage in debug mode enough that the tests pass with the
    // default windows stack of 1MB
    command.env("UV_STACK_SIZE", (8 * 1024 * 1024).to_string());
}
```

Centralizing these into a `TestContext::add_shared_args` method removes
them from everywhere.

**2)** Prefix all `TextContext` methods of the pip interface with
`pip_`. This is now necessary due to `uv sync` vs. `uv pip sync`.

**3)** Move command creation in the various test files into dedicated
functions or methods to avoid repeating the arguments. Except for error
message tests, there should be at most one `Command::new(get_bin())`
call per test file. `EXCLUDE_NEWER` is exclusively used in
`TestContext`.

---

I'm considering adding a `TestCommand` on top of these changes (in
another PR) that holds a reference to the `TextContext`, has
`add_shared_args` as a method and uses `Fn(Self) -> Self` instead of
`Fn(&mut Self) -> Self` for methods to improved chaining.
2024-06-25 22:06:54 +00:00
..
bench Expand documentation in scripts/bench/__main__.py (#2875) 2024-04-08 02:48:12 +00:00
benchmarks Rename to uv (#1302) 2024-02-15 11:19:46 -06:00
links Add test case for wheel installation with different path (#4396) 2024-06-19 09:39:55 -05:00
packages Rename README to README.md (#4315) 2024-06-13 16:43:11 -05:00
popular_packages Finish install-many with pypi 10k most dependents (#732) 2023-12-27 09:42:51 -05:00
requirements Add airflow benchmark (#3643) 2024-05-23 13:25:54 -04:00
scenarios Deduplicate test command creation (#4512) 2024-06-25 22:06:54 +00:00
workspaces Default to current Python minor if Requires-Python is absent (#4070) 2024-06-05 20:45:50 +00:00
check_cache_compat.py fix typos (#2804) 2024-04-03 11:57:19 +00:00
check_embedded_python.py Add support for embedded Python on Windows (#3161) 2024-04-22 13:34:27 -04:00
check_system_python.py Deduplicate symbolic links between purelib and platlib (#3002) 2024-04-12 17:08:56 -04:00
release.sh Request Python 3.12 in the release script (#4384) 2024-06-18 10:44:42 -05:00
sync_scenarios.sh Fixups to release.sh and sync_scenarios.sh (#2790) 2024-04-03 01:59:58 +00:00
transform_readme.py Add top-level benchmark to the README (#2622) 2024-03-22 16:07:31 -04:00
update_schemastore.py Improve JSON Schema and add export script (#3461) 2024-05-08 16:15:16 +00:00