From 65b39f2ca9678c349f8f77384ea8d2c3ff742adf Mon Sep 17 00:00:00 2001 From: Matthew Mckee Date: Wed, 6 Aug 2025 23:02:10 +0100 Subject: [PATCH] [ty] Add support for using the test command emitted when a mdtest fails (#19794) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## Summary When seeing a failed test like ```bash is_subtype_of.md - Subtype relation - Callable - Class literals - Classes with `__new_… (1e9782853227c019) crates/ty_python_semantic/resources/mdtest/type_properties/is_subtype_of.md:1810 unexpected error: [unresolved-reference] "Name `Aa` used when not defined" To rerun this specific test, set the environment variable: MDTEST_TEST_FILTER='is_subtype_of.md - Subtype relation - Callable - Class literals - Classes with `__new_… (1e9782853227c019)' MDTEST_TEST_FILTER='is_subtype_of.md - Subtype relation - Callable - Class literals - Classes with `__new_… (1e9782853227c019)' cargo test -p ty_python_semantic --test mdtest -- mdtest__type_properties_is_subtype_of ``` running the following now works ```bash MDTEST_TEST_FILTER='is_subtype_of.md - Subtype relation - Callable - Class literals - Classes with `__new_… (1e9782853227c019)' cargo test -p ty_python_semantic --test mdtest -- mdtest__type_properties_is_subtype_of ``` ## Test Plan Do we have tests for the test runner? :) --- crates/ty_test/src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/ty_test/src/lib.rs b/crates/ty_test/src/lib.rs index 8532bbdd02..fdde483c1a 100644 --- a/crates/ty_test/src/lib.rs +++ b/crates/ty_test/src/lib.rs @@ -58,7 +58,7 @@ pub fn run( for test in suite.tests() { if filter .as_ref() - .is_some_and(|f| !test.uncontracted_name().contains(f)) + .is_some_and(|f| !(test.uncontracted_name().contains(f) || test.name() == *f)) { continue; }