@@ -77,22 +77,30 @@ run_gcov <- function(path, quiet = TRUE, clean = TRUE,
7777 if (length(gcov_inputs )) stop(' gcov not found' )
7878 return ()
7979 }
80+
81+ if (clean ) {
82+ on.exit({
83+ gcov_outputs <- list.files(path , pattern = rex :: rex(" .gcov" , end ), recursive = TRUE , full.names = TRUE )
84+ unlink(gcov_outputs )
85+ })
86+ }
87+
8088 run_gcov_one <- function (src ) {
8189 system_check(gcov_path ,
8290 args = c(gcov_args , src , " -p" , " -o" , dirname(src )),
8391 quiet = quiet , echo = ! quiet )
84- gcov_outputs <- list.files(path , pattern = rex :: rex(" .gcov" , end ), recursive = TRUE , full.names = TRUE )
85- if (clean ) {
86- on.exit(unlink(gcov_outputs ))
87- }
88- unlist(lapply(gcov_outputs , parse_gcov , package_path = c(path , getOption(" covr.gcov_additional_paths" , NULL ))), recursive = FALSE )
8992 }
9093
91- res <- withr :: with_dir(src_path , {
92- compact(unlist(lapply(gcov_inputs , run_gcov_one ), recursive = FALSE ))
93- })
94- if (! length(res ) && length(gcov_inputs ))
94+ withr :: with_dir(src_path , {
95+ compact(unlist(lapply(gcov_inputs , run_gcov_one ), recursive = FALSE ))
96+ gcov_outputs <- list.files(path , pattern = rex :: rex(" .gcov" , end ), recursive = TRUE , full.names = TRUE )
97+ res <- unlist(lapply(gcov_outputs , parse_gcov , package_path = c(path , getOption(" covr.gcov_additional_paths" , NULL ))), recursive = FALSE )
98+ })
99+
100+ if (! length(res ) && length(gcov_inputs )) {
95101 warning(' parsed gcov output was empty' )
102+ }
103+
96104 res
97105}
98106
0 commit comments