-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[ VM / Service ] Add librariesAlreadyCompiled to getSourceReport RPC
The goal is to have the flutter test framework skip compilation of libraries it's already seen. See option 3 from this doc: https://docs.google.com/document/d/193DKN1DmbHdphhbC8RngdkSafHQGF2QEmf-qDxqSIrk/edit#heading=h.fn9090oeqrk3 Change-Id: Ia76bbb35df22dee6e9f8b32f90bbf2ef2fa18913 TEST=source_report_libraries_already_compiled_test.dart Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/321660 Reviewed-by: Ben Konyi <bkonyi@google.com> Commit-Queue: Liam Appelbe <liama@google.com>
- Loading branch information
1 parent
685af75
commit 2fcc9bd
Showing
13 changed files
with
263 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
version=4.12 | ||
version=4.14 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
95 changes: 95 additions & 0 deletions
95
pkg/vm_service/test/source_report_libraries_already_compiled_test.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
// Copyright (c) 2023, the Dart project authors. Please see the AUTHORS file | ||
// for details. All rights reserved. Use of this source code is governed by a | ||
// BSD-style license that can be found in the LICENSE file. | ||
|
||
import 'dart:io'; | ||
import 'dart:developer'; | ||
import 'package:test/test.dart'; | ||
import 'package:vm_service/vm_service.dart'; | ||
import 'common/service_test_common.dart'; | ||
import 'common/test_helper.dart'; | ||
|
||
// ignore_for_file: dead_code | ||
|
||
class Class { | ||
void method() { | ||
print("hit"); | ||
} | ||
|
||
void missed() { | ||
print("miss"); | ||
} | ||
} | ||
|
||
void unusedFunction() { | ||
print("miss"); | ||
} | ||
|
||
void testFunction() { | ||
if (true) { | ||
print("hit"); | ||
Class().method(); | ||
} else { | ||
print("miss"); | ||
unusedFunction(); | ||
} | ||
debugger(); | ||
} | ||
|
||
const ignoreHitsBelowThisLine = 39; | ||
|
||
const allHits = [15, 16, 28, 30, 31, 36]; | ||
final tests = <IsolateTest>[ | ||
hasStoppedAtBreakpoint, | ||
librariesAlreadyCompiledTest(false, [], allHits, [33, 34]), | ||
librariesAlreadyCompiledTest(true, [target], allHits, [33, 34]), | ||
librariesAlreadyCompiledTest(true, [], allHits, [19, 20, 24, 25, 33, 34]), | ||
resumeIsolate, | ||
]; | ||
|
||
final target = Platform.script.toString(); | ||
|
||
librariesAlreadyCompiledTest( | ||
bool forceCompile, | ||
List<String> librariesAlreadyCompiled, | ||
List<int> expectedHits, | ||
List<int> expectedMisses, | ||
) => | ||
(VmService service, IsolateRef isolateRef) async { | ||
final isolateId = isolateRef.id!; | ||
|
||
final report = await service.getSourceReport( | ||
isolateId, | ||
[SourceReportKind.kCoverage], | ||
forceCompile: forceCompile, | ||
reportLines: true, | ||
librariesAlreadyCompiled: librariesAlreadyCompiled, | ||
); | ||
|
||
addLines(List<int>? lines, Set<int> out) { | ||
for (final line in lines ?? []) { | ||
if (line < ignoreHitsBelowThisLine) { | ||
out.add(line); | ||
} | ||
} | ||
} | ||
|
||
final hits = <int>{}; | ||
final misses = <int>{}; | ||
for (final range in report.ranges!) { | ||
if (report.scripts?[range.scriptIndex!].uri == target) { | ||
addLines(range.coverage?.hits, hits); | ||
addLines(range.coverage?.misses, misses); | ||
} | ||
} | ||
|
||
expect(hits, unorderedEquals(expectedHits)); | ||
expect(misses, unorderedEquals(expectedMisses)); | ||
}; | ||
|
||
main([args = const <String>[]]) async => await runIsolateTests( | ||
args, | ||
tests, | ||
target, | ||
testeeConcurrent: testFunction, | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.