@@ -6,6 +6,7 @@ import 'dart:io';
6
6
7
7
import 'package:args/args.dart' ;
8
8
import 'package:coverage/coverage.dart' ;
9
+ import 'package:glob/glob.dart' ;
9
10
import 'package:path/path.dart' as p;
10
11
11
12
/// [Environment] stores gathered arguments information.
@@ -24,6 +25,7 @@ class Environment {
24
25
required this .prettyPrintFunc,
25
26
required this .prettyPrintBranch,
26
27
required this .reportOn,
28
+ required this .ignoreFiles,
27
29
required this .sdkRoot,
28
30
required this .verbose,
29
31
required this .workers,
@@ -42,6 +44,7 @@ class Environment {
42
44
bool prettyPrintFunc;
43
45
bool prettyPrintBranch;
44
46
List <String >? reportOn;
47
+ List <String >? ignoreFiles;
45
48
String ? sdkRoot;
46
49
bool verbose;
47
50
int workers;
@@ -76,6 +79,8 @@ Future<void> main(List<String> arguments) async {
76
79
print ('Done creating global hitmap. Took ${clock .elapsedMilliseconds } ms.' );
77
80
}
78
81
82
+ final ignoreGlobs = env.ignoreFiles? .map (Glob .new ).toSet ();
83
+
79
84
String output;
80
85
final resolver = env.bazel
81
86
? BazelResolver (workspacePath: env.bazelWorkspace)
@@ -88,12 +93,15 @@ Future<void> main(List<String> arguments) async {
88
93
if (env.prettyPrint) {
89
94
output = await hitmap.prettyPrint (resolver, loader,
90
95
reportOn: env.reportOn,
96
+ ignoreGlobs: ignoreGlobs,
91
97
reportFuncs: env.prettyPrintFunc,
92
98
reportBranches: env.prettyPrintBranch);
93
99
} else {
94
100
assert (env.lcov);
95
101
output = hitmap.formatLcov (resolver,
96
- reportOn: env.reportOn, basePath: env.baseDirectory);
102
+ reportOn: env.reportOn,
103
+ ignoreGlobs: ignoreGlobs,
104
+ basePath: env.baseDirectory);
97
105
}
98
106
99
107
env.output.write (output);
@@ -124,50 +132,54 @@ Future<void> main(List<String> arguments) async {
124
132
Environment parseArgs (List <String > arguments) {
125
133
final parser = ArgParser ();
126
134
127
- parser.addOption ('sdk-root' , abbr: 's' , help: 'path to the SDK root' );
128
- parser.addOption ('packages' ,
129
- help: '[DEPRECATED] path to the package spec file' );
130
- parser.addOption ('package' ,
131
- help: 'root directory of the package' , defaultsTo: '.' );
132
- parser.addOption ('in' , abbr: 'i' , help: 'input(s): may be file or directory' );
133
- parser.addOption ('out' ,
134
- abbr: 'o' , defaultsTo: 'stdout' , help: 'output: may be file or stdout' );
135
- parser.addMultiOption ('report-on' ,
136
- help: 'which directories or files to report coverage on' );
137
- parser.addOption ('workers' ,
138
- abbr: 'j' , defaultsTo: '1' , help: 'number of workers' );
139
- parser.addOption ('bazel-workspace' ,
140
- defaultsTo: '' , help: 'Bazel workspace directory' );
141
- parser.addOption ('base-directory' ,
142
- abbr: 'b' ,
143
- help: 'the base directory relative to which source paths are output' );
144
- parser.addFlag ('bazel' ,
145
- defaultsTo: false , help: 'use Bazel-style path resolution' );
146
- parser.addFlag ('pretty-print' ,
147
- abbr: 'r' ,
148
- negatable: false ,
149
- help: 'convert line coverage data to pretty print format' );
150
- parser.addFlag ('pretty-print-func' ,
151
- abbr: 'f' ,
135
+ parser
136
+ ..addOption ('sdk-root' , abbr: 's' , help: 'path to the SDK root' )
137
+ ..addOption ('packages' , help: '[DEPRECATED] path to the package spec file' )
138
+ ..addOption ('package' ,
139
+ help: 'root directory of the package' , defaultsTo: '.' )
140
+ ..addOption ('in' , abbr: 'i' , help: 'input(s): may be file or directory' )
141
+ ..addOption ('out' ,
142
+ abbr: 'o' , defaultsTo: 'stdout' , help: 'output: may be file or stdout' )
143
+ ..addMultiOption ('report-on' ,
144
+ help: 'which directories or files to report coverage on' )
145
+ ..addOption ('workers' ,
146
+ abbr: 'j' , defaultsTo: '1' , help: 'number of workers' )
147
+ ..addOption ('bazel-workspace' ,
148
+ defaultsTo: '' , help: 'Bazel workspace directory' )
149
+ ..addOption ('base-directory' ,
150
+ abbr: 'b' ,
151
+ help: 'the base directory relative to which source paths are output' )
152
+ ..addFlag ('bazel' ,
153
+ defaultsTo: false , help: 'use Bazel-style path resolution' )
154
+ ..addFlag ('pretty-print' ,
155
+ abbr: 'r' ,
156
+ negatable: false ,
157
+ help: 'convert line coverage data to pretty print format' )
158
+ ..addFlag ('pretty-print-func' ,
159
+ abbr: 'f' ,
160
+ negatable: false ,
161
+ help: 'convert function coverage data to pretty print format' )
162
+ ..addFlag ('pretty-print-branch' ,
163
+ negatable: false ,
164
+ help: 'convert branch coverage data to pretty print format' )
165
+ ..addFlag ('lcov' ,
166
+ abbr: 'l' ,
167
+ negatable: false ,
168
+ help: 'convert coverage data to lcov format' )
169
+ ..addFlag ('verbose' , abbr: 'v' , negatable: false , help: 'verbose output' )
170
+ ..addFlag (
171
+ 'check-ignore' ,
172
+ abbr: 'c' ,
152
173
negatable: false ,
153
- help: 'convert function coverage data to pretty print format' );
154
- parser.addFlag ('pretty-print-branch' ,
155
- negatable: false ,
156
- help: 'convert branch coverage data to pretty print format' );
157
- parser.addFlag ('lcov' ,
158
- abbr: 'l' ,
159
- negatable: false ,
160
- help: 'convert coverage data to lcov format' );
161
- parser.addFlag ('verbose' ,
162
- abbr: 'v' , negatable: false , help: 'verbose output' );
163
- parser.addFlag (
164
- 'check-ignore' ,
165
- abbr: 'c' ,
166
- negatable: false ,
167
- help: 'check for coverage ignore comments.'
168
- ' Not supported in web coverage.' ,
169
- );
170
- parser.addFlag ('help' , abbr: 'h' , negatable: false , help: 'show this help' );
174
+ help: 'check for coverage ignore comments.'
175
+ ' Not supported in web coverage.' ,
176
+ )
177
+ ..addMultiOption (
178
+ 'ignore-files' ,
179
+ defaultsTo: [],
180
+ help: 'Ignore files by glob patterns' ,
181
+ )
182
+ ..addFlag ('help' , abbr: 'h' , negatable: false , help: 'show this help' );
171
183
172
184
final args = parser.parse (arguments);
173
185
@@ -261,6 +273,7 @@ Environment parseArgs(List<String> arguments) {
261
273
}
262
274
263
275
final checkIgnore = args['check-ignore' ] as bool ;
276
+ final ignoredGlobs = args['ignore-files' ] as List <String >;
264
277
final verbose = args['verbose' ] as bool ;
265
278
return Environment (
266
279
baseDirectory: baseDirectory,
@@ -276,6 +289,7 @@ Environment parseArgs(List<String> arguments) {
276
289
prettyPrintFunc: prettyPrintFunc,
277
290
prettyPrintBranch: prettyPrintBranch,
278
291
reportOn: reportOn,
292
+ ignoreFiles: ignoredGlobs,
279
293
sdkRoot: sdkRoot,
280
294
verbose: verbose,
281
295
workers: workers);
0 commit comments