@@ -31,10 +31,17 @@ pub fn run_tests(
3131 let mut cargo_args = flatten_args ( args, passthrough_args) ;
3232
3333 // Re-add profile flags that were consumed during argument parsing
34- if is_release {
35- cargo_args. insert ( 0 , OsString :: from ( "--release" ) ) ;
34+ #[ expect( clippy:: manual_map) ] // This is much clearer than using map()
35+ let profile_arg = if is_release {
36+ Some ( OsString :: from ( "--release" ) )
3637 } else if let Some ( ref p) = custom_profile {
37- cargo_args. insert ( 0 , OsString :: from ( format ! ( "--cargo-profile={p}" ) ) ) ;
38+ Some ( OsString :: from ( format ! ( "--cargo-profile={p}" ) ) )
39+ } else {
40+ None
41+ } ;
42+
43+ if let Some ( ref profile_arg) = profile_arg {
44+ cargo_args. insert ( 0 , profile_arg. clone ( ) ) ;
3845 }
3946
4047 // Retries handled by cargo nextest natively
@@ -50,37 +57,36 @@ pub fn run_tests(
5057 install_warp:: install_warp ( & shell, & target_dir) ?;
5158 }
5259
53- // These needs to match the command in "run wgpu-info" in `.github/workflows/ci.yml`
54- let llvm_cov_flags: & [ _ ] = if llvm_cov {
55- & [ "llvm-cov" , "--no-cfg-coverage" , "--no-report" ]
56- } else {
57- & [ ]
58- } ;
59- let llvm_cov_nextest_flags: & [ _ ] = if llvm_cov {
60+ let test_suite_run_flags: & [ _ ] = if llvm_cov {
6061 & [ "llvm-cov" , "--no-cfg-coverage" , "--no-report" , "nextest" ]
61- } else if list {
62- & [ "nextest" , "list" ]
6362 } else {
6463 & [ "nextest" , "run" ]
6564 } ;
6665
6766 log:: info!( "Generating .gpuconfig file based on gpus on the system" ) ;
6867
68+ // We use a test to generate the .gpuconfig file instead of using the cli directly
69+ // as `cargo run --bin wgpu-info` would build a different set of dependencies, causing
70+ // incremental changes to need to rebuild the wgpu stack twice, one for the tests
71+ // and once for the cli binary.
72+ //
73+ // Needs to be kept in sync with the test in wgpu-info/src/tests.rs
6974 shell
7075 . cmd ( "cargo" )
71- . args ( llvm_cov_flags)
72- . args ( [
73- "run" ,
74- "--bin" ,
75- "wgpu-info" ,
76- "--" ,
77- "--json" ,
78- "-o" ,
79- ".gpuconfig" ,
80- ] )
76+ . args ( test_suite_run_flags)
77+ // Use the same build configuration as the main tests, so that we only build once.
78+ . args ( [ "--benches" , "--tests" , "--all-features" ] )
79+ // Use the same cargo profile as the main tests.
80+ . args ( profile_arg)
81+ // We need to tell nextest to filter by binary too, so it doesn't try to enumerate
82+ // tests on any of the gpu enabled test binaries, as that will fail due to
83+ // old or missing .gpuconfig files.
84+ . args ( [ "-E" , "binary(wgpu-info)" , "generate_gpuconfig_report" ] )
85+ // Turn on the env var for saving the .gpuconfig files
86+ . env ( "WGPU_INFO_SAVE_GPUCONFIG_REPORT" , "1" )
8187 . quiet ( )
8288 . run ( )
83- . context ( "Failed to run wgpu-info to generate .gpuconfig" ) ?;
89+ . context ( "Failed to run tests to generate .gpuconfig" ) ?;
8490
8591 let gpu_count = shell
8692 . read_file ( ".gpuconfig" )
@@ -99,7 +105,7 @@ pub fn run_tests(
99105 log:: info!( "Listing tests" ) ;
100106 shell
101107 . cmd ( "cargo" )
102- . args ( llvm_cov_nextest_flags )
108+ . args ( [ "nextest" , "list" ] )
103109 . args ( [ "-v" , "--benches" , "--tests" , "--all-features" ] )
104110 . args ( cargo_args)
105111 . run ( )
@@ -110,7 +116,7 @@ pub fn run_tests(
110116
111117 shell
112118 . cmd ( "cargo" )
113- . args ( llvm_cov_nextest_flags )
119+ . args ( test_suite_run_flags )
114120 . args ( [ "--benches" , "--tests" , "--all-features" ] )
115121 . args ( cargo_args)
116122 . quiet ( )
0 commit comments