The commits above were made without the pre-commit hook, which could not run dart at the time.
66 lines
2.3 KiB
Dart
66 lines
2.3 KiB
Dart
import 'dart:io';
|
|
|
|
import 'package:pipe/pipe.dart';
|
|
import 'package:test/test.dart';
|
|
|
|
void _copyTree(Directory from, Directory to) {
|
|
to.createSync(recursive: true);
|
|
for (final entity in from.listSync(recursive: true)) {
|
|
final relative = entity.path.substring(from.path.length + 1);
|
|
final target = '${to.path}/$relative';
|
|
if (entity is Directory) {
|
|
Directory(target).createSync(recursive: true);
|
|
} else if (entity is File) {
|
|
File(target).writeAsBytesSync(entity.readAsBytesSync());
|
|
}
|
|
}
|
|
}
|
|
|
|
void main() {
|
|
test('verify reports findings in an excluded file as not scanned', () async {
|
|
// The analyzer skips a file that analysis_options `exclude:` names, and the
|
|
// verify gate only refused FAILED files. So a finding in an excluded file
|
|
// was absent from the fresh report and verify called it RESOLVED.
|
|
const excluded = 'lib/item_bloc.dart';
|
|
final original = await loadProject('test/fixtures/stuck_loading');
|
|
final before = await analyzeProject(original, concurrency: 1);
|
|
final encoded = encodeBaseline(original.root, before.report.findings);
|
|
await before.dispose();
|
|
final baseline = decodeBaselineEntries(encoded);
|
|
final inExcluded = baseline.where((entry) => entry.file == excluded);
|
|
expect(inExcluded, isNotEmpty, reason: 'the fixture must exercise this');
|
|
|
|
final temp = Directory.systemTemp.createTempSync('pipe-excluded');
|
|
_copyTree(Directory('test/fixtures/stuck_loading'), temp);
|
|
File(
|
|
'${temp.path}/analysis_options.yaml',
|
|
).writeAsStringSync('analyzer:\n exclude:\n - $excluded\n');
|
|
|
|
final analysis = await analyzeProject(
|
|
await loadProject(temp.path),
|
|
concurrency: 1,
|
|
);
|
|
try {
|
|
expect(
|
|
analysis.run.outcomes.where((outcome) => outcome.skipped),
|
|
isNotEmpty,
|
|
reason: 'analysis_options exclude: should skip the file',
|
|
);
|
|
final verification = verifyAnalysis(
|
|
analysis: analysis,
|
|
baseline: baseline,
|
|
);
|
|
expect(
|
|
verification.resolved.where((entry) => entry.file == excluded),
|
|
isEmpty,
|
|
);
|
|
expect(
|
|
verification.notScanned.map((entry) => entry.fingerprint),
|
|
containsAll(inExcluded.map((entry) => entry.fingerprint)),
|
|
);
|
|
expect(verification.allResolved, isFalse);
|
|
} finally {
|
|
await analysis.dispose();
|
|
}
|
|
});
|
|
}
|