From a0e86814523d9797c57ac06db8d69e16825a4abf Mon Sep 17 00:00:00 2001 From: godofredoc <54371434+godofredoc@users.noreply.github.com> Date: Thu, 11 Feb 2021 15:30:55 -0800 Subject: [PATCH] Add flutter update packages to some tests. (#75530) * Add flutter update packages to some tests. Analyzer_benchmark and flutter_test_performance require to pub get multiple directories. Rather than delegating the recipes to run flutter update-packages we explicitly running on tests that need it. Bug: https://github.com/flutter/flutter/issues/75524 * Add pub get directly on the analyis classes. * Run flutter get in dev/tools. * Fix directory path. * Add more dependency directories. * Fix typo. * Add more dependencies. * Add stocks dependency. * Fix paths to some apps. * Add more dependencies. * Complete dependencies definition. * More analysis dependencies. * Add examples dependencies. * Dev tool dependencies. * Use update-packages for analyzer benchmark. --- .../bin/tasks/flutter_test_performance.dart | 9 +++++++++ dev/devicelab/lib/tasks/analysis.dart | 16 ++++++++-------- 2 files changed, 17 insertions(+), 8 deletions(-) diff --git a/dev/devicelab/bin/tasks/flutter_test_performance.dart b/dev/devicelab/bin/tasks/flutter_test_performance.dart index b3f8c072d3..0b255dfa8f 100644 --- a/dev/devicelab/bin/tasks/flutter_test_performance.dart +++ b/dev/devicelab/bin/tasks/flutter_test_performance.dart @@ -101,11 +101,20 @@ Future runTest({bool coverage = false, bool noPub = false}) async { return clock.elapsedMilliseconds; } +Future pubGetDependencies(List directories) async { + for (final Directory directory in directories) { + await inDirectory(directory, () async { + await flutter('pub', options: ['get']); + }); + } +} + void main() { task(() async { final File nodeSourceFile = File(path.join( flutterDirectory.path, 'packages', 'flutter', 'lib', 'src', 'foundation', 'node.dart', )); + await pubGetDependencies([Directory(path.join(flutterDirectory.path, 'dev', 'automated_tests')),]); final String originalSource = await nodeSourceFile.readAsString(); try { await runTest(noPub: true); // first number is meaningless; could have had to build the tool, run pub get, have a cache, etc diff --git a/dev/devicelab/lib/tasks/analysis.dart b/dev/devicelab/lib/tasks/analysis.dart index c3c5494c2a..30fa74e5c7 100644 --- a/dev/devicelab/lib/tasks/analysis.dart +++ b/dev/devicelab/lib/tasks/analysis.dart @@ -24,6 +24,7 @@ Future analyzerBenchmarkTask() async { await inDirectory(flutterDirectory, () async { rmTree(_megaGalleryDirectory); mkdirs(_megaGalleryDirectory); + await flutter('update-packages'); await dart(['dev/tools/mega_gallery.dart', '--out=${_megaGalleryDirectory.path}']); }); @@ -56,7 +57,7 @@ class _BenchmarkResult { } abstract class _Benchmark { - _Benchmark({ this.watch = false }); + _Benchmark({this.watch = false}); final bool watch; @@ -65,9 +66,9 @@ abstract class _Benchmark { Directory get directory; List get options => [ - '--benchmark', - if (watch) '--watch', - ]; + '--benchmark', + if (watch) '--watch', + ]; Future execute(int iteration, int targetIterations) async { section('Analyze $title ${watch ? 'with watcher' : ''} - ${iteration + 1} / $targetIterations'); @@ -83,7 +84,7 @@ abstract class _Benchmark { /// Times how long it takes to analyze the Flutter repository. class _FlutterRepoBenchmark extends _Benchmark { - _FlutterRepoBenchmark({ bool watch = false }) : super(watch: watch); + _FlutterRepoBenchmark({bool watch = false}) : super(watch: watch); @override String get title => 'Flutter repo'; @@ -93,14 +94,13 @@ class _FlutterRepoBenchmark extends _Benchmark { @override List get options { - return super.options - ..add('--flutter-repo'); + return super.options..add('--flutter-repo'); } } /// Times how long it takes to analyze the generated "mega_gallery" app. class _MegaGalleryBenchmark extends _Benchmark { - _MegaGalleryBenchmark({ bool watch = false }) : super(watch: watch); + _MegaGalleryBenchmark({bool watch = false}) : super(watch: watch); @override String get title => 'mega gallery';