@@ -177,9 +177,15 @@ struct TestBuildFilter {
177177}
178178
179179impl TestBuildFilter {
180- fn compute < ' g > ( & self , graph : & ' g PackageGraph , output : OutputContext ) -> Result < TestList < ' g > > {
181- let manifest_path = graph. workspace ( ) . root ( ) . join ( "Cargo.toml" ) ;
182- let mut cargo_cli = CargoCli :: new ( "test" , Some ( & manifest_path) , output) ;
180+ fn compute < ' g > (
181+ & self ,
182+ manifest_path : Option < & ' g Utf8Path > ,
183+ graph : & ' g PackageGraph ,
184+ output : OutputContext ,
185+ ) -> Result < TestList < ' g > > {
186+ // Don't use the manifest path from the graph to ensure that if the user cd's into a
187+ // particular crate and runs cargo nextest, then it behaves identically to cargo test.
188+ let mut cargo_cli = CargoCli :: new ( "test" , manifest_path, output) ;
183189
184190 // Only build tests in the cargo test invocation, do not run them.
185191 cargo_cli. add_args ( [ "--no-run" , "--message-format" , "json-render-diagnostics" ] ) ;
@@ -309,7 +315,8 @@ impl AppImpl {
309315 build_filter,
310316 message_format,
311317 } => {
312- let mut test_list = build_filter. compute ( & graph, output) ?;
318+ let mut test_list =
319+ build_filter. compute ( self . manifest_path . as_deref ( ) , & graph, output) ?;
313320 if output. color . should_colorize ( Stream :: Stdout ) {
314321 test_list. colorize ( ) ;
315322 }
@@ -332,7 +339,8 @@ impl AppImpl {
332339 std:: fs:: create_dir_all ( & store_dir)
333340 . wrap_err_with ( || format ! ( "failed to create store dir '{}'" , store_dir) ) ?;
334341
335- let test_list = build_filter. compute ( & graph, output) ?;
342+ let test_list =
343+ build_filter. compute ( self . manifest_path . as_deref ( ) , & graph, output) ?;
336344
337345 let mut reporter = reporter_opts
338346 . to_builder ( no_capture)
0 commit comments