From 6cce488d80b1d4097cdc281cf60589c015d0b944 Mon Sep 17 00:00:00 2001 From: jonahwilliams Date: Mon, 14 Sep 2020 16:39:59 -0700 Subject: [PATCH 1/4] [flutter_tools] add support for FLUTTER_LOCAL_ENGINE config in test driver --- packages/flutter_tools/README.md | 22 +++++++++++++++---- .../test/integration.shard/test_driver.dart | 15 +++++++++++++ 2 files changed, 33 insertions(+), 4 deletions(-) diff --git a/packages/flutter_tools/README.md b/packages/flutter_tools/README.md index bccbfe5715fcb..bd644ff1af38b 100644 --- a/packages/flutter_tools/README.md +++ b/packages/flutter_tools/README.md @@ -22,7 +22,7 @@ $ ../../bin/flutter --version To run Flutter Tools from source, in this directory run: ```shell -$ ../../bin/cache/dart-sdk/bin/dart bin/flutter_tools.dart +$ ../../bin/dart bin/flutter_tools.dart ``` followed by command-line arguments, as usual. @@ -56,24 +56,38 @@ that add new code should aim to increase coverage. In particular, the coverage of the diff should be close to the average coverage, and should ideally be better. +#### Using local engine builds in integration tests + +The integration tests can be configured to use a specific local engine +variant by setting the `FLUTTER_LOCAL_ENGINE` environment variable to the +name of the local engine (e.g. "android_debug_unopt"). If the local engine build +requires a source path, this can be provided by setting the `FLUTTER_LOCAL_ENGINE_SRC_PATH` +environment variable. This second variable is not necessary if the `flutter` and +`engine` checkouts are in adjacent directories. + +```shell +export FLUTTER_LOCAL_ENGINE=android_debug_unopt +../../bin/dart test test/integration.shard/some_test_case +``` + ### Running the tests To run the tests in the `test/` directory, first ensure that there are no connected devices. Then, in this directory run: ```shell -$ ../../bin/cache/dart-sdk/bin/pub run test +$ ../../bin/dart pub run test ``` The tests in `test/integration.shard` are slower to run than the tests in `test/general.shard`. To run only the tests in `test/general.shard`, in this directory run: ```shell -$ ../../bin/cache/dart-sdk/bin/pub run test test/general.shard +$ ../../bin/dart pub run test test/general.shard ``` To run the tests in a specific file, run: ```shell -$ ../../bin/cache/dart-sdk/bin/pub run test test/general.shard/utils_test.dart +$ ../../bin/dart pub run test test/general.shard/utils_test.dart ``` ### Forcing snapshot regeneration diff --git a/packages/flutter_tools/test/integration.shard/test_driver.dart b/packages/flutter_tools/test/integration.shard/test_driver.dart index 1154ff56ad70d..27d7d80b11fcf 100644 --- a/packages/flutter_tools/test/integration.shard/test_driver.dart +++ b/packages/flutter_tools/test/integration.shard/test_driver.dart @@ -31,6 +31,9 @@ import 'test_utils.dart'; // taking a long time are printed to the console. const bool _printDebugOutputToStdOut = false; +const String kLocalEngineEnvironment = 'FLUTTER_LOCAL_ENGINE'; +const String kLocalEngineLocation = 'FLUTTER_LOCAL_ENGINE_SRC_PATH'; + final DateTime startTime = DateTime.now(); const Duration defaultTimeout = Duration(seconds: 5); @@ -452,6 +455,10 @@ class FlutterRunTestDriver extends FlutterTestDriver { '--disable-service-auth-codes', if (machine) '--machine', if (!spawnDdsInstance) '--disable-dds', + if (platform.environment.containsKey(kLocalEngineEnvironment)) + '--local-engine=${platform.environment[kLocalEngineEnvironment]}', + if (platform.environment.containsKey(kLocalEngineLocation)) + '--local-engine-src-path=${platform.environment[kLocalEngineLocation]}', '-d', if (chrome) ...[ @@ -482,6 +489,10 @@ class FlutterRunTestDriver extends FlutterTestDriver { await _setupProcess( [ 'attach', + if (platform.environment.containsKey(kLocalEngineEnvironment)) + '--local-engine=${platform.environment[kLocalEngineEnvironment]}', + if (platform.environment.containsKey(kLocalEngineLocation)) + '--local-engine-src-path=${platform.environment[kLocalEngineLocation]}', '--machine', if (!spawnDdsInstance) '--disable-dds', @@ -705,6 +716,10 @@ class FlutterTestTestDriver extends FlutterTestDriver { }) async { await _setupProcess([ 'test', + if (platform.environment.containsKey(kLocalEngineEnvironment)) + '--local-engine=${platform.environment[kLocalEngineEnvironment]}', + if (platform.environment.containsKey(kLocalEngineLocation)) + '--local-engine-src-path=${platform.environment[kLocalEngineLocation]}', '--disable-service-auth-codes', '--machine', if (coverage) From 7696d3a9bc3bf931870e189e1d79b54854385382 Mon Sep 17 00:00:00 2001 From: jonahwilliams Date: Mon, 14 Sep 2020 16:46:03 -0700 Subject: [PATCH 2/4] the rest of the commands --- .../integration.shard/analyze_size_test.dart | 3 +++ .../build_ios_config_only_test.dart | 25 ++++++++++--------- .../command_output_test.dart | 8 ++++++ .../integration.shard/daemon_mode_test.dart | 2 +- .../test/integration.shard/test_driver.dart | 18 +++---------- .../test/integration.shard/test_utils.dart | 12 +++++++++ 6 files changed, 40 insertions(+), 28 deletions(-) diff --git a/packages/flutter_tools/test/integration.shard/analyze_size_test.dart b/packages/flutter_tools/test/integration.shard/analyze_size_test.dart index db284c78625a3..888de26bdcc9d 100644 --- a/packages/flutter_tools/test/integration.shard/analyze_size_test.dart +++ b/packages/flutter_tools/test/integration.shard/analyze_size_test.dart @@ -18,6 +18,7 @@ void main() { final String flutterBin = fileSystem.path.join(getFlutterRoot(), 'bin', 'flutter'); final ProcessResult result = await processManager.run([ flutterBin, + ...getLocalEngineArguments(), 'build', 'apk', '--analyze-size', @@ -42,6 +43,7 @@ void main() { final String flutterBin = fileSystem.path.join(getFlutterRoot(), 'bin', 'flutter'); final ProcessResult result = await processManager.run([ flutterBin, + ...getLocalEngineArguments(), 'build', 'ios', '--analyze-size', @@ -65,6 +67,7 @@ void main() { final String flutterBin = fileSystem.path.join(getFlutterRoot(), 'bin', 'flutter'); final ProcessResult result = await processManager.run([ flutterBin, + ...getLocalEngineArguments(), 'build', 'apk', '--analyze-size', diff --git a/packages/flutter_tools/test/integration.shard/build_ios_config_only_test.dart b/packages/flutter_tools/test/integration.shard/build_ios_config_only_test.dart index 494cd713c1595..c10b22e913bc5 100644 --- a/packages/flutter_tools/test/integration.shard/build_ios_config_only_test.dart +++ b/packages/flutter_tools/test/integration.shard/build_ios_config_only_test.dart @@ -5,23 +5,24 @@ import 'package:file_testing/file_testing.dart'; import 'package:flutter_tools/src/base/file_system.dart'; import 'package:flutter_tools/src/base/io.dart'; -import 'package:flutter_tools/src/base/platform.dart'; import 'package:process/process.dart'; -import 'package:flutter_tools/src/globals.dart' as globals; import '../src/common.dart'; +import 'test_utils.dart'; void main() { test('flutter build ios --config only updates generated xcconfig file without performing build', () async { - final String woringDirectory = globals.fs.path.join(getFlutterRoot(), 'examples', 'hello_world'); - final String flutterBin = globals.fs.path.join(getFlutterRoot(), 'bin', 'flutter'); + final String woringDirectory = fileSystem.path.join(getFlutterRoot(), 'examples', 'hello_world'); + final String flutterBin = fileSystem.path.join(getFlutterRoot(), 'bin', 'flutter'); - await const LocalProcessManager().run([ + await processManager.run([ flutterBin, + ...getLocalEngineArguments(), 'clean', ], workingDirectory: woringDirectory); - final ProcessResult result = await const LocalProcessManager().run([ + final ProcessResult result = await processManager.run([ flutterBin, + ...getLocalEngineArguments(), 'build', 'ios', '--config-only', @@ -36,20 +37,20 @@ void main() { expect(result.exitCode, 0); - final File generatedConfig = globals.fs.file( - globals.fs.path.join(woringDirectory, 'ios', 'Flutter', 'Generated.xcconfig')); + final File generatedConfig = fileSystem.file( + fileSystem.path.join(woringDirectory, 'ios', 'Flutter', 'Generated.xcconfig')); // Config is updated if command succeeded. expect(generatedConfig, exists); expect(generatedConfig.readAsStringSync(), allOf( contains('DART_OBFUSCATION=true'), - contains('FLUTTER_FRAMEWORK_DIR=${globals.fs.path.absolute(getFlutterRoot(), 'bin', 'cache', 'artifacts', 'engine')}'), + contains('FLUTTER_FRAMEWORK_DIR=${fileSystem.path.absolute(getFlutterRoot(), 'bin', 'cache', 'artifacts', 'engine')}'), )); // file that only exists if app was fully built. - final File frameworkPlist = globals.fs.file( - globals.fs.path.join(woringDirectory, 'build', 'ios', 'iphoneos', 'Runner.app', 'AppFrameworkInfo.plist')); + final File frameworkPlist = fileSystem.file( + fileSystem.path.join(woringDirectory, 'build', 'ios', 'iphoneos', 'Runner.app', 'AppFrameworkInfo.plist')); expect(frameworkPlist, isNot(exists)); - },skip: !const LocalPlatform().isMacOS); + }, skip: !platform.isMacOS); } diff --git a/packages/flutter_tools/test/integration.shard/command_output_test.dart b/packages/flutter_tools/test/integration.shard/command_output_test.dart index 698b13b5c66ef..af49bb0f68289 100644 --- a/packages/flutter_tools/test/integration.shard/command_output_test.dart +++ b/packages/flutter_tools/test/integration.shard/command_output_test.dart @@ -16,6 +16,7 @@ void main() { final String flutterBin = fileSystem.path.join(getFlutterRoot(), 'bin', 'flutter'); final ProcessResult result = await processManager.run([ flutterBin, + ...getLocalEngineArguments(), '-h', '-v', ]); @@ -36,6 +37,7 @@ void main() { final String flutterBin = fileSystem.path.join(getFlutterRoot(), 'bin', 'flutter'); final ProcessResult result = await processManager.run([ flutterBin, + ...getLocalEngineArguments(), 'doctor', '-v', ]); @@ -48,6 +50,7 @@ void main() { final String flutterBin = fileSystem.path.join(getFlutterRoot(), 'bin', 'flutter'); final ProcessResult result = await processManager.run([ flutterBin, + ...getLocalEngineArguments(), 'doctor', '-vv', ]); @@ -60,6 +63,7 @@ void main() { final String flutterBin = fileSystem.path.join(getFlutterRoot(), 'bin', 'flutter'); final ProcessResult result = await processManager.run([ flutterBin, + ...getLocalEngineArguments(), 'config', ]); @@ -89,6 +93,7 @@ void main() { final String flutterBin = fileSystem.path.join(getFlutterRoot(), 'bin', 'flutter'); final ProcessResult result = await processManager.run([ flutterBin, + ...getLocalEngineArguments(), 'run', '--show-test-device', // ensure command can fail to run and hit injection of correct logger. '--machine', @@ -105,6 +110,7 @@ void main() { final String flutterBin = fileSystem.path.join(getFlutterRoot(), 'bin', 'flutter'); final ProcessResult result = await processManager.run([ flutterBin, + ...getLocalEngineArguments(), 'attach', '--machine', '-v', @@ -117,6 +123,7 @@ void main() { final String flutterBin = fileSystem.path.join(getFlutterRoot(), 'bin', 'flutter'); final ProcessResult result = await processManager.run([ flutterBin, + ...getLocalEngineArguments(), 'build', '-h', '-v', @@ -133,6 +140,7 @@ void main() { final String flutterBin = fileSystem.path.join(getFlutterRoot(), 'bin', 'flutter'); final ProcessResult result = await processManager.run([ flutterBin, + ...getLocalEngineArguments(), '--version', '--machine', ]); diff --git a/packages/flutter_tools/test/integration.shard/daemon_mode_test.dart b/packages/flutter_tools/test/integration.shard/daemon_mode_test.dart index 6932d469e4fc1..c8c015477ee24 100644 --- a/packages/flutter_tools/test/integration.shard/daemon_mode_test.dart +++ b/packages/flutter_tools/test/integration.shard/daemon_mode_test.dart @@ -27,7 +27,7 @@ void main() { const ProcessManager processManager = LocalProcessManager(); final Process process = await processManager.start( - [flutterBin, '--show-test-device', 'daemon'], + [flutterBin, ...getLocalEngineArguments(), '--show-test-device', 'daemon'], workingDirectory: tempDir.path, ); diff --git a/packages/flutter_tools/test/integration.shard/test_driver.dart b/packages/flutter_tools/test/integration.shard/test_driver.dart index 27d7d80b11fcf..8c5706367ddb3 100644 --- a/packages/flutter_tools/test/integration.shard/test_driver.dart +++ b/packages/flutter_tools/test/integration.shard/test_driver.dart @@ -31,9 +31,6 @@ import 'test_utils.dart'; // taking a long time are printed to the console. const bool _printDebugOutputToStdOut = false; -const String kLocalEngineEnvironment = 'FLUTTER_LOCAL_ENGINE'; -const String kLocalEngineLocation = 'FLUTTER_LOCAL_ENGINE_SRC_PATH'; - final DateTime startTime = DateTime.now(); const Duration defaultTimeout = Duration(seconds: 5); @@ -455,10 +452,7 @@ class FlutterRunTestDriver extends FlutterTestDriver { '--disable-service-auth-codes', if (machine) '--machine', if (!spawnDdsInstance) '--disable-dds', - if (platform.environment.containsKey(kLocalEngineEnvironment)) - '--local-engine=${platform.environment[kLocalEngineEnvironment]}', - if (platform.environment.containsKey(kLocalEngineLocation)) - '--local-engine-src-path=${platform.environment[kLocalEngineLocation]}', + ...getLocalEngineArguments(), '-d', if (chrome) ...[ @@ -489,10 +483,7 @@ class FlutterRunTestDriver extends FlutterTestDriver { await _setupProcess( [ 'attach', - if (platform.environment.containsKey(kLocalEngineEnvironment)) - '--local-engine=${platform.environment[kLocalEngineEnvironment]}', - if (platform.environment.containsKey(kLocalEngineLocation)) - '--local-engine-src-path=${platform.environment[kLocalEngineLocation]}', + ...getLocalEngineArguments(), '--machine', if (!spawnDdsInstance) '--disable-dds', @@ -716,10 +707,7 @@ class FlutterTestTestDriver extends FlutterTestDriver { }) async { await _setupProcess([ 'test', - if (platform.environment.containsKey(kLocalEngineEnvironment)) - '--local-engine=${platform.environment[kLocalEngineEnvironment]}', - if (platform.environment.containsKey(kLocalEngineLocation)) - '--local-engine-src-path=${platform.environment[kLocalEngineLocation]}', + ...getLocalEngineArguments(), '--disable-service-auth-codes', '--machine', if (coverage) diff --git a/packages/flutter_tools/test/integration.shard/test_utils.dart b/packages/flutter_tools/test/integration.shard/test_utils.dart index 50459cfb186d8..78f1fcb9f0dc6 100644 --- a/packages/flutter_tools/test/integration.shard/test_utils.dart +++ b/packages/flutter_tools/test/integration.shard/test_utils.dart @@ -63,3 +63,15 @@ Future getPackages(String folder) async { throw Exception('flutter pub get failed: ${result.stderr}\n${result.stdout}'); } } + +const String kLocalEngineEnvironment = 'FLUTTER_LOCAL_ENGINE'; +const String kLocalEngineLocation = 'FLUTTER_LOCAL_ENGINE_SRC_PATH'; + +List getLocalEngineArguments() { + return [ + if (platform.environment.containsKey(kLocalEngineEnvironment)) + '--local-engine=${platform.environment[kLocalEngineEnvironment]}', + if (platform.environment.containsKey(kLocalEngineLocation)) + '--local-engine-src-path=${platform.environment[kLocalEngineLocation]}', + ]; +} \ No newline at end of file From 744c169ebf8c5cb86133c9abdf49de309afdad6e Mon Sep 17 00:00:00 2001 From: jonahwilliams Date: Mon, 14 Sep 2020 16:55:42 -0700 Subject: [PATCH 3/4] fix analysis --- .../test/integration.shard/build_ios_config_only_test.dart | 1 - 1 file changed, 1 deletion(-) diff --git a/packages/flutter_tools/test/integration.shard/build_ios_config_only_test.dart b/packages/flutter_tools/test/integration.shard/build_ios_config_only_test.dart index c10b22e913bc5..d3da2aaf10d19 100644 --- a/packages/flutter_tools/test/integration.shard/build_ios_config_only_test.dart +++ b/packages/flutter_tools/test/integration.shard/build_ios_config_only_test.dart @@ -5,7 +5,6 @@ import 'package:file_testing/file_testing.dart'; import 'package:flutter_tools/src/base/file_system.dart'; import 'package:flutter_tools/src/base/io.dart'; -import 'package:process/process.dart'; import '../src/common.dart'; import 'test_utils.dart'; From f68c6fc5c489fb12d6b3e67ee9bcb59d02cde159 Mon Sep 17 00:00:00 2001 From: Jonah Williams Date: Mon, 14 Sep 2020 19:08:02 -0700 Subject: [PATCH 4/4] Update test_utils.dart --- packages/flutter_tools/test/integration.shard/test_utils.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/flutter_tools/test/integration.shard/test_utils.dart b/packages/flutter_tools/test/integration.shard/test_utils.dart index 78f1fcb9f0dc6..f6d39977b634c 100644 --- a/packages/flutter_tools/test/integration.shard/test_utils.dart +++ b/packages/flutter_tools/test/integration.shard/test_utils.dart @@ -74,4 +74,4 @@ List getLocalEngineArguments() { if (platform.environment.containsKey(kLocalEngineLocation)) '--local-engine-src-path=${platform.environment[kLocalEngineLocation]}', ]; -} \ No newline at end of file +} pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy