-
Notifications
You must be signed in to change notification settings - Fork 9.7k
[script/tool] speed up the pub get portion of the analyze command #3982
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
- Loading branch information
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -41,6 +41,7 @@ class AnalyzeCommand extends PluginCommand { | |
| @override | ||
| Future<void> run() async { | ||
| print('Verifying analysis settings...'); | ||
|
|
||
| final List<FileSystemEntity> files = packagesDir.listSync(recursive: true); | ||
| for (final FileSystemEntity file in files) { | ||
| if (file.basename != 'analysis_options.yaml' && | ||
|
|
@@ -64,6 +65,14 @@ class AnalyzeCommand extends PluginCommand { | |
| } | ||
|
|
||
| final List<Directory> packageDirectories = await getPackages().toList(); | ||
| final List<String> packagePaths = | ||
| packageDirectories.map((Directory dir) => dir.path).toList(); | ||
| packageDirectories.removeWhere((Directory directory) { | ||
| // We remove the 'example' subdirectories - 'flutter pub get' automatically | ||
| // runs 'pub get' there as part of handling the parent directory. | ||
| return directory.basename == 'example' && | ||
| packagePaths.contains(directory.parent.path); | ||
| }); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I was hoping we could just use
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah, I would prefer something more semantic here as well. The logic for how these are computed - getPlugins() and getPackages() - seems complicated, and I wasn't comfortable modifying it. It looks like I would have assumed that I'll want a call like that - the top level plugin directory - for a follow up PR, where I'm going to try and speed up the analysis portion of the analyze call.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
I suspect what happened is that this was written for flutter/plugins, then expanded for use in flutter/packages without renaming. Fixing the fact that "plugins" is used to refer to packages in general in the tool (including the |
||
| for (final Directory package in packageDirectories) { | ||
| await processRunner.runAndStream('flutter', <String>['packages', 'get'], | ||
| workingDir: package, exitOnError: true); | ||
|
|
@@ -86,6 +95,7 @@ class AnalyzeCommand extends PluginCommand { | |
| } | ||
|
|
||
| print('\n\n'); | ||
|
|
||
| if (failingPackages.isNotEmpty) { | ||
| print('The following packages have analyzer errors (see above):'); | ||
| for (final String package in failingPackages) { | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -53,6 +53,24 @@ void main() { | |
| ])); | ||
| }); | ||
|
|
||
| test('skips flutter pub get for examples', () async { | ||
| final Directory plugin1Dir = createFakePlugin('a', withSingleExample: true); | ||
|
|
||
| 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('dart', const <String>['analyze', '--fatal-infos'], | ||
| plugin1Dir.path), | ||
| ])); | ||
| }); | ||
|
|
||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We have one like that already - the |
||
| test('uses a separate analysis sdk', () async { | ||
| final Directory pluginDir = createFakePlugin('a'); | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
toSet()? You're only using this for inclusion testing.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
will change