@@ -127,6 +127,11 @@ def parse_args():
127127 "skip-tensor (everything except tensor, assumes tensor headers exist), "
128128 "or both (default: both)" ,
129129 )
130+ p .add_argument (
131+ "--tests-only" ,
132+ action = "store_true" ,
133+ help = "Skip build and only run tests with coverage collection" ,
134+ )
130135
131136 return p .parse_args ()
132137
@@ -163,44 +168,67 @@ def main():
163168 args = parse_args ()
164169 setup_dir = os .path .dirname (os .path .dirname (os .path .abspath (__file__ )))
165170
166- c_compiler , cxx_compiler = resolve_compilers (
167- args .oneapi ,
168- args .c_compiler ,
169- args .cxx_compiler ,
170- args .compiler_root ,
171- )
171+ env = os .environ .copy ()
172+
173+ # If tests-only mode, skip build and jump to test execution
174+ if args .tests_only :
175+ c_compiler , cxx_compiler = resolve_compilers (
176+ args .oneapi ,
177+ args .c_compiler ,
178+ args .cxx_compiler ,
179+ args .compiler_root ,
180+ )
181+ if args .bin_llvm :
182+ bin_llvm = args .bin_llvm
183+ else :
184+ bin_llvm = find_bin_llvm (c_compiler )
185+ print (
186+ f"[gen_coverage] Path to folder with llvm-cov/llvm-profdata: { bin_llvm } "
187+ )
188+ if bin_llvm :
189+ env ["PATH" ] = ":" .join ((env .get ("PATH" , "" ), bin_llvm ))
190+ env ["LLVM_TOOLS_HOME" ] = bin_llvm
172191
173- dpctl_cmake_dir = get_dpctl_cmake_dir ()
174- print (f"[gen_coverage] Found DPCTL CMake dir: { dpctl_cmake_dir } " )
192+ print ("[gen_coverage] Skipping build (--tests-only mode)" )
193+ # Jump to test execution below
194+ else :
195+ # Normal build mode
196+ c_compiler , cxx_compiler = resolve_compilers (
197+ args .oneapi ,
198+ args .c_compiler ,
199+ args .cxx_compiler ,
200+ args .compiler_root ,
201+ )
175202
176- if args . clean :
177- clean_build_dir ( setup_dir )
203+ dpctl_cmake_dir = get_dpctl_cmake_dir ()
204+ print ( f"[gen_coverage] Found DPCTL CMake dir: { dpctl_cmake_dir } " )
178205
179- cmake_args = make_cmake_args (
180- c_compiler = c_compiler ,
181- cxx_compiler = cxx_compiler ,
182- dpctl_cmake_dir = dpctl_cmake_dir ,
183- verbose = args .verbose ,
184- )
185- cmake_args .append ("-DDPNP_GENERATE_COVERAGE=ON" )
206+ if args .clean :
207+ clean_build_dir (setup_dir )
186208
187- env = os .environ .copy ()
209+ cmake_args = make_cmake_args (
210+ c_compiler = c_compiler ,
211+ cxx_compiler = cxx_compiler ,
212+ dpctl_cmake_dir = dpctl_cmake_dir ,
213+ verbose = args .verbose ,
214+ )
215+ cmake_args .append ("-DDPNP_GENERATE_COVERAGE=ON" )
188216
189- if args .bin_llvm :
190- bin_llvm = args .bin_llvm
191- else :
192- bin_llvm = find_bin_llvm (c_compiler )
193- print (
194- f"[gen_coverage] Path to folder with llvm-cov/llvm-profdata: { bin_llvm } "
195- )
217+ if args .bin_llvm :
218+ bin_llvm = args .bin_llvm
219+ else :
220+ bin_llvm = find_bin_llvm (c_compiler )
221+ print (
222+ f"[gen_coverage] Path to folder with llvm-cov/llvm-profdata: { bin_llvm } "
223+ )
196224
197- if bin_llvm :
198- env ["PATH" ] = ":" .join ((env .get ("PATH" , "" ), bin_llvm ))
199- env ["LLVM_TOOLS_HOME" ] = bin_llvm
225+ if bin_llvm :
226+ env ["PATH" ] = ":" .join ((env .get ("PATH" , "" ), bin_llvm ))
227+ env ["LLVM_TOOLS_HOME" ] = bin_llvm
200228
201- log_cmake_args (cmake_args , "gen_coverage" )
229+ log_cmake_args (cmake_args , "gen_coverage" )
202230
203- if args .build_step in ["tensor" , "both" ]:
231+ if not args . tests_only and args .build_step in ["tensor" , "both" ]:
204232 # Build tensor only to generate Cython headers
205233 tensor_cmake_args = cmake_args .copy ()
206234 tensor_cmake_args .append ("-DDPNP_BUILD_COMPONENTS=TENSOR_ONLY" )
@@ -214,7 +242,7 @@ def main():
214242 build_type = "Coverage" ,
215243 )
216244
217- if args .build_step in ["skip-tensor" , "both" ]:
245+ if not args . tests_only and args .build_step in ["skip-tensor" , "both" ]:
218246 # Build everything except tensor (assumes tensor headers already exist)
219247 skip_tensor_cmake_args = cmake_args .copy ()
220248 skip_tensor_cmake_args .append ("-DDPNP_BUILD_COMPONENTS=SKIP_TENSOR" )
@@ -229,8 +257,10 @@ def main():
229257 )
230258 install_editable (setup_dir , env )
231259
232- # Only run tests when we have a complete build (skip-tensor or both)
233- if args .run_pytest and args .build_step in ["skip-tensor" , "both" ]:
260+ # Run tests when: tests-only mode OR (run_pytest AND complete build)
261+ if args .tests_only or (
262+ args .run_pytest and args .build_step in ["skip-tensor" , "both" ]
263+ ):
234264 env ["LLVM_PROFILE_FILE" ] = "dpnp_pytest.profraw"
235265 pytest_cmd = [
236266 "pytest" ,
0 commit comments