Skip to content
This repository was archived by the owner on Aug 28, 2024. It is now read-only.

Commit 0a8c489

Browse files
committed
Add integration test
1 parent 0e55fcc commit 0a8c489

File tree

1 file changed

+33
-5
lines changed

1 file changed

+33
-5
lines changed

test/collect_coverage_api_test.dart

Lines changed: 33 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -100,10 +100,37 @@ void main() {
100100
final coverableLineCache = <String, Set<int>>{};
101101
final coverage =
102102
await _collectCoverage(coverableLineCache: coverableLineCache);
103-
104-
print(coverage);
105-
print(coverableLineCache);
106-
expect(false, true);
103+
final result = await HitMap.parseJson(
104+
coverage['coverage'] as List<Map<String, dynamic>>);
105+
106+
expect(coverableLineCache, contains(_sampleAppFileUri));
107+
expect(coverableLineCache, contains(_isolateLibFileUri));
108+
109+
// Expect that we have some missed lines.
110+
expect(result[_sampleAppFileUri]!.lineHits.containsValue(0), isTrue);
111+
expect(result[_isolateLibFileUri]!.lineHits.containsValue(0), isTrue);
112+
113+
// Clear _sampleAppFileUri's cache entry, then gather coverage again. We're
114+
// doing this to verify that force compilation is disabled for these
115+
// libraries. The result should be that _isolateLibFileUri should be the
116+
// same, but _sampleAppFileUri should be missing all its missed lines.
117+
coverableLineCache[_sampleAppFileUri] = {};
118+
final coverage2 =
119+
await _collectCoverage(coverableLineCache: coverableLineCache);
120+
final result2 = await HitMap.parseJson(
121+
coverage2['coverage'] as List<Map<String, dynamic>>);
122+
123+
// _isolateLibFileUri still has missed lines, but _sampleAppFileUri doesn't.
124+
expect(result2[_sampleAppFileUri]!.lineHits.containsValue(0), isFalse);
125+
expect(result2[_isolateLibFileUri]!.lineHits.containsValue(0), isTrue);
126+
127+
// _isolateLibFileUri is the same. _sampleAppFileUri is the same, but
128+
// without all its missed lines.
129+
expect(result2[_isolateLibFileUri]!.lineHits,
130+
result[_isolateLibFileUri]!.lineHits);
131+
result[_sampleAppFileUri]!.lineHits.removeWhere((line, hits) => hits == 0);
132+
expect(result2[_sampleAppFileUri]!.lineHits,
133+
result[_sampleAppFileUri]!.lineHits);
107134
}, skip: !platformVersionCheck(3, 2));
108135
}
109136

@@ -125,5 +152,6 @@ Future<Map<String, dynamic>> _collectCoverage(
125152
timeout: timeout,
126153
isolateIds: isolateIdSet,
127154
functionCoverage: functionCoverage,
128-
branchCoverage: branchCoverage);
155+
branchCoverage: branchCoverage,
156+
coverableLineCache: coverableLineCache);
129157
}

0 commit comments

Comments
 (0)