Skip to content
This repository was archived by the owner on Feb 22, 2023. It is now read-only.

[script/tool] speed up the pub get portion of the analyze command #3982

Merged
merged 2 commits into from
May 27, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
review comments; add additional test
  • Loading branch information
devoncarew committed May 27, 2021
commit 8364bf0bbd03f124c9dca57ab3a2b501b116922f
4 changes: 2 additions & 2 deletions script/tool/lib/src/analyze_command.dart
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,8 @@ class AnalyzeCommand extends PluginCommand {
}

final List<Directory> packageDirectories = await getPackages().toList();
final List<String> packagePaths =
packageDirectories.map((Directory dir) => dir.path).toList();
final Set<String> packagePaths =
packageDirectories.map((Directory dir) => dir.path).toSet();
packageDirectories.removeWhere((Directory directory) {
// We remove the 'example' subdirectories - 'flutter pub get' automatically
// runs 'pub get' there as part of handling the parent directory.
Expand Down
23 changes: 23 additions & 0 deletions script/tool/test/analyze_command_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,29 @@ void main() {
]));
});

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you also add a test of a package with a sub-package that's not example, to make sure nobody makes the "simplification" that I was about to suggest before checking flutter/packages?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We have one like that already - the analyzes all packages test - but I can add one where the 2nd package is named 'example' but not contained by the 1st package.

test('don\'t elide a non-contained example package', () async {
final Directory plugin1Dir = createFakePlugin('a');
final Directory plugin2Dir = createFakePlugin('example');

final MockProcess mockProcess = MockProcess();
mockProcess.exitCodeCompleter.complete(0);
processRunner.processToReturn = mockProcess;
await runner.run(<String>['analyze']);

expect(
processRunner.recordedCalls,
orderedEquals(<ProcessCall>[
ProcessCall(
'flutter', const <String>['packages', 'get'], plugin1Dir.path),
ProcessCall(
'flutter', const <String>['packages', 'get'], plugin2Dir.path),
ProcessCall('dart', const <String>['analyze', '--fatal-infos'],
plugin1Dir.path),
ProcessCall('dart', const <String>['analyze', '--fatal-infos'],
plugin2Dir.path),
]));
});

test('uses a separate analysis sdk', () async {
final Directory pluginDir = createFakePlugin('a');

Expand Down