forked from firka/flutter
Make coverage collection aware of workspaces (#166389)
By default, `CoverageCollector.libraryNames` was being set to the name of the current `FlutterProject`. This means that only tests in the current project are included in the coverage report. So if the project is a workspace, tests in its subprojects were being excluded. I've changed it so that it also allows tests that are part of any of the subprojects. Fixes #159390
This commit is contained in:
@@ -727,8 +727,15 @@ class TestCommand extends FlutterCommand with DeviceBasedDevelopmentArtifacts {
|
||||
FlutterProject flutterProject,
|
||||
PackageConfig packageConfig,
|
||||
) {
|
||||
final String projectName = flutterProject.manifest.appName;
|
||||
final Set<String> packagesToInclude = <String>{if (packagesRegExps.isEmpty) projectName};
|
||||
final Set<String> packagesToInclude = <String>{};
|
||||
if (packagesRegExps.isEmpty) {
|
||||
void addProject(FlutterProject project) {
|
||||
packagesToInclude.add(project.manifest.appName);
|
||||
project.workspaceProjects.forEach(addProject);
|
||||
}
|
||||
|
||||
addProject(flutterProject);
|
||||
}
|
||||
try {
|
||||
for (final String regExpStr in packagesRegExps) {
|
||||
final RegExp regExp = RegExp(regExpStr);
|
||||
|
||||
@@ -140,6 +140,10 @@ class FlutterManifest {
|
||||
return dependencies != null ? <String>{...dependencies.keys.cast<String>()} : <String>{};
|
||||
}
|
||||
|
||||
/// List of all the entries in the workspace field of the `pubspec.yaml` file.
|
||||
List<String> get workspace =>
|
||||
(_descriptor['workspace'] as YamlList?)?.cast<String>() ?? <String>[];
|
||||
|
||||
// Flag to avoid printing multiple invalid version messages.
|
||||
bool _hasShowInvalidVersionMsg = false;
|
||||
|
||||
|
||||
@@ -131,6 +131,16 @@ class FlutterProject {
|
||||
/// The manifest of the example sub-project of this project.
|
||||
final FlutterManifest _exampleManifest;
|
||||
|
||||
/// List of [FlutterProject]s corresponding to the workspace entries.
|
||||
List<FlutterProject> get workspaceProjects =>
|
||||
manifest.workspace
|
||||
.map(
|
||||
(String entry) => FlutterProject.fromDirectory(
|
||||
directory.childDirectory(directory.fileSystem.path.normalize(entry)),
|
||||
),
|
||||
)
|
||||
.toList();
|
||||
|
||||
/// The set of organization names found in this project as
|
||||
/// part of iOS product bundle identifier, Android application ID, or
|
||||
/// Gradle group ID.
|
||||
|
||||
Reference in New Issue
Block a user