Auto-generate environment variable references for ty (#19205)

## Summary

This PR mirrors the environment variable implementation we have in uv:
efc361223c/crates/uv-static/src/env_vars.rs (L6-L7).

See: https://github.com/astral-sh/ty/issues/773.
This commit is contained in:
Charlie Marsh 2025-07-08 10:48:31 -04:00 committed by GitHub
parent 149350bf39
commit 3ee3434187
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
24 changed files with 458 additions and 14 deletions

View file

@ -29,7 +29,7 @@ mod diagnostic;
mod matcher;
mod parser;
const MDTEST_TEST_FILTER: &str = "MDTEST_TEST_FILTER";
use ty_static::EnvVars;
/// Run `path` as a markdown test suite with given `title`.
///
@ -53,7 +53,7 @@ pub fn run(
let mut db = db::Db::setup();
let filter = std::env::var(MDTEST_TEST_FILTER).ok();
let filter = std::env::var(EnvVars::MDTEST_TEST_FILTER).ok();
let mut any_failures = false;
for test in suite.tests() {
if filter
@ -105,10 +105,12 @@ pub fn run(
if output_format.is_cli() {
println!(
"\nTo rerun this specific test, set the environment variable: {MDTEST_TEST_FILTER}='{escaped_test_name}'",
"\nTo rerun this specific test, set the environment variable: {}='{escaped_test_name}'",
EnvVars::MDTEST_TEST_FILTER,
);
println!(
"{MDTEST_TEST_FILTER}='{escaped_test_name}' cargo test -p ty_python_semantic --test mdtest -- {test_name}",
"{}='{escaped_test_name}' cargo test -p ty_python_semantic --test mdtest -- {test_name}",
EnvVars::MDTEST_TEST_FILTER,
);
}
}