Add pathFilter to Fingerprinter (#17412)
Allows users of Fingerprinter to filter the set of paths collected from the explicitly-specified paths and those collected from depfiles. In some cases, depfiles are emitted with files that are not present on the local disk (e.g. the frontend compiler currently emits buildbot paths for the dart core libraries and dart:ui). These files will not materially affect whether we need to re-run a build action for which they are inputs, since they're not present in the filesystem and therefore cannot change.
This commit is contained in:
@@ -52,10 +52,12 @@ void main() {
|
||||
testUsingContext('creates fingerprint with file checksums', () async {
|
||||
await fs.file('a.dart').create();
|
||||
await fs.file('b.dart').create();
|
||||
await fs.file('depfile').writeAsString('depfile : b.dart');
|
||||
|
||||
final Fingerprinter fingerprinter = new Fingerprinter(
|
||||
fingerprintPath: 'out.fingerprint',
|
||||
paths: <String>['a.dart', 'b.dart'],
|
||||
paths: <String>['a.dart'],
|
||||
depfilePaths: <String>['depfile'],
|
||||
properties: <String, String>{
|
||||
'bar': 'baz',
|
||||
'wobble': 'womble',
|
||||
@@ -123,6 +125,38 @@ void main() {
|
||||
await fingerprinter.writeFingerprint();
|
||||
expect(await fingerprinter.doesFingerprintMatch(), isTrue);
|
||||
}, overrides: contextOverrides);
|
||||
|
||||
testUsingContext('fails to write fingerprint if inputs are missing', () async {
|
||||
final Fingerprinter fingerprinter = new Fingerprinter(
|
||||
fingerprintPath: 'out.fingerprint',
|
||||
paths: <String>['a.dart'],
|
||||
properties: <String, String>{
|
||||
'foo': 'bar',
|
||||
'wibble': 'wobble',
|
||||
},
|
||||
);
|
||||
await fingerprinter.writeFingerprint();
|
||||
expect(fs.file('out.fingerprint').existsSync(), isFalse);
|
||||
}, overrides: contextOverrides);
|
||||
|
||||
testUsingContext('applies path filter to inputs paths', () async {
|
||||
await fs.file('a.dart').create();
|
||||
await fs.file('ab.dart').create();
|
||||
await fs.file('depfile').writeAsString('depfile : ab.dart c.dart');
|
||||
|
||||
final Fingerprinter fingerprinter = new Fingerprinter(
|
||||
fingerprintPath: 'out.fingerprint',
|
||||
paths: <String>['a.dart'],
|
||||
depfilePaths: <String>['depfile'],
|
||||
properties: <String, String>{
|
||||
'foo': 'bar',
|
||||
'wibble': 'wobble',
|
||||
},
|
||||
pathFilter: (String path) => path.startsWith('a'),
|
||||
);
|
||||
await fingerprinter.writeFingerprint();
|
||||
expect(fs.file('out.fingerprint').existsSync(), isTrue);
|
||||
}, overrides: contextOverrides);
|
||||
});
|
||||
|
||||
group('Fingerprint', () {
|
||||
|
||||
Reference in New Issue
Block a user