@@ -39,9 +39,7 @@ impl Cover {
3939
4040 // Get the absolute path for the coverage directory to ensure .profraw files
4141 // are created in the correct location, even in workspace scenarios
42- let coverage_target_dir = env:: current_dir ( )
43- . unwrap ( )
44- . join ( "target/coverage/debug/deps" ) ;
42+ let coverage_target_dir = super :: target_dir ( ) . join ( "coverage/debug/deps" ) ;
4543 let profile_file = coverage_target_dir. join ( "coverage-%p-%m.profraw" ) ;
4644
4745 let coverage_corpus = if input_path. is_dir ( ) {
@@ -55,13 +53,15 @@ impl Cover {
5553 } ;
5654
5755 for file in coverage_corpus {
58- let _ = process:: Command :: new ( format ! ( "./target/coverage/debug/{}" , & self . target) )
59- . arg ( file. display ( ) . to_string ( ) )
60- . env ( "LLVM_PROFILE_FILE" , profile_file. display ( ) . to_string ( ) )
61- . spawn ( )
62- . unwrap ( )
63- . wait_with_output ( )
64- . unwrap ( ) ;
56+ let _ = process:: Command :: new (
57+ super :: target_dir ( ) . join ( format ! ( "coverage/debug/{}" , & self . target) ) ,
58+ )
59+ . arg ( file. display ( ) . to_string ( ) )
60+ . env ( "LLVM_PROFILE_FILE" , & profile_file)
61+ . spawn ( )
62+ . unwrap ( )
63+ . wait_with_output ( )
64+ . unwrap ( ) ;
6565 }
6666
6767 let source_or_workspace_root = self . source . as_ref ( ) . map_or_else (
@@ -107,13 +107,10 @@ impl Cover {
107107 env:: var ( "COVERAGE_RUSTFLAGS" ) . unwrap_or_else ( |_| "-Cinstrument-coverage" . to_string ( ) ) ;
108108 coverage_rustflags. push ( ' ' ) ;
109109 coverage_rustflags. push_str ( & env:: var ( "RUSTFLAGS" ) . unwrap_or_default ( ) ) ;
110+ let target_dir = format ! ( "--target-dir={}" , super :: target_dir( ) . join( "coverage" ) ) ;
110111
111112 let build = process:: Command :: new ( & cargo)
112- . args ( [
113- "rustc" ,
114- "--target-dir=target/coverage" ,
115- "--features=ziggy/coverage" ,
116- ] )
113+ . args ( [ "rustc" , "--features=ziggy/coverage" , & target_dir] )
117114 . env ( "RUSTFLAGS" , coverage_rustflags)
118115 . spawn ( )
119116 . context ( "⚠️ couldn't spawn rustc for coverage" ) ?
@@ -134,14 +131,15 @@ impl Cover {
134131 let coverage = process:: Command :: new ( "grcov" )
135132 . args ( [
136133 "." ,
137- & format ! ( "-b=./target/ coverage/debug/{target}" ) ,
134+ & format ! ( "-b={}/ coverage/debug/{target}" , super :: target_dir ( ) ) ,
138135 & format ! ( "-s={source_or_workspace_root}" ) ,
139136 & format ! ( "-t={output_types}" ) ,
140137 "--llvm" ,
141138 "--branch" ,
142139 "--ignore-not-existing" ,
143140 & format ! ( "-o={coverage_dir}" ) ,
144141 ] )
142+ . current_dir ( super :: target_dir ( ) . join ( "coverage/debug/deps" ) )
145143 . spawn ( )
146144 . context ( "⚠️ cannot find grcov in your path, please install it" ) ?
147145 . wait ( )
@@ -154,12 +152,10 @@ impl Cover {
154152
155153 pub fn clean_old_cov ( ) -> Result < ( ) , anyhow:: Error > {
156154 // Use absolute path to ensure we clean the correct location in workspaces
157- let coverage_deps_dir = env:: current_dir ( )
158- . unwrap ( )
159- . join ( "target/coverage/debug/deps" ) ;
155+ let coverage_deps_dir = super :: target_dir ( ) . join ( "coverage/debug/deps" ) ;
160156 let pattern = coverage_deps_dir. join ( "*.profraw" ) ;
161157
162- if let Ok ( profile_files) = glob ( & pattern. display ( ) . to_string ( ) ) {
158+ if let Ok ( profile_files) = glob ( pattern. as_str ( ) ) {
163159 for file in profile_files. flatten ( ) {
164160 let file_string = & file. display ( ) ;
165161 fs:: remove_file ( & file)
0 commit comments