@@ -2,10 +2,10 @@ use std::process::Command;
22use std:: sync:: Arc ;
33use std:: time:: Duration ;
44
5- use anyhow:: { bail, Result } ;
5+ use anyhow:: { bail, Context , Result } ;
66use clap:: Parser ;
77use cobertura:: CoberturaCoverage ;
8- use coverage:: allowlist:: { AllowList , TargetAllowList } ;
8+ use coverage:: allowlist:: AllowList ;
99use coverage:: binary:: { BinaryCoverage , DebugInfoCache } ;
1010use coverage:: record:: { CoverageRecorder , Recorded } ;
1111use debuggable_module:: load_module:: LoadModule ;
@@ -57,19 +57,21 @@ fn main() -> Result<()> {
5757 . map ( Duration :: from_millis)
5858 . unwrap_or ( DEFAULT_TIMEOUT ) ;
5959
60- let mut allowlist = TargetAllowList :: default ( ) ;
60+ let module_allowlist = args
61+ . module_allowlist
62+ . map ( AllowList :: load)
63+ . unwrap_or_else ( || Ok ( AllowList :: default ( ) ) )
64+ . context ( "loading module allowlist" ) ?;
6165
62- if let Some ( path) = & args. module_allowlist {
63- allowlist. modules = AllowList :: load ( path) ?;
64- }
65-
66- if let Some ( path) = & args. source_allowlist {
67- allowlist. source_files = AllowList :: load ( path) ?;
68- }
66+ let source_allowlist = args
67+ . source_allowlist
68+ . map ( AllowList :: load)
69+ . unwrap_or_else ( || Ok ( AllowList :: default ( ) ) )
70+ . context ( "loading source allowlist" ) ?;
6971
7072 let mut coverage = BinaryCoverage :: default ( ) ;
7173 let loader = Arc :: new ( Loader :: new ( ) ) ;
72- let cache = Arc :: new ( DebugInfoCache :: new ( allowlist . source_files . clone ( ) ) ) ;
74+ let cache = Arc :: new ( DebugInfoCache :: new ( source_allowlist . clone ( ) ) ) ;
7375
7476 let t = std:: time:: Instant :: now ( ) ;
7577 precache_target ( & args. command [ 0 ] , & loader, & cache) ?;
@@ -84,7 +86,7 @@ fn main() -> Result<()> {
8486
8587 let t = std:: time:: Instant :: now ( ) ;
8688 let recorded = CoverageRecorder :: new ( cmd)
87- . allowlist ( allowlist . clone ( ) )
89+ . module_allowlist ( module_allowlist . clone ( ) )
8890 . loader ( loader. clone ( ) )
8991 . debuginfo_cache ( cache. clone ( ) )
9092 . timeout ( timeout)
@@ -102,7 +104,7 @@ fn main() -> Result<()> {
102104
103105 let t = std:: time:: Instant :: now ( ) ;
104106 let recorded = CoverageRecorder :: new ( cmd)
105- . allowlist ( allowlist . clone ( ) )
107+ . module_allowlist ( module_allowlist )
106108 . loader ( loader)
107109 . debuginfo_cache ( cache)
108110 . timeout ( timeout)
@@ -118,8 +120,8 @@ fn main() -> Result<()> {
118120
119121 match args. output {
120122 OutputFormat :: ModOff => dump_modoff ( & coverage) ?,
121- OutputFormat :: Source => dump_source_line ( & coverage, allowlist . source_files ) ?,
122- OutputFormat :: Cobertura => dump_cobertura ( & coverage, allowlist . source_files ) ?,
123+ OutputFormat :: Source => dump_source_line ( & coverage, source_allowlist ) ?,
124+ OutputFormat :: Cobertura => dump_cobertura ( & coverage, source_allowlist ) ?,
123125 }
124126
125127 Ok ( ( ) )
0 commit comments