@@ -55,7 +55,7 @@ def main():
5555 help = "run integration tests using chisel" )
5656 parser .add_argument ('--coverage' , dest = "coverage" , action = "store_true" ,
5757 help = "run integration tests with coverage" )
58- parser .add_argument ('--coveragedir ' , dest = "coverage_dir" , action = "store" ,
58+ parser .add_argument ('--coverage-dir ' , dest = "coverage_dir" , action = "store" ,
5959 default = f"test/coverage/{ datetime .datetime .now ().strftime ('%Y-%m-%d_%H-%M-%S' )} " ,
6060 help = "directory to store coverage data" )
6161 parser .add_argument ('--gotest' , dest = "run_go" , action = "store_true" ,
@@ -74,7 +74,7 @@ def main():
7474 if not os .path .exists (args .coverage_dir ):
7575 os .makedirs (args .coverage_dir )
7676 if not os .path .isdir (args .coverage_dir ):
77- raise (Exception ("coveragedir must be a directory" ))
77+ raise (Exception ("coverage-dir must be a directory" ))
7878
7979 if not (args .run_chisel or args .custom or args .run_go is not None ):
8080 raise (Exception ("must run at least one of the letsencrypt or chisel tests with --chisel, --gotest, or --custom" ))
@@ -118,6 +118,10 @@ def main():
118118 run_cert_checker ()
119119 check_balance ()
120120
121+ # If coverage is enabled, process the coverage data
122+ if args .coverage :
123+ process_covdata (args .coverage_dir )
124+
121125 if not startservers .check ():
122126 raise (Exception ("startservers.check failed" ))
123127
@@ -159,5 +163,17 @@ def check_balance():
159163def run_cert_checker ():
160164 run (["./bin/boulder" , "cert-checker" , "-config" , "%s/cert-checker.json" % config_dir ])
161165
166+ def process_covdata (coverage_dir ):
167+ """Process coverage data and generate reports."""
168+ if not os .path .exists (coverage_dir ):
169+ raise (Exception ("Coverage directory does not exist: %s" % coverage_dir ))
170+
171+ # Generate text report
172+ coverage_dir = os .path .abspath (coverage_dir )
173+ cov_text = os .path .join (coverage_dir , "integration.coverprofile" )
174+ # this works, but if it takes a long time consider merging with `go tool covdata merge` first
175+ # https://go.dev/blog/integration-test-coverage#merging-raw-profiles-with-go-tool-covdata-merge
176+ subprocess .check_call (["go" , "tool" , "covdata" , "textfmt" , "-i" , coverage_dir , "-o" , cov_text ])
177+
162178if __name__ == "__main__" :
163179 main ()
0 commit comments