Auto-format Framework (#160545)
This auto-formats all *.dart files in the repository outside of the `engine` subdirectory and enforces that these files stay formatted with a presubmit check. **Reviewers:** Please carefully review all the commits except for the one titled "formatted". The "formatted" commit was auto-generated by running `dev/tools/format.sh -a -f`. The other commits were hand-crafted to prepare the repo for the formatting change. I recommend reviewing the commits one-by-one via the "Commits" tab and avoiding Github's "Files changed" tab as it will likely slow down your browser because of the size of this PR. --------- Co-authored-by: Kate Lovett <katelovett@google.com> Co-authored-by: LongCatIsLooong <31859944+LongCatIsLooong@users.noreply.github.com>
This commit is contained in:
committed by
GitHub
parent
8e0993eda8
commit
5491c8c146
@@ -57,7 +57,8 @@ Future<void> main(List<String> rawArgs) async {
|
||||
final bool exitOnFirstTestFailure = (args['exit'] as bool?) ?? false;
|
||||
|
||||
/// Whether to tell tasks to clean up after themselves.
|
||||
final bool terminateStrayDartProcesses = (args['terminate-stray-dart-processes'] as bool?) ?? false;
|
||||
final bool terminateStrayDartProcesses =
|
||||
(args['terminate-stray-dart-processes'] as bool?) ?? false;
|
||||
|
||||
/// The git branch being tested on.
|
||||
final String? gitBranch = args['git-branch'] as String?;
|
||||
@@ -90,12 +91,16 @@ Future<void> main(List<String> rawArgs) async {
|
||||
final int runsPerTest = int.parse(args['ab'] as String);
|
||||
final String resultsFile = args['ab-result-file'] as String? ?? 'ABresults#.json';
|
||||
if (taskNames.length > 1) {
|
||||
stderr.writeln('When running in A/B test mode exactly one task must be passed but got ${taskNames.join(', ')}.\n');
|
||||
stderr.writeln(
|
||||
'When running in A/B test mode exactly one task must be passed but got ${taskNames.join(', ')}.\n',
|
||||
);
|
||||
stderr.writeln(argParser.usage);
|
||||
exit(1);
|
||||
}
|
||||
if (localEngine == null && localWebSdk == null) {
|
||||
stderr.writeln('When running in A/B test mode --local-engine or --local-web-sdk is required.\n');
|
||||
stderr.writeln(
|
||||
'When running in A/B test mode --local-engine or --local-web-sdk is required.\n',
|
||||
);
|
||||
stderr.writeln(argParser.usage);
|
||||
exit(1);
|
||||
}
|
||||
@@ -117,7 +122,8 @@ Future<void> main(List<String> rawArgs) async {
|
||||
onlyLocalEngine: (args['ab-local-engine-only'] as bool?) ?? false,
|
||||
);
|
||||
} else {
|
||||
await runTasks(taskNames,
|
||||
await runTasks(
|
||||
taskNames,
|
||||
silent: silent,
|
||||
localEngine: localEngine,
|
||||
localEngineHost: localEngineHost,
|
||||
@@ -240,7 +246,8 @@ ArgParser createArgParser(List<String> taskNames) {
|
||||
..addMultiOption(
|
||||
'task',
|
||||
abbr: 't',
|
||||
help: 'Name of a Dart file in bin/tasks.\n'
|
||||
help:
|
||||
'Name of a Dart file in bin/tasks.\n'
|
||||
' Example: complex_layout__start_up\n'
|
||||
'\n'
|
||||
'This option may be repeated to specify multiple tasks.',
|
||||
@@ -251,22 +258,24 @@ ArgParser createArgParser(List<String> taskNames) {
|
||||
..addOption(
|
||||
'device-id',
|
||||
abbr: 'd',
|
||||
help: 'Target device id (prefixes are allowed, names are not supported).\n'
|
||||
'The option will be ignored if the test target does not run on a\n'
|
||||
'mobile device. This still respects the device operating system\n'
|
||||
'settings in the test case, and will results in error if no device\n'
|
||||
'with given ID/ID prefix is found.',
|
||||
help:
|
||||
'Target device id (prefixes are allowed, names are not supported).\n'
|
||||
'The option will be ignored if the test target does not run on a\n'
|
||||
'mobile device. This still respects the device operating system\n'
|
||||
'settings in the test case, and will results in error if no device\n'
|
||||
'with given ID/ID prefix is found.',
|
||||
)
|
||||
..addOption(
|
||||
'ab',
|
||||
help: 'Runs an A/B test comparing the default engine with the local\n'
|
||||
'engine build for one task. This option does not support running\n'
|
||||
'multiple tasks. The value is the number of times to run the task.\n'
|
||||
'The task is expected to be a benchmark that reports score keys.\n'
|
||||
'The A/B test collects the metrics collected by the test and\n'
|
||||
'produces a report containing averages, noise, and the speed-up\n'
|
||||
'between the two engines. --local-engine is required when running\n'
|
||||
'an A/B test.',
|
||||
help:
|
||||
'Runs an A/B test comparing the default engine with the local\n'
|
||||
'engine build for one task. This option does not support running\n'
|
||||
'multiple tasks. The value is the number of times to run the task.\n'
|
||||
'The task is expected to be a benchmark that reports score keys.\n'
|
||||
'The A/B test collects the metrics collected by the test and\n'
|
||||
'produces a report containing averages, noise, and the speed-up\n'
|
||||
'between the two engines. --local-engine is required when running\n'
|
||||
'an A/B test.',
|
||||
callback: (String? value) {
|
||||
if (value != null && int.tryParse(value) == null) {
|
||||
throw ArgParserException('Option --ab must be a number, but was "$value".');
|
||||
@@ -275,96 +284,106 @@ ArgParser createArgParser(List<String> taskNames) {
|
||||
)
|
||||
..addOption(
|
||||
'ab-result-file',
|
||||
help: 'The filename in which to place the json encoded results of an A/B test.\n'
|
||||
'The filename may contain a single # character to be replaced by a sequence\n'
|
||||
'number if the name already exists.',
|
||||
help:
|
||||
'The filename in which to place the json encoded results of an A/B test.\n'
|
||||
'The filename may contain a single # character to be replaced by a sequence\n'
|
||||
'number if the name already exists.',
|
||||
)
|
||||
..addFlag(
|
||||
'ab-local-engine-only',
|
||||
help: 'When running the A/B aggregator, do not run benchmarks with the default engine (A), only the local engine (B).\n'
|
||||
'Shows the averages and noise report for the local engine without comparison to anything else.',
|
||||
help:
|
||||
'When running the A/B aggregator, do not run benchmarks with the default engine (A), only the local engine (B).\n'
|
||||
'Shows the averages and noise report for the local engine without comparison to anything else.',
|
||||
)
|
||||
..addFlag(
|
||||
'exit',
|
||||
help: 'Exit on the first test failure. Currently flakes are intentionally (though '
|
||||
'incorrectly) not considered to be failures.',
|
||||
help:
|
||||
'Exit on the first test failure. Currently flakes are intentionally (though '
|
||||
'incorrectly) not considered to be failures.',
|
||||
)
|
||||
..addOption(
|
||||
'git-branch',
|
||||
help: '[Flutter infrastructure] Git branch of the current commit. LUCI\n'
|
||||
'checkouts run in detached HEAD state, so the branch must be passed.',
|
||||
help:
|
||||
'[Flutter infrastructure] Git branch of the current commit. LUCI\n'
|
||||
'checkouts run in detached HEAD state, so the branch must be passed.',
|
||||
)
|
||||
..addOption(
|
||||
'local-engine',
|
||||
help: 'Name of a build output within the engine out directory, if you\n'
|
||||
'are building Flutter locally. Use this to select a specific\n'
|
||||
'version of the engine if you have built multiple engine targets.\n'
|
||||
'This path is relative to --local-engine-src-path/out. This option\n'
|
||||
'is required when running an A/B test (see the --ab option).',
|
||||
help:
|
||||
'Name of a build output within the engine out directory, if you\n'
|
||||
'are building Flutter locally. Use this to select a specific\n'
|
||||
'version of the engine if you have built multiple engine targets.\n'
|
||||
'This path is relative to --local-engine-src-path/out. This option\n'
|
||||
'is required when running an A/B test (see the --ab option).',
|
||||
)
|
||||
..addOption(
|
||||
'local-engine-host',
|
||||
help: 'Name of a build output within the engine out directory, if you\n'
|
||||
'are building Flutter locally. Use this to select a specific\n'
|
||||
'version of the engine to use as the host platform if you have built '
|
||||
'multiple engine targets.\n'
|
||||
'This path is relative to --local-engine-src-path/out. This option\n'
|
||||
'is required when running an A/B test (see the --ab option).',
|
||||
help:
|
||||
'Name of a build output within the engine out directory, if you\n'
|
||||
'are building Flutter locally. Use this to select a specific\n'
|
||||
'version of the engine to use as the host platform if you have built '
|
||||
'multiple engine targets.\n'
|
||||
'This path is relative to --local-engine-src-path/out. This option\n'
|
||||
'is required when running an A/B test (see the --ab option).',
|
||||
)
|
||||
..addOption(
|
||||
'local-web-sdk',
|
||||
help: 'Name of a build output within the engine out directory, if you\n'
|
||||
'are building Flutter locally. Use this to select a specific\n'
|
||||
'version of the engine if you have built multiple engine targets.\n'
|
||||
'This path is relative to --local-engine-src-path/out. This option\n'
|
||||
'is required when running an A/B test (see the --ab option).',
|
||||
help:
|
||||
'Name of a build output within the engine out directory, if you\n'
|
||||
'are building Flutter locally. Use this to select a specific\n'
|
||||
'version of the engine if you have built multiple engine targets.\n'
|
||||
'This path is relative to --local-engine-src-path/out. This option\n'
|
||||
'is required when running an A/B test (see the --ab option).',
|
||||
)
|
||||
..addFlag(
|
||||
'list',
|
||||
abbr: 'l',
|
||||
help: "Don't actually run the tasks, but list out the tasks that would\n"
|
||||
'have been run, in the order they would have run.',
|
||||
help:
|
||||
"Don't actually run the tasks, but list out the tasks that would\n"
|
||||
'have been run, in the order they would have run.',
|
||||
)
|
||||
..addOption(
|
||||
'local-engine-src-path',
|
||||
help: 'Path to your engine src directory, if you are building Flutter\n'
|
||||
'locally. Defaults to \$FLUTTER_ENGINE if set, or tries to guess at\n'
|
||||
'the location based on the value of the --flutter-root option.',
|
||||
help:
|
||||
'Path to your engine src directory, if you are building Flutter\n'
|
||||
'locally. Defaults to \$FLUTTER_ENGINE if set, or tries to guess at\n'
|
||||
'the location based on the value of the --flutter-root option.',
|
||||
)
|
||||
..addOption(
|
||||
'luci-builder',
|
||||
help: '[Flutter infrastructure] Name of the LUCI builder being run on.',
|
||||
)
|
||||
..addOption('luci-builder', help: '[Flutter infrastructure] Name of the LUCI builder being run on.')
|
||||
..addOption(
|
||||
'results-file',
|
||||
help: '[Flutter infrastructure] File path for test results. If passed with\n'
|
||||
'task, will write test results to the file.'
|
||||
help:
|
||||
'[Flutter infrastructure] File path for test results. If passed with\n'
|
||||
'task, will write test results to the file.',
|
||||
)
|
||||
..addOption(
|
||||
'service-account-token-file',
|
||||
help: '[Flutter infrastructure] Authentication for uploading results.',
|
||||
)
|
||||
..addFlag(
|
||||
'silent',
|
||||
help: 'Reduce verbosity slightly.',
|
||||
)
|
||||
..addFlag('silent', help: 'Reduce verbosity slightly.')
|
||||
..addFlag(
|
||||
'terminate-stray-dart-processes',
|
||||
defaultsTo: true,
|
||||
help: 'Whether to send a SIGKILL signal to any Dart processes that are still '
|
||||
'running when a task is completed. If any Dart processes are terminated '
|
||||
'in this way, the test is considered to have failed.',
|
||||
help:
|
||||
'Whether to send a SIGKILL signal to any Dart processes that are still '
|
||||
'running when a task is completed. If any Dart processes are terminated '
|
||||
'in this way, the test is considered to have failed.',
|
||||
)
|
||||
..addFlag(
|
||||
'use-emulator',
|
||||
help: 'If this is an android test, use an emulator to run the test instead of '
|
||||
'a physical device.'
|
||||
help:
|
||||
'If this is an android test, use an emulator to run the test instead of '
|
||||
'a physical device.',
|
||||
)
|
||||
..addMultiOption(
|
||||
'test',
|
||||
hide: true,
|
||||
callback: (List<String> value) {
|
||||
if (value.isNotEmpty) {
|
||||
throw const FormatException(
|
||||
'Invalid option --test. Did you mean --task (-t)?',
|
||||
);
|
||||
throw const FormatException('Invalid option --test. Did you mean --task (-t)?');
|
||||
}
|
||||
},
|
||||
);
|
||||
|
||||
@@ -30,7 +30,7 @@ Future<void> main(List<String> rawArgs) async {
|
||||
return;
|
||||
}
|
||||
|
||||
final List<String> jsonFiles = args.rest.isNotEmpty ? args.rest : <String>[ 'ABresults.json' ];
|
||||
final List<String> jsonFiles = args.rest.isNotEmpty ? args.rest : <String>['ABresults.json'];
|
||||
|
||||
for (final String filename in jsonFiles) {
|
||||
final File file = File(filename);
|
||||
@@ -42,7 +42,7 @@ Future<void> main(List<String> rawArgs) async {
|
||||
ABTest test;
|
||||
try {
|
||||
test = ABTest.fromJsonMap(
|
||||
const JsonDecoder().convert(await file.readAsString()) as Map<String, dynamic>
|
||||
const JsonDecoder().convert(await file.readAsString()) as Map<String, dynamic>,
|
||||
);
|
||||
} catch (error) {
|
||||
_usage('Could not parse json file "$filename"');
|
||||
@@ -65,20 +65,22 @@ Future<void> main(List<String> rawArgs) async {
|
||||
}
|
||||
|
||||
/// Command-line options for the `summarize.dart` command.
|
||||
final ArgParser _argParser = ArgParser()
|
||||
..addFlag(
|
||||
kAsciiTableOpt,
|
||||
defaultsTo: true,
|
||||
help: 'Prints the summary in a table formatted nicely for terminal output.',
|
||||
)
|
||||
..addFlag(
|
||||
kTabTableOpt,
|
||||
defaultsTo: true,
|
||||
help: 'Prints the summary in a table with tabs for easy spreadsheet entry.',
|
||||
)
|
||||
..addFlag(
|
||||
kRawSummaryOpt,
|
||||
defaultsTo: true,
|
||||
help: 'Prints all per-run data collected by the A/B test formatted with\n'
|
||||
'tabs for easy spreadsheet entry.',
|
||||
);
|
||||
final ArgParser _argParser =
|
||||
ArgParser()
|
||||
..addFlag(
|
||||
kAsciiTableOpt,
|
||||
defaultsTo: true,
|
||||
help: 'Prints the summary in a table formatted nicely for terminal output.',
|
||||
)
|
||||
..addFlag(
|
||||
kTabTableOpt,
|
||||
defaultsTo: true,
|
||||
help: 'Prints the summary in a table with tabs for easy spreadsheet entry.',
|
||||
)
|
||||
..addFlag(
|
||||
kRawSummaryOpt,
|
||||
defaultsTo: true,
|
||||
help:
|
||||
'Prints all per-run data collected by the A/B test formatted with\n'
|
||||
'tabs for easy spreadsheet entry.',
|
||||
);
|
||||
|
||||
@@ -16,11 +16,36 @@ import 'package:flutter_devicelab/framework/framework.dart';
|
||||
// - Kotlin: No methodology as of yet.
|
||||
// (*) - support range defined in packages/flutter_tools/gradle/src/main/kotlin/dependency_version_checker.gradle.kts.
|
||||
List<VersionTuple> versionTuples = <VersionTuple>[
|
||||
VersionTuple(agpVersion: '7.0.1', gradleVersion: '7.0.2', kotlinVersion: '1.7.10', compileSdkVersion: '34'),
|
||||
VersionTuple(agpVersion: '7.1.0', gradleVersion: '7.2', kotlinVersion: '1.7.10', compileSdkVersion: '34'),
|
||||
VersionTuple(agpVersion: '7.2.0', gradleVersion: '7.3.3', kotlinVersion: '1.7.10', compileSdkVersion: '34'),
|
||||
VersionTuple(agpVersion: '7.3.0', gradleVersion: '7.4', kotlinVersion: '1.7.10', compileSdkVersion: '34'),
|
||||
VersionTuple(agpVersion: '7.4.0', gradleVersion: '7.5', kotlinVersion: '1.8.10', compileSdkVersion: '34'),
|
||||
VersionTuple(
|
||||
agpVersion: '7.0.1',
|
||||
gradleVersion: '7.0.2',
|
||||
kotlinVersion: '1.7.10',
|
||||
compileSdkVersion: '34',
|
||||
),
|
||||
VersionTuple(
|
||||
agpVersion: '7.1.0',
|
||||
gradleVersion: '7.2',
|
||||
kotlinVersion: '1.7.10',
|
||||
compileSdkVersion: '34',
|
||||
),
|
||||
VersionTuple(
|
||||
agpVersion: '7.2.0',
|
||||
gradleVersion: '7.3.3',
|
||||
kotlinVersion: '1.7.10',
|
||||
compileSdkVersion: '34',
|
||||
),
|
||||
VersionTuple(
|
||||
agpVersion: '7.3.0',
|
||||
gradleVersion: '7.4',
|
||||
kotlinVersion: '1.7.10',
|
||||
compileSdkVersion: '34',
|
||||
),
|
||||
VersionTuple(
|
||||
agpVersion: '7.4.0',
|
||||
gradleVersion: '7.5',
|
||||
kotlinVersion: '1.8.10',
|
||||
compileSdkVersion: '34',
|
||||
),
|
||||
];
|
||||
|
||||
// This test requires a Java version less than 17 due to the intentionally low
|
||||
@@ -32,14 +57,14 @@ Future<void> main() async {
|
||||
/// The [FileSystem] for the integration test environment.
|
||||
const LocalFileSystem fileSystem = LocalFileSystem();
|
||||
|
||||
final Directory tempDir = fileSystem
|
||||
.systemTempDirectory
|
||||
.createTempSync('flutter_android_dependency_version_tests');
|
||||
final Directory tempDir = fileSystem.systemTempDirectory.createTempSync(
|
||||
'flutter_android_dependency_version_tests',
|
||||
);
|
||||
await task(() {
|
||||
return buildFlutterApkWithSpecifiedDependencyVersions(
|
||||
versionTuples: versionTuples,
|
||||
tempDir: tempDir,
|
||||
localFileSystem: fileSystem
|
||||
versionTuples: versionTuples,
|
||||
tempDir: tempDir,
|
||||
localFileSystem: fileSystem,
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -17,7 +17,12 @@ import 'package:flutter_devicelab/framework/framework.dart';
|
||||
// (*) - support range defined in packages/flutter_tools/gradle/src/main/kotlin/dependency_version_checker.gradle.kts.
|
||||
// Note that compileSdk 35 requires AGP 8.1.0+, so override to compileSdk 34 for AGP 8.0.
|
||||
List<VersionTuple> versionTuples = <VersionTuple>[
|
||||
VersionTuple(agpVersion: '8.0.0', gradleVersion: '8.0', kotlinVersion: '1.8.22', compileSdkVersion: '34'),
|
||||
VersionTuple(
|
||||
agpVersion: '8.0.0',
|
||||
gradleVersion: '8.0',
|
||||
kotlinVersion: '1.8.22',
|
||||
compileSdkVersion: '34',
|
||||
),
|
||||
VersionTuple(agpVersion: '8.1.0', gradleVersion: '8.0', kotlinVersion: '1.8.22'),
|
||||
VersionTuple(agpVersion: '8.2.0', gradleVersion: '8.2', kotlinVersion: '1.8.22'),
|
||||
VersionTuple(agpVersion: '8.3.0', gradleVersion: '8.4', kotlinVersion: '1.8.22'),
|
||||
@@ -31,8 +36,14 @@ Future<void> main() async {
|
||||
/// The [FileSystem] for the integration test environment.
|
||||
const LocalFileSystem fileSystem = LocalFileSystem();
|
||||
|
||||
final Directory tempDir = fileSystem.systemTempDirectory.createTempSync('flutter_android_dependency_version_tests');
|
||||
final Directory tempDir = fileSystem.systemTempDirectory.createTempSync(
|
||||
'flutter_android_dependency_version_tests',
|
||||
);
|
||||
await task(() {
|
||||
return buildFlutterApkWithSpecifiedDependencyVersions(versionTuples: versionTuples, tempDir: tempDir, localFileSystem: fileSystem);
|
||||
return buildFlutterApkWithSpecifiedDependencyVersions(
|
||||
versionTuples: versionTuples,
|
||||
tempDir: tempDir,
|
||||
localFileSystem: fileSystem,
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -15,13 +15,16 @@ Future<void> main() async {
|
||||
await runProjectTest((FlutterProject flutterProject) async {
|
||||
section('APK content for task assembleRelease with --obfuscate');
|
||||
await inDirectory(flutterProject.rootPath, () async {
|
||||
await flutter('build', options: <String>[
|
||||
'apk',
|
||||
'--target-platform=android-arm',
|
||||
'--obfuscate',
|
||||
'--split-debug-info=foo/',
|
||||
'--verbose',
|
||||
]);
|
||||
await flutter(
|
||||
'build',
|
||||
options: <String>[
|
||||
'apk',
|
||||
'--target-platform=android-arm',
|
||||
'--obfuscate',
|
||||
'--split-debug-info=foo/',
|
||||
'--verbose',
|
||||
],
|
||||
);
|
||||
});
|
||||
final String outputApkDirectory = path.join(
|
||||
flutterProject.rootPath,
|
||||
@@ -40,11 +43,10 @@ Future<void> main() async {
|
||||
await inDirectory(flutterProject.rootPath, () async {
|
||||
await exec('unzip', <String>[outputApkDirectory]);
|
||||
checkFileExists(path.join(flutterProject.rootPath, 'lib/armeabi-v7a/libapp.so'));
|
||||
final String response = await eval(
|
||||
'grep',
|
||||
<String>[flutterProject.name, 'lib/armeabi-v7a/libapp.so'],
|
||||
canFail: true,
|
||||
);
|
||||
final String response = await eval('grep', <String>[
|
||||
flutterProject.name,
|
||||
'lib/armeabi-v7a/libapp.so',
|
||||
], canFail: true);
|
||||
if (response.trim().contains('matches')) {
|
||||
foundApkProjectName = true;
|
||||
}
|
||||
@@ -56,15 +58,18 @@ Future<void> main() async {
|
||||
section('AAR content with --obfuscate');
|
||||
|
||||
await inDirectory(flutterProject.rootPath, () async {
|
||||
await flutter('build', options: <String>[
|
||||
'aar',
|
||||
'--target-platform=android-arm',
|
||||
'--obfuscate',
|
||||
'--split-debug-info=foo/',
|
||||
'--no-debug',
|
||||
'--no-profile',
|
||||
'--verbose',
|
||||
]);
|
||||
await flutter(
|
||||
'build',
|
||||
options: <String>[
|
||||
'aar',
|
||||
'--target-platform=android-arm',
|
||||
'--obfuscate',
|
||||
'--split-debug-info=foo/',
|
||||
'--no-debug',
|
||||
'--no-profile',
|
||||
'--verbose',
|
||||
],
|
||||
);
|
||||
});
|
||||
|
||||
final String outputAarDirectory = path.join(
|
||||
@@ -83,11 +88,10 @@ Future<void> main() async {
|
||||
await inDirectory(flutterProject.rootPath, () async {
|
||||
await exec('unzip', <String>[outputAarDirectory]);
|
||||
checkFileExists(path.join(flutterProject.rootPath, 'jni/armeabi-v7a/libapp.so'));
|
||||
final String response = await eval(
|
||||
'grep',
|
||||
<String>[flutterProject.name, 'jni/armeabi-v7a/libapp.so'],
|
||||
canFail: true,
|
||||
);
|
||||
final String response = await eval('grep', <String>[
|
||||
flutterProject.name,
|
||||
'jni/armeabi-v7a/libapp.so',
|
||||
], canFail: true);
|
||||
if (response.trim().contains('matches')) {
|
||||
foundAarProjectName = true;
|
||||
}
|
||||
|
||||
@@ -16,12 +16,21 @@ Future<void> main() async {
|
||||
try {
|
||||
await runProjectTest((FlutterProject flutterProject) async {
|
||||
// Create dev_dependency plugin to use for test.
|
||||
final Directory tempDir = Directory.systemTemp.createTempSync('android_release_builds_exclude_dev_dependencies_test.');
|
||||
final Directory tempDir = Directory.systemTemp.createTempSync(
|
||||
'android_release_builds_exclude_dev_dependencies_test.',
|
||||
);
|
||||
const String devDependencyPluginOrg = 'com.example.dev_dependency_plugin';
|
||||
await FlutterPluginProject.create(tempDir, 'dev_dependency_plugin', options: <String>['--platforms=android', '--org=$devDependencyPluginOrg']);
|
||||
await FlutterPluginProject.create(
|
||||
tempDir,
|
||||
'dev_dependency_plugin',
|
||||
options: <String>['--platforms=android', '--org=$devDependencyPluginOrg'],
|
||||
);
|
||||
|
||||
// Add devDependencyPlugin as dependency of flutterProject.
|
||||
await flutterProject.addPlugin('dev_dependency_plugin', options: <String>['--path', path.join(tempDir.path, 'dev_dependency_plugin')]);
|
||||
await flutterProject.addPlugin(
|
||||
'dev_dependency_plugin',
|
||||
options: <String>['--path', path.join(tempDir.path, 'dev_dependency_plugin')],
|
||||
);
|
||||
|
||||
final List<String> buildModesToTest = <String>['debug', 'profile', 'release'];
|
||||
for (final String buildMode in buildModesToTest) {
|
||||
@@ -29,32 +38,46 @@ Future<void> main() async {
|
||||
|
||||
// Build APK in buildMode and check that devDependencyPlugin is included/excluded in the APK as expected.
|
||||
await inDirectory(flutterProject.rootPath, () async {
|
||||
await flutter('build', options: <String>[
|
||||
'apk',
|
||||
'--$buildMode',
|
||||
'--target-platform=android-arm',
|
||||
]);
|
||||
await flutter(
|
||||
'build',
|
||||
options: <String>['apk', '--$buildMode', '--target-platform=android-arm'],
|
||||
);
|
||||
|
||||
final File apk = File(path.join(flutterProject.rootPath, 'build', 'app', 'outputs', 'flutter-apk', 'app-debug.apk'));
|
||||
final File apk = File(
|
||||
path.join(
|
||||
flutterProject.rootPath,
|
||||
'build',
|
||||
'app',
|
||||
'outputs',
|
||||
'flutter-apk',
|
||||
'app-debug.apk',
|
||||
),
|
||||
);
|
||||
if (!apk.existsSync()) {
|
||||
throw TaskResult.failure("Expected ${apk.path} to exist, but it doesn't.");
|
||||
}
|
||||
|
||||
// We expect the APK to include the devDependencyPlugin except in release mode.
|
||||
final bool isTestingReleaseMode = buildMode == 'release';
|
||||
final bool apkIncludesDevDependency = await checkApkContainsMethodsFromLibrary(apk, devDependencyPluginOrg);
|
||||
final bool apkIncludesDevDependencyAsExpected = isTestingReleaseMode ? !apkIncludesDevDependency : apkIncludesDevDependency;
|
||||
final bool apkIncludesDevDependency = await checkApkContainsMethodsFromLibrary(
|
||||
apk,
|
||||
devDependencyPluginOrg,
|
||||
);
|
||||
final bool apkIncludesDevDependencyAsExpected =
|
||||
isTestingReleaseMode ? !apkIncludesDevDependency : apkIncludesDevDependency;
|
||||
if (!apkIncludesDevDependencyAsExpected) {
|
||||
return TaskResult.failure('Expected to${isTestingReleaseMode ? ' not' : ''} find dev_dependency_plugin in APK built with debug mode but did${isTestingReleaseMode ? '' : ' not'}.');
|
||||
return TaskResult.failure(
|
||||
'Expected to${isTestingReleaseMode ? ' not' : ''} find dev_dependency_plugin in APK built with debug mode but did${isTestingReleaseMode ? '' : ' not'}.',
|
||||
);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
return TaskResult.success(null);
|
||||
} on TaskResult catch (taskResult) {
|
||||
return taskResult;
|
||||
} catch (e) {
|
||||
return TaskResult.failure(e.toString());
|
||||
}
|
||||
return taskResult;
|
||||
} catch (e) {
|
||||
return TaskResult.failure(e.toString());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -10,6 +10,5 @@ import 'package:flutter_devicelab/tasks/perf_tests.dart';
|
||||
|
||||
Future<void> main() async {
|
||||
deviceOperatingSystem = DeviceOperatingSystem.android;
|
||||
await task(createAnimatedAdvancedBlendPerfTest(
|
||||
enableImpeller: true, forceOpenGLES: true));
|
||||
await task(createAnimatedAdvancedBlendPerfTest(enableImpeller: true, forceOpenGLES: true));
|
||||
}
|
||||
|
||||
@@ -10,6 +10,5 @@ import 'package:flutter_devicelab/tasks/perf_tests.dart';
|
||||
|
||||
Future<void> main() async {
|
||||
deviceOperatingSystem = DeviceOperatingSystem.android;
|
||||
await task(createAnimatedBlurBackropFilterPerfTest(
|
||||
enableImpeller: true, forceOpenGLES: true));
|
||||
await task(createAnimatedBlurBackropFilterPerfTest(enableImpeller: true, forceOpenGLES: true));
|
||||
}
|
||||
|
||||
@@ -9,9 +9,11 @@ import 'package:flutter_devicelab/tasks/perf_tests.dart';
|
||||
|
||||
Future<void> main() async {
|
||||
deviceOperatingSystem = DeviceOperatingSystem.android;
|
||||
await task(PerfTest(
|
||||
'${flutterDirectory.path}/dev/benchmarks/macrobenchmarks',
|
||||
'test_driver/animated_image.dart',
|
||||
'animated_image',
|
||||
).run);
|
||||
await task(
|
||||
PerfTest(
|
||||
'${flutterDirectory.path}/dev/benchmarks/macrobenchmarks',
|
||||
'test_driver/animated_image.dart',
|
||||
'animated_image',
|
||||
).run,
|
||||
);
|
||||
}
|
||||
|
||||
@@ -13,7 +13,6 @@ import 'package:path/path.dart' as path;
|
||||
/// Tests that AARs can be built on module projects.
|
||||
Future<void> main() async {
|
||||
await task(() async {
|
||||
|
||||
section('Find Java');
|
||||
|
||||
final String? javaHome = await findJavaHome();
|
||||
@@ -39,7 +38,14 @@ Future<void> main() async {
|
||||
await inDirectory(tempDir, () async {
|
||||
await flutter(
|
||||
'create',
|
||||
options: <String>['--org', 'io.flutter.devicelab', '--template', 'plugin', '--platforms=android', 'plugin_with_android'],
|
||||
options: <String>[
|
||||
'--org',
|
||||
'io.flutter.devicelab',
|
||||
'--template',
|
||||
'plugin',
|
||||
'--platforms=android',
|
||||
'plugin_with_android',
|
||||
],
|
||||
);
|
||||
});
|
||||
|
||||
@@ -48,7 +54,14 @@ Future<void> main() async {
|
||||
await inDirectory(tempDir, () async {
|
||||
await flutter(
|
||||
'create',
|
||||
options: <String>['--org', 'io.flutter.devicelab', '--template', 'plugin', '--platforms=ios', 'plugin_without_android'],
|
||||
options: <String>[
|
||||
'--org',
|
||||
'io.flutter.devicelab',
|
||||
'--template',
|
||||
'plugin',
|
||||
'--platforms=ios',
|
||||
'plugin_without_android',
|
||||
],
|
||||
);
|
||||
});
|
||||
|
||||
@@ -59,51 +72,41 @@ Future<void> main() async {
|
||||
content = content.replaceFirst(
|
||||
'${Platform.lineTerminator}dependencies:${Platform.lineTerminator}',
|
||||
'${Platform.lineTerminator}dependencies:${Platform.lineTerminator}'
|
||||
' plugin_with_android:${Platform.lineTerminator}'
|
||||
' path: ../plugin_with_android${Platform.lineTerminator}'
|
||||
' plugin_without_android:${Platform.lineTerminator}'
|
||||
' path: ../plugin_without_android${Platform.lineTerminator}'
|
||||
' plugin_with_android:${Platform.lineTerminator}'
|
||||
' path: ../plugin_with_android${Platform.lineTerminator}'
|
||||
' plugin_without_android:${Platform.lineTerminator}'
|
||||
' path: ../plugin_without_android${Platform.lineTerminator}',
|
||||
);
|
||||
modulePubspec.writeAsStringSync(content, flush: true);
|
||||
|
||||
section('Run packages get in module project');
|
||||
|
||||
await inDirectory(projectDir, () async {
|
||||
await flutter(
|
||||
'packages',
|
||||
options: <String>['get'],
|
||||
);
|
||||
await flutter('packages', options: <String>['get']);
|
||||
});
|
||||
|
||||
section('Build release AAR');
|
||||
|
||||
await inDirectory(projectDir, () async {
|
||||
await flutter(
|
||||
'build',
|
||||
options: <String>['aar', '--verbose'],
|
||||
);
|
||||
await flutter('build', options: <String>['aar', '--verbose']);
|
||||
});
|
||||
|
||||
final String repoPath = path.join(
|
||||
projectDir.path,
|
||||
'build',
|
||||
'host',
|
||||
'outputs',
|
||||
'repo',
|
||||
);
|
||||
final String repoPath = path.join(projectDir.path, 'build', 'host', 'outputs', 'repo');
|
||||
|
||||
section('Check release Maven artifacts');
|
||||
|
||||
checkFileExists(path.join(
|
||||
repoPath,
|
||||
'io',
|
||||
'flutter',
|
||||
'devicelab',
|
||||
'hello',
|
||||
'flutter_release',
|
||||
'1.0',
|
||||
'flutter_release-1.0.aar',
|
||||
));
|
||||
checkFileExists(
|
||||
path.join(
|
||||
repoPath,
|
||||
'io',
|
||||
'flutter',
|
||||
'devicelab',
|
||||
'hello',
|
||||
'flutter_release',
|
||||
'1.0',
|
||||
'flutter_release-1.0.aar',
|
||||
),
|
||||
);
|
||||
|
||||
final String releasePom = path.join(
|
||||
repoPath,
|
||||
@@ -118,27 +121,31 @@ Future<void> main() async {
|
||||
|
||||
checkFileExists(releasePom);
|
||||
|
||||
checkFileExists(path.join(
|
||||
repoPath,
|
||||
'io',
|
||||
'flutter',
|
||||
'devicelab',
|
||||
'plugin_with_android',
|
||||
'plugin_with_android_release',
|
||||
'1.0',
|
||||
'plugin_with_android_release-1.0.aar',
|
||||
));
|
||||
checkFileExists(
|
||||
path.join(
|
||||
repoPath,
|
||||
'io',
|
||||
'flutter',
|
||||
'devicelab',
|
||||
'plugin_with_android',
|
||||
'plugin_with_android_release',
|
||||
'1.0',
|
||||
'plugin_with_android_release-1.0.aar',
|
||||
),
|
||||
);
|
||||
|
||||
checkFileExists(path.join(
|
||||
repoPath,
|
||||
'io',
|
||||
'flutter',
|
||||
'devicelab',
|
||||
'plugin_with_android',
|
||||
'plugin_with_android_release',
|
||||
'1.0',
|
||||
'plugin_with_android_release-1.0.pom',
|
||||
));
|
||||
checkFileExists(
|
||||
path.join(
|
||||
repoPath,
|
||||
'io',
|
||||
'flutter',
|
||||
'devicelab',
|
||||
'plugin_with_android',
|
||||
'plugin_with_android_release',
|
||||
'1.0',
|
||||
'plugin_with_android_release-1.0.pom',
|
||||
),
|
||||
);
|
||||
|
||||
section('Check AOT blobs in release POM');
|
||||
|
||||
@@ -170,22 +177,24 @@ Future<void> main() async {
|
||||
'flutter_release',
|
||||
'1.0',
|
||||
'flutter_release-1.0.aar',
|
||||
)
|
||||
)
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
section('Check debug Maven artifacts');
|
||||
|
||||
checkFileExists(path.join(
|
||||
repoPath,
|
||||
'io',
|
||||
'flutter',
|
||||
'devicelab',
|
||||
'hello',
|
||||
'flutter_debug',
|
||||
'1.0',
|
||||
'flutter_debug-1.0.aar',
|
||||
));
|
||||
checkFileExists(
|
||||
path.join(
|
||||
repoPath,
|
||||
'io',
|
||||
'flutter',
|
||||
'devicelab',
|
||||
'hello',
|
||||
'flutter_debug',
|
||||
'1.0',
|
||||
'flutter_debug-1.0.aar',
|
||||
),
|
||||
);
|
||||
|
||||
final String debugPom = path.join(
|
||||
repoPath,
|
||||
@@ -200,27 +209,31 @@ Future<void> main() async {
|
||||
|
||||
checkFileExists(debugPom);
|
||||
|
||||
checkFileExists(path.join(
|
||||
repoPath,
|
||||
'io',
|
||||
'flutter',
|
||||
'devicelab',
|
||||
'plugin_with_android',
|
||||
'plugin_with_android_debug',
|
||||
'1.0',
|
||||
'plugin_with_android_debug-1.0.aar',
|
||||
));
|
||||
checkFileExists(
|
||||
path.join(
|
||||
repoPath,
|
||||
'io',
|
||||
'flutter',
|
||||
'devicelab',
|
||||
'plugin_with_android',
|
||||
'plugin_with_android_debug',
|
||||
'1.0',
|
||||
'plugin_with_android_debug-1.0.aar',
|
||||
),
|
||||
);
|
||||
|
||||
checkFileExists(path.join(
|
||||
repoPath,
|
||||
'io',
|
||||
'flutter',
|
||||
'devicelab',
|
||||
'plugin_with_android',
|
||||
'plugin_with_android_debug',
|
||||
'1.0',
|
||||
'plugin_with_android_debug-1.0.pom',
|
||||
));
|
||||
checkFileExists(
|
||||
path.join(
|
||||
repoPath,
|
||||
'io',
|
||||
'flutter',
|
||||
'devicelab',
|
||||
'plugin_with_android',
|
||||
'plugin_with_android_debug',
|
||||
'1.0',
|
||||
'plugin_with_android_debug-1.0.pom',
|
||||
),
|
||||
);
|
||||
|
||||
section('Check AOT blobs in debug POM');
|
||||
|
||||
@@ -234,21 +247,20 @@ Future<void> main() async {
|
||||
|
||||
section('Check assets in debug AAR');
|
||||
|
||||
final Iterable<String> debugAar = await getFilesInAar(path.join(
|
||||
repoPath,
|
||||
'io',
|
||||
'flutter',
|
||||
'devicelab',
|
||||
'hello',
|
||||
'flutter_debug',
|
||||
'1.0',
|
||||
'flutter_debug-1.0.aar',
|
||||
));
|
||||
final Iterable<String> debugAar = await getFilesInAar(
|
||||
path.join(
|
||||
repoPath,
|
||||
'io',
|
||||
'flutter',
|
||||
'devicelab',
|
||||
'hello',
|
||||
'flutter_debug',
|
||||
'1.0',
|
||||
'flutter_debug-1.0.aar',
|
||||
),
|
||||
);
|
||||
|
||||
checkCollectionContains<String>(<String>[
|
||||
...flutterAssets,
|
||||
...debugAssets,
|
||||
], debugAar);
|
||||
checkCollectionContains<String>(<String>[...flutterAssets, ...debugAssets], debugAar);
|
||||
|
||||
return TaskResult.success(null);
|
||||
} on TaskResult catch (taskResult) {
|
||||
|
||||
@@ -14,8 +14,7 @@ import 'package:flutter_devicelab/framework/utils.dart';
|
||||
import 'package:path/path.dart' as path;
|
||||
|
||||
final String gradlew = Platform.isWindows ? 'gradlew.bat' : 'gradlew';
|
||||
final String gradlewExecutable =
|
||||
Platform.isWindows ? '.\\$gradlew' : './$gradlew';
|
||||
final String gradlewExecutable = Platform.isWindows ? '.\\$gradlew' : './$gradlew';
|
||||
final String fileReadWriteMode = Platform.isWindows ? 'rw-rw-rw-' : 'rw-r--r--';
|
||||
|
||||
/// Combines several TaskFunctions with trivial success value into one.
|
||||
@@ -34,9 +33,7 @@ TaskFunction combine(List<TaskFunction> tasks) {
|
||||
/// Tests that the Flutter module project template works and supports
|
||||
/// adding Flutter to an existing Android app.
|
||||
class ModuleTest {
|
||||
ModuleTest({
|
||||
this.gradleVersion = '7.6.3',
|
||||
});
|
||||
ModuleTest({this.gradleVersion = '7.6.3'});
|
||||
|
||||
static const String buildTarget = 'module-gradle';
|
||||
final String gradleVersion;
|
||||
@@ -89,32 +86,21 @@ class ModuleTest {
|
||||
);
|
||||
await pubspec.writeAsString(content, flush: true);
|
||||
await inDirectory(projectDir, () async {
|
||||
await flutter(
|
||||
'packages',
|
||||
options: <String>['get'],
|
||||
output: stdout,
|
||||
stderr: stderr,
|
||||
);
|
||||
await flutter('packages', options: <String>['get'], output: stdout, stderr: stderr);
|
||||
});
|
||||
|
||||
section('Add read-only asset');
|
||||
|
||||
final File readonlyTxtAssetFile = await File(path.join(
|
||||
projectDir.path,
|
||||
'assets',
|
||||
'read-only.txt'
|
||||
))
|
||||
.create(recursive: true);
|
||||
final File readonlyTxtAssetFile = await File(
|
||||
path.join(projectDir.path, 'assets', 'read-only.txt'),
|
||||
).create(recursive: true);
|
||||
|
||||
if (!exists(readonlyTxtAssetFile)) {
|
||||
return TaskResult.failure('Failed to create read-only asset');
|
||||
}
|
||||
|
||||
if (!Platform.isWindows) {
|
||||
await exec('chmod', <String>[
|
||||
'444',
|
||||
readonlyTxtAssetFile.path,
|
||||
]);
|
||||
await exec('chmod', <String>['444', readonlyTxtAssetFile.path]);
|
||||
}
|
||||
|
||||
content = content.replaceFirst(
|
||||
@@ -131,12 +117,7 @@ class ModuleTest {
|
||||
);
|
||||
await pubspec.writeAsString(content, flush: true);
|
||||
await inDirectory(projectDir, () async {
|
||||
await flutter(
|
||||
'packages',
|
||||
options: <String>['get'],
|
||||
output: stdout,
|
||||
stderr: stderr,
|
||||
);
|
||||
await flutter('packages', options: <String>['get'], output: stdout, stderr: stderr);
|
||||
});
|
||||
|
||||
// TODO(dacoharkes): Implement Add2app. https://github.com/flutter/flutter/issues/129757
|
||||
@@ -147,19 +128,23 @@ class ModuleTest {
|
||||
await exec(
|
||||
gradlewExecutable,
|
||||
<String>['flutter:assembleDebug'],
|
||||
environment: <String, String>{ 'JAVA_HOME': javaHome },
|
||||
environment: <String, String>{'JAVA_HOME': javaHome},
|
||||
);
|
||||
});
|
||||
|
||||
final bool aarBuilt = exists(File(path.join(
|
||||
projectDir.path,
|
||||
'.android',
|
||||
'Flutter',
|
||||
'build',
|
||||
'outputs',
|
||||
'aar',
|
||||
'flutter-debug.aar',
|
||||
)));
|
||||
final bool aarBuilt = exists(
|
||||
File(
|
||||
path.join(
|
||||
projectDir.path,
|
||||
'.android',
|
||||
'Flutter',
|
||||
'build',
|
||||
'outputs',
|
||||
'aar',
|
||||
'flutter-debug.aar',
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
if (!aarBuilt) {
|
||||
return TaskResult.failure('Failed to build .aar');
|
||||
@@ -168,23 +153,22 @@ class ModuleTest {
|
||||
section('Build ephemeral host app');
|
||||
|
||||
await inDirectory(projectDir, () async {
|
||||
await flutter(
|
||||
'build',
|
||||
options: <String>['apk'],
|
||||
output: stdout,
|
||||
stderr: stderr,
|
||||
);
|
||||
await flutter('build', options: <String>['apk'], output: stdout, stderr: stderr);
|
||||
});
|
||||
|
||||
final bool ephemeralHostApkBuilt = exists(File(path.join(
|
||||
projectDir.path,
|
||||
'build',
|
||||
'host',
|
||||
'outputs',
|
||||
'apk',
|
||||
'release',
|
||||
'app-release.apk',
|
||||
)));
|
||||
final bool ephemeralHostApkBuilt = exists(
|
||||
File(
|
||||
path.join(
|
||||
projectDir.path,
|
||||
'build',
|
||||
'host',
|
||||
'outputs',
|
||||
'apk',
|
||||
'release',
|
||||
'app-release.apk',
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
if (!ephemeralHostApkBuilt) {
|
||||
return TaskResult.failure('Failed to build ephemeral host .apk');
|
||||
@@ -193,11 +177,7 @@ class ModuleTest {
|
||||
section('Clean build');
|
||||
|
||||
await inDirectory(projectDir, () async {
|
||||
await flutter(
|
||||
'clean',
|
||||
output: stdout,
|
||||
stderr: stderr,
|
||||
);
|
||||
await flutter('clean', output: stdout, stderr: stderr);
|
||||
});
|
||||
|
||||
section('Make Android host app editable');
|
||||
@@ -214,23 +194,22 @@ class ModuleTest {
|
||||
section('Build editable host app');
|
||||
|
||||
await inDirectory(projectDir, () async {
|
||||
await flutter(
|
||||
'build',
|
||||
options: <String>['apk'],
|
||||
output: stdout,
|
||||
stderr: stderr,
|
||||
);
|
||||
await flutter('build', options: <String>['apk'], output: stdout, stderr: stderr);
|
||||
});
|
||||
|
||||
final bool editableHostApkBuilt = exists(File(path.join(
|
||||
projectDir.path,
|
||||
'build',
|
||||
'host',
|
||||
'outputs',
|
||||
'apk',
|
||||
'release',
|
||||
'app-release.apk',
|
||||
)));
|
||||
final bool editableHostApkBuilt = exists(
|
||||
File(
|
||||
path.join(
|
||||
projectDir.path,
|
||||
'build',
|
||||
'host',
|
||||
'outputs',
|
||||
'apk',
|
||||
'release',
|
||||
'app-release.apk',
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
if (!editableHostApkBuilt) {
|
||||
return TaskResult.failure('Failed to build editable host .apk');
|
||||
@@ -252,25 +231,19 @@ class ModuleTest {
|
||||
),
|
||||
hostApp,
|
||||
);
|
||||
copy(File(path.join(projectDir.path, '.android', gradlew)), hostApp);
|
||||
copy(
|
||||
File(path.join(projectDir.path, '.android', gradlew)),
|
||||
hostApp,
|
||||
);
|
||||
copy(
|
||||
File(path.join(projectDir.path, '.android', 'gradle', 'wrapper',
|
||||
'gradle-wrapper.jar')),
|
||||
File(path.join(projectDir.path, '.android', 'gradle', 'wrapper', 'gradle-wrapper.jar')),
|
||||
Directory(path.join(hostApp.path, 'gradle', 'wrapper')),
|
||||
);
|
||||
|
||||
// Modify gradle version to passed in version.
|
||||
// This is somehow the wrong file.
|
||||
final File gradleWrapperProperties = File(path.join(
|
||||
hostApp.path, 'gradle', 'wrapper', 'gradle-wrapper.properties'));
|
||||
String propertyContent = await gradleWrapperProperties.readAsString();
|
||||
propertyContent = propertyContent.replaceFirst(
|
||||
'REPLACEME',
|
||||
gradleVersion,
|
||||
final File gradleWrapperProperties = File(
|
||||
path.join(hostApp.path, 'gradle', 'wrapper', 'gradle-wrapper.properties'),
|
||||
);
|
||||
String propertyContent = await gradleWrapperProperties.readAsString();
|
||||
propertyContent = propertyContent.replaceFirst('REPLACEME', gradleVersion);
|
||||
section(propertyContent);
|
||||
await gradleWrapperProperties.writeAsString(propertyContent, flush: true);
|
||||
|
||||
@@ -280,7 +253,8 @@ class ModuleTest {
|
||||
if (!Platform.isWindows) {
|
||||
await exec('chmod', <String>['+x', 'gradlew']);
|
||||
}
|
||||
await exec(gradlewExecutable,
|
||||
await exec(
|
||||
gradlewExecutable,
|
||||
<String>['app:assembleDebug'],
|
||||
environment: <String, String>{
|
||||
'JAVA_HOME': javaHome,
|
||||
@@ -320,9 +294,10 @@ class ModuleTest {
|
||||
if (!androidManifestDebug.contains('''
|
||||
<meta-data
|
||||
android:name="flutterProjectType"
|
||||
android:value="module" />''')
|
||||
) {
|
||||
return TaskResult.failure("Debug host APK doesn't contain metadata: flutterProjectType = module ");
|
||||
android:value="module" />''')) {
|
||||
return TaskResult.failure(
|
||||
"Debug host APK doesn't contain metadata: flutterProjectType = module ",
|
||||
);
|
||||
}
|
||||
|
||||
section('Check file access modes for read-only asset from Flutter module');
|
||||
@@ -352,7 +327,8 @@ class ModuleTest {
|
||||
section('Build release host APK');
|
||||
|
||||
await inDirectory(hostApp, () async {
|
||||
await exec(gradlewExecutable,
|
||||
await exec(
|
||||
gradlewExecutable,
|
||||
<String>['app:assembleRelease'],
|
||||
environment: <String, String>{
|
||||
'JAVA_HOME': javaHome,
|
||||
@@ -411,9 +387,10 @@ class ModuleTest {
|
||||
if (!androidManifestRelease.contains('''
|
||||
<meta-data
|
||||
android:name="flutterProjectType"
|
||||
android:value="module" />''')
|
||||
) {
|
||||
return TaskResult.failure("Release host APK doesn't contain metadata: flutterProjectType = module ");
|
||||
android:value="module" />''')) {
|
||||
return TaskResult.failure(
|
||||
"Release host APK doesn't contain metadata: flutterProjectType = module ",
|
||||
);
|
||||
}
|
||||
|
||||
section('Check file access modes for read-only asset from Flutter module');
|
||||
@@ -458,9 +435,11 @@ class ModuleTest {
|
||||
}
|
||||
|
||||
Future<void> main() async {
|
||||
await task(combine(<TaskFunction>[
|
||||
// ignore: avoid_redundant_argument_values
|
||||
ModuleTest(gradleVersion: '8.4').call,
|
||||
ModuleTest(gradleVersion: '8.4-rc-3').call,
|
||||
]));
|
||||
await task(
|
||||
combine(<TaskFunction>[
|
||||
// ignore: avoid_redundant_argument_values
|
||||
ModuleTest(gradleVersion: '8.4').call,
|
||||
ModuleTest(gradleVersion: '8.4-rc-3').call,
|
||||
]),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -14,8 +14,7 @@ import 'package:flutter_devicelab/framework/utils.dart';
|
||||
import 'package:path/path.dart' as path;
|
||||
|
||||
final String gradlew = Platform.isWindows ? 'gradlew.bat' : 'gradlew';
|
||||
final String gradlewExecutable =
|
||||
Platform.isWindows ? '.\\$gradlew' : './$gradlew';
|
||||
final String gradlewExecutable = Platform.isWindows ? '.\\$gradlew' : './$gradlew';
|
||||
final String fileReadWriteMode = Platform.isWindows ? 'rw-rw-rw-' : 'rw-r--r--';
|
||||
|
||||
/// Combines several TaskFunctions with trivial success value into one.
|
||||
@@ -34,9 +33,7 @@ TaskFunction combine(List<TaskFunction> tasks) {
|
||||
/// Tests that the Flutter module project template works and supports
|
||||
/// adding Flutter to an existing Android app.
|
||||
class ModuleTest {
|
||||
ModuleTest({
|
||||
this.gradleVersion = '7.6.3',
|
||||
});
|
||||
ModuleTest({this.gradleVersion = '7.6.3'});
|
||||
|
||||
static const String buildTarget = 'module-gradle';
|
||||
final String gradleVersion;
|
||||
@@ -89,32 +86,21 @@ class ModuleTest {
|
||||
);
|
||||
await pubspec.writeAsString(content, flush: true);
|
||||
await inDirectory(projectDir, () async {
|
||||
await flutter(
|
||||
'packages',
|
||||
options: <String>['get'],
|
||||
output: stdout,
|
||||
stderr: stderr,
|
||||
);
|
||||
await flutter('packages', options: <String>['get'], output: stdout, stderr: stderr);
|
||||
});
|
||||
|
||||
section('Add read-only asset');
|
||||
|
||||
final File readonlyTxtAssetFile = await File(path.join(
|
||||
projectDir.path,
|
||||
'assets',
|
||||
'read-only.txt'
|
||||
))
|
||||
.create(recursive: true);
|
||||
final File readonlyTxtAssetFile = await File(
|
||||
path.join(projectDir.path, 'assets', 'read-only.txt'),
|
||||
).create(recursive: true);
|
||||
|
||||
if (!exists(readonlyTxtAssetFile)) {
|
||||
return TaskResult.failure('Failed to create read-only asset');
|
||||
}
|
||||
|
||||
if (!Platform.isWindows) {
|
||||
await exec('chmod', <String>[
|
||||
'444',
|
||||
readonlyTxtAssetFile.path,
|
||||
]);
|
||||
await exec('chmod', <String>['444', readonlyTxtAssetFile.path]);
|
||||
}
|
||||
|
||||
content = content.replaceFirst(
|
||||
@@ -131,34 +117,28 @@ class ModuleTest {
|
||||
);
|
||||
await pubspec.writeAsString(content, flush: true);
|
||||
await inDirectory(projectDir, () async {
|
||||
await flutter(
|
||||
'packages',
|
||||
options: <String>['get'],
|
||||
output: stdout,
|
||||
stderr: stderr,
|
||||
);
|
||||
await flutter('packages', options: <String>['get'], output: stdout, stderr: stderr);
|
||||
});
|
||||
|
||||
section('Build ephemeral host app');
|
||||
|
||||
await inDirectory(projectDir, () async {
|
||||
await flutter(
|
||||
'build',
|
||||
options: <String>['apk'],
|
||||
output: stdout,
|
||||
stderr: stderr,
|
||||
);
|
||||
await flutter('build', options: <String>['apk'], output: stdout, stderr: stderr);
|
||||
});
|
||||
|
||||
final bool ephemeralHostApkBuilt = exists(File(path.join(
|
||||
projectDir.path,
|
||||
'build',
|
||||
'host',
|
||||
'outputs',
|
||||
'apk',
|
||||
'release',
|
||||
'app-release.apk',
|
||||
)));
|
||||
final bool ephemeralHostApkBuilt = exists(
|
||||
File(
|
||||
path.join(
|
||||
projectDir.path,
|
||||
'build',
|
||||
'host',
|
||||
'outputs',
|
||||
'apk',
|
||||
'release',
|
||||
'app-release.apk',
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
if (!ephemeralHostApkBuilt) {
|
||||
return TaskResult.failure('Failed to build ephemeral host .apk');
|
||||
@@ -167,11 +147,7 @@ class ModuleTest {
|
||||
section('Clean build');
|
||||
|
||||
await inDirectory(projectDir, () async {
|
||||
await flutter(
|
||||
'clean',
|
||||
output: stdout,
|
||||
stderr: stderr,
|
||||
);
|
||||
await flutter('clean', output: stdout, stderr: stderr);
|
||||
});
|
||||
|
||||
section('Make Android host app editable');
|
||||
@@ -188,23 +164,22 @@ class ModuleTest {
|
||||
section('Build editable host app');
|
||||
|
||||
await inDirectory(projectDir, () async {
|
||||
await flutter(
|
||||
'build',
|
||||
options: <String>['apk'],
|
||||
output: stdout,
|
||||
stderr: stderr,
|
||||
);
|
||||
await flutter('build', options: <String>['apk'], output: stdout, stderr: stderr);
|
||||
});
|
||||
|
||||
final bool editableHostApkBuilt = exists(File(path.join(
|
||||
projectDir.path,
|
||||
'build',
|
||||
'host',
|
||||
'outputs',
|
||||
'apk',
|
||||
'release',
|
||||
'app-release.apk',
|
||||
)));
|
||||
final bool editableHostApkBuilt = exists(
|
||||
File(
|
||||
path.join(
|
||||
projectDir.path,
|
||||
'build',
|
||||
'host',
|
||||
'outputs',
|
||||
'apk',
|
||||
'release',
|
||||
'app-release.apk',
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
if (!editableHostApkBuilt) {
|
||||
return TaskResult.failure('Failed to build editable host .apk');
|
||||
@@ -226,25 +201,19 @@ class ModuleTest {
|
||||
),
|
||||
hostApp,
|
||||
);
|
||||
copy(File(path.join(projectDir.path, '.android', gradlew)), hostApp);
|
||||
copy(
|
||||
File(path.join(projectDir.path, '.android', gradlew)),
|
||||
hostApp,
|
||||
);
|
||||
copy(
|
||||
File(path.join(projectDir.path, '.android', 'gradle', 'wrapper',
|
||||
'gradle-wrapper.jar')),
|
||||
File(path.join(projectDir.path, '.android', 'gradle', 'wrapper', 'gradle-wrapper.jar')),
|
||||
Directory(path.join(hostApp.path, 'gradle', 'wrapper')),
|
||||
);
|
||||
|
||||
// Modify gradle version to passed in version.
|
||||
// This is somehow the wrong file.
|
||||
final File gradleWrapperProperties = File(path.join(
|
||||
hostApp.path, 'gradle', 'wrapper', 'gradle-wrapper.properties'));
|
||||
String propertyContent = await gradleWrapperProperties.readAsString();
|
||||
propertyContent = propertyContent.replaceFirst(
|
||||
'REPLACEME',
|
||||
gradleVersion,
|
||||
final File gradleWrapperProperties = File(
|
||||
path.join(hostApp.path, 'gradle', 'wrapper', 'gradle-wrapper.properties'),
|
||||
);
|
||||
String propertyContent = await gradleWrapperProperties.readAsString();
|
||||
propertyContent = propertyContent.replaceFirst('REPLACEME', gradleVersion);
|
||||
section(propertyContent);
|
||||
await gradleWrapperProperties.writeAsString(propertyContent, flush: true);
|
||||
|
||||
@@ -254,7 +223,8 @@ class ModuleTest {
|
||||
if (!Platform.isWindows) {
|
||||
await exec('chmod', <String>['+x', 'gradlew']);
|
||||
}
|
||||
await exec(gradlewExecutable,
|
||||
await exec(
|
||||
gradlewExecutable,
|
||||
<String>['app:assembleDebug'],
|
||||
environment: <String, String>{
|
||||
'JAVA_HOME': javaHome,
|
||||
@@ -294,9 +264,10 @@ class ModuleTest {
|
||||
if (!androidManifestDebug.contains('''
|
||||
<meta-data
|
||||
android:name="flutterProjectType"
|
||||
android:value="module" />''')
|
||||
) {
|
||||
return TaskResult.failure("Debug host APK doesn't contain metadata: flutterProjectType = module ");
|
||||
android:value="module" />''')) {
|
||||
return TaskResult.failure(
|
||||
"Debug host APK doesn't contain metadata: flutterProjectType = module ",
|
||||
);
|
||||
}
|
||||
|
||||
section('Check file access modes for read-only asset from Flutter module');
|
||||
@@ -327,7 +298,8 @@ class ModuleTest {
|
||||
section('Build release host APK');
|
||||
|
||||
await inDirectory(hostApp, () async {
|
||||
await exec(gradlewExecutable,
|
||||
await exec(
|
||||
gradlewExecutable,
|
||||
<String>['app:assembleRelease'],
|
||||
environment: <String, String>{
|
||||
'JAVA_HOME': javaHome,
|
||||
@@ -386,9 +358,10 @@ class ModuleTest {
|
||||
if (!androidManifestRelease.contains('''
|
||||
<meta-data
|
||||
android:name="flutterProjectType"
|
||||
android:value="module" />''')
|
||||
) {
|
||||
return TaskResult.failure("Release host APK doesn't contain metadata: flutterProjectType = module ");
|
||||
android:value="module" />''')) {
|
||||
return TaskResult.failure(
|
||||
"Release host APK doesn't contain metadata: flutterProjectType = module ",
|
||||
);
|
||||
}
|
||||
|
||||
section('Check file access modes for read-only asset from Flutter module');
|
||||
@@ -434,8 +407,10 @@ class ModuleTest {
|
||||
}
|
||||
|
||||
Future<void> main() async {
|
||||
await task(combine(<TaskFunction>[
|
||||
// ignore: avoid_redundant_argument_values
|
||||
ModuleTest(gradleVersion: '8.7').call,
|
||||
]));
|
||||
await task(
|
||||
combine(<TaskFunction>[
|
||||
// ignore: avoid_redundant_argument_values
|
||||
ModuleTest(gradleVersion: '8.7').call,
|
||||
]),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -13,7 +13,6 @@ import 'package:path/path.dart' as path;
|
||||
/// Tests that iOS and macOS .xcframeworks can be built.
|
||||
Future<void> main() async {
|
||||
await task(() async {
|
||||
|
||||
section('Create module project');
|
||||
|
||||
final Directory tempDir = Directory.systemTemp.createTempSync('flutter_module_test.');
|
||||
@@ -21,8 +20,7 @@ Future<void> main() async {
|
||||
await inDirectory(tempDir, () async {
|
||||
section('Test iOS module template');
|
||||
|
||||
final Directory moduleProjectDir =
|
||||
Directory(path.join(tempDir.path, 'hello_module'));
|
||||
final Directory moduleProjectDir = Directory(path.join(tempDir.path, 'hello_module'));
|
||||
await flutter(
|
||||
'create',
|
||||
options: <String>[
|
||||
@@ -39,8 +37,7 @@ Future<void> main() async {
|
||||
|
||||
section('Test app template');
|
||||
|
||||
final Directory projectDir =
|
||||
Directory(path.join(tempDir.path, 'hello_project'));
|
||||
final Directory projectDir = Directory(path.join(tempDir.path, 'hello_project'));
|
||||
await flutter(
|
||||
'create',
|
||||
options: <String>['--org', 'io.flutter.devicelab', 'hello_project'],
|
||||
@@ -73,14 +70,11 @@ Future<void> _addPlugin(Directory projectDir) async {
|
||||
);
|
||||
pubspec.writeAsStringSync(content, flush: true);
|
||||
await inDirectory(projectDir, () async {
|
||||
await flutter(
|
||||
'packages',
|
||||
options: <String>['get'],
|
||||
);
|
||||
await flutter('packages', options: <String>['get']);
|
||||
});
|
||||
}
|
||||
|
||||
Future<void> _testBuildIosFramework(Directory projectDir, { bool isModule = false}) async {
|
||||
Future<void> _testBuildIosFramework(Directory projectDir, {bool isModule = false}) async {
|
||||
// This builds all build modes' frameworks by default
|
||||
section('Build iOS app');
|
||||
|
||||
@@ -101,14 +95,16 @@ Future<void> _testBuildIosFramework(Directory projectDir, { bool isModule = fals
|
||||
|
||||
final String outputPath = path.join(projectDir.path, outputDirectoryName);
|
||||
|
||||
checkFileExists(path.join(
|
||||
outputPath,
|
||||
'Debug',
|
||||
'Flutter.xcframework',
|
||||
'ios-arm64',
|
||||
'Flutter.framework',
|
||||
'Flutter',
|
||||
));
|
||||
checkFileExists(
|
||||
path.join(
|
||||
outputPath,
|
||||
'Debug',
|
||||
'Flutter.xcframework',
|
||||
'ios-arm64',
|
||||
'Flutter.framework',
|
||||
'Flutter',
|
||||
),
|
||||
);
|
||||
|
||||
final String debugAppFrameworkPath = path.join(
|
||||
outputPath,
|
||||
@@ -120,41 +116,33 @@ Future<void> _testBuildIosFramework(Directory projectDir, { bool isModule = fals
|
||||
);
|
||||
checkFileExists(debugAppFrameworkPath);
|
||||
|
||||
checkFileExists(path.join(
|
||||
outputPath,
|
||||
'Debug',
|
||||
'App.xcframework',
|
||||
'ios-arm64',
|
||||
'App.framework',
|
||||
'Info.plist',
|
||||
));
|
||||
checkFileExists(
|
||||
path.join(outputPath, 'Debug', 'App.xcframework', 'ios-arm64', 'App.framework', 'Info.plist'),
|
||||
);
|
||||
|
||||
section('Check debug build has Dart snapshot as asset');
|
||||
|
||||
checkFileExists(path.join(
|
||||
outputPath,
|
||||
'Debug',
|
||||
'App.xcframework',
|
||||
'ios-arm64_x86_64-simulator',
|
||||
'App.framework',
|
||||
'flutter_assets',
|
||||
'vm_snapshot_data',
|
||||
));
|
||||
checkFileExists(
|
||||
path.join(
|
||||
outputPath,
|
||||
'Debug',
|
||||
'App.xcframework',
|
||||
'ios-arm64_x86_64-simulator',
|
||||
'App.framework',
|
||||
'flutter_assets',
|
||||
'vm_snapshot_data',
|
||||
),
|
||||
);
|
||||
|
||||
section('Check obfuscation symbols');
|
||||
|
||||
checkFileExists(path.join(
|
||||
projectDir.path,
|
||||
'symbols',
|
||||
'app.ios-arm64.symbols',
|
||||
));
|
||||
checkFileExists(path.join(projectDir.path, 'symbols', 'app.ios-arm64.symbols'));
|
||||
|
||||
section('Check debug build has no Dart AOT');
|
||||
|
||||
final String aotSymbols = await dumpSymbolTable(debugAppFrameworkPath);
|
||||
|
||||
if (aotSymbols.contains('architecture') ||
|
||||
aotSymbols.contains('_kDartVmSnapshot')) {
|
||||
if (aotSymbols.contains('architecture') || aotSymbols.contains('_kDartVmSnapshot')) {
|
||||
throw TaskResult.failure('Debug App.framework contains AOT');
|
||||
}
|
||||
|
||||
@@ -178,92 +166,89 @@ Future<void> _testBuildIosFramework(Directory projectDir, { bool isModule = fals
|
||||
throw TaskResult.failure('$mode App.framework missing Dart AOT');
|
||||
}
|
||||
|
||||
checkFileNotExists(path.join(
|
||||
outputPath,
|
||||
mode,
|
||||
'App.xcframework',
|
||||
'ios-arm64',
|
||||
'App.framework',
|
||||
'flutter_assets',
|
||||
'vm_snapshot_data',
|
||||
));
|
||||
|
||||
final String dsymPath = path.join(
|
||||
checkFileNotExists(
|
||||
path.join(
|
||||
outputPath,
|
||||
mode,
|
||||
'App.xcframework',
|
||||
'ios-arm64',
|
||||
'dSYMs'
|
||||
'App.framework',
|
||||
'flutter_assets',
|
||||
'vm_snapshot_data',
|
||||
),
|
||||
);
|
||||
|
||||
final String dsymPath = path.join(outputPath, mode, 'App.xcframework', 'ios-arm64', 'dSYMs');
|
||||
checkDirectoryExists(dsymPath);
|
||||
|
||||
final String appFrameworkDsymPath = path.join(
|
||||
dsymPath,
|
||||
'App.framework.dSYM'
|
||||
);
|
||||
final String appFrameworkDsymPath = path.join(dsymPath, 'App.framework.dSYM');
|
||||
checkDirectoryExists(appFrameworkDsymPath);
|
||||
|
||||
if (Directory(dsymPath).listSync().whereType<Directory>().length != 1) {
|
||||
throw TaskResult.failure('App.framework/dSYMs should ONLY contain App.xcframework.dSYM');
|
||||
}
|
||||
|
||||
await _checkDsym(path.join(
|
||||
appFrameworkDsymPath,
|
||||
'Contents',
|
||||
'Resources',
|
||||
'DWARF',
|
||||
'App',
|
||||
));
|
||||
await _checkDsym(path.join(appFrameworkDsymPath, 'Contents', 'Resources', 'DWARF', 'App'));
|
||||
|
||||
checkFileExists(path.join(
|
||||
outputPath,
|
||||
mode,
|
||||
'App.xcframework',
|
||||
'ios-arm64_x86_64-simulator',
|
||||
'App.framework',
|
||||
'App',
|
||||
));
|
||||
checkFileExists(
|
||||
path.join(
|
||||
outputPath,
|
||||
mode,
|
||||
'App.xcframework',
|
||||
'ios-arm64_x86_64-simulator',
|
||||
'App.framework',
|
||||
'App',
|
||||
),
|
||||
);
|
||||
|
||||
checkFileExists(path.join(
|
||||
outputPath,
|
||||
mode,
|
||||
'App.xcframework',
|
||||
'ios-arm64_x86_64-simulator',
|
||||
'App.framework',
|
||||
'Info.plist',
|
||||
));
|
||||
checkFileExists(
|
||||
path.join(
|
||||
outputPath,
|
||||
mode,
|
||||
'App.xcframework',
|
||||
'ios-arm64_x86_64-simulator',
|
||||
'App.framework',
|
||||
'Info.plist',
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
section("Check all modes' engine dylib");
|
||||
|
||||
for (final String mode in <String>['Debug', 'Profile', 'Release']) {
|
||||
checkFileExists(path.join(
|
||||
outputPath,
|
||||
mode,
|
||||
'Flutter.xcframework',
|
||||
'ios-arm64',
|
||||
'Flutter.framework',
|
||||
'Flutter',
|
||||
));
|
||||
checkFileExists(
|
||||
path.join(
|
||||
outputPath,
|
||||
mode,
|
||||
'Flutter.xcframework',
|
||||
'ios-arm64',
|
||||
'Flutter.framework',
|
||||
'Flutter',
|
||||
),
|
||||
);
|
||||
|
||||
checkFileExists(path.join(
|
||||
outputPath,
|
||||
mode,
|
||||
'Flutter.xcframework',
|
||||
'ios-arm64_x86_64-simulator',
|
||||
'Flutter.framework',
|
||||
'Flutter',
|
||||
));
|
||||
checkFileExists(
|
||||
path.join(
|
||||
outputPath,
|
||||
mode,
|
||||
'Flutter.xcframework',
|
||||
'ios-arm64_x86_64-simulator',
|
||||
'Flutter.framework',
|
||||
'Flutter',
|
||||
),
|
||||
);
|
||||
|
||||
checkFileExists(path.join(
|
||||
outputPath,
|
||||
mode,
|
||||
'Flutter.xcframework',
|
||||
'ios-arm64_x86_64-simulator',
|
||||
'Flutter.framework',
|
||||
'Headers',
|
||||
'Flutter.h',
|
||||
));
|
||||
checkFileExists(
|
||||
path.join(
|
||||
outputPath,
|
||||
mode,
|
||||
'Flutter.xcframework',
|
||||
'ios-arm64_x86_64-simulator',
|
||||
'Flutter.framework',
|
||||
'Headers',
|
||||
'Flutter.h',
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
section('Check all modes have plugins');
|
||||
@@ -298,28 +283,33 @@ Future<void> _testBuildIosFramework(Directory projectDir, { bool isModule = fals
|
||||
|
||||
if (await _linksOnFlutter(transitiveDependencyFrameworkPath)) {
|
||||
throw TaskResult.failure(
|
||||
'Transitive dependency $transitiveDependencyFrameworkPath unexpectedly links on Flutter');
|
||||
'Transitive dependency $transitiveDependencyFrameworkPath unexpectedly links on Flutter',
|
||||
);
|
||||
}
|
||||
|
||||
checkFileExists(path.join(
|
||||
outputPath,
|
||||
mode,
|
||||
'connectivity.xcframework',
|
||||
'ios-arm64',
|
||||
'connectivity.framework',
|
||||
'Headers',
|
||||
'FLTConnectivityPlugin.h',
|
||||
));
|
||||
|
||||
if (mode != 'Debug') {
|
||||
checkDirectoryExists(path.join(
|
||||
checkFileExists(
|
||||
path.join(
|
||||
outputPath,
|
||||
mode,
|
||||
'connectivity.xcframework',
|
||||
'ios-arm64',
|
||||
'dSYMs',
|
||||
'connectivity.framework.dSYM',
|
||||
));
|
||||
'connectivity.framework',
|
||||
'Headers',
|
||||
'FLTConnectivityPlugin.h',
|
||||
),
|
||||
);
|
||||
|
||||
if (mode != 'Debug') {
|
||||
checkDirectoryExists(
|
||||
path.join(
|
||||
outputPath,
|
||||
mode,
|
||||
'connectivity.xcframework',
|
||||
'ios-arm64',
|
||||
'dSYMs',
|
||||
'connectivity.framework.dSYM',
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
final String simulatorFrameworkPath = path.join(
|
||||
@@ -361,15 +351,17 @@ Future<void> _testBuildIosFramework(Directory projectDir, { bool isModule = fals
|
||||
);
|
||||
await _checkStatic(registrantFrameworkPath);
|
||||
|
||||
checkFileExists(path.join(
|
||||
outputPath,
|
||||
mode,
|
||||
'FlutterPluginRegistrant.xcframework',
|
||||
'ios-arm64',
|
||||
'FlutterPluginRegistrant.framework',
|
||||
'Headers',
|
||||
'GeneratedPluginRegistrant.h',
|
||||
));
|
||||
checkFileExists(
|
||||
path.join(
|
||||
outputPath,
|
||||
mode,
|
||||
'FlutterPluginRegistrant.xcframework',
|
||||
'ios-arm64',
|
||||
'FlutterPluginRegistrant.framework',
|
||||
'Headers',
|
||||
'GeneratedPluginRegistrant.h',
|
||||
),
|
||||
);
|
||||
final String simulatorHeaderPath = path.join(
|
||||
outputPath,
|
||||
mode,
|
||||
@@ -402,19 +394,10 @@ Future<void> _testBuildIosFramework(Directory projectDir, { bool isModule = fals
|
||||
|
||||
final String cocoapodsOutputPath = path.join(projectDir.path, cocoapodsOutputDirectoryName);
|
||||
for (final String mode in <String>['Debug', 'Profile', 'Release']) {
|
||||
checkFileExists(path.join(
|
||||
cocoapodsOutputPath,
|
||||
mode,
|
||||
'Flutter.podspec',
|
||||
));
|
||||
await _checkDylib(path.join(
|
||||
cocoapodsOutputPath,
|
||||
mode,
|
||||
'App.xcframework',
|
||||
'ios-arm64',
|
||||
'App.framework',
|
||||
'App',
|
||||
));
|
||||
checkFileExists(path.join(cocoapodsOutputPath, mode, 'Flutter.podspec'));
|
||||
await _checkDylib(
|
||||
path.join(cocoapodsOutputPath, mode, 'App.xcframework', 'ios-arm64', 'App.framework', 'App'),
|
||||
);
|
||||
|
||||
if (mode != 'Debug') {
|
||||
final String appFrameworkDsymPath = path.join(
|
||||
@@ -423,66 +406,49 @@ Future<void> _testBuildIosFramework(Directory projectDir, { bool isModule = fals
|
||||
'App.xcframework',
|
||||
'ios-arm64',
|
||||
'dSYMs',
|
||||
'App.framework.dSYM'
|
||||
'App.framework.dSYM',
|
||||
);
|
||||
checkDirectoryExists(appFrameworkDsymPath);
|
||||
await _checkDsym(path.join(
|
||||
appFrameworkDsymPath,
|
||||
'Contents',
|
||||
'Resources',
|
||||
'DWARF',
|
||||
'App',
|
||||
));
|
||||
await _checkDsym(path.join(appFrameworkDsymPath, 'Contents', 'Resources', 'DWARF', 'App'));
|
||||
}
|
||||
|
||||
if (Directory(path.join(
|
||||
cocoapodsOutputPath,
|
||||
mode,
|
||||
'FlutterPluginRegistrant.xcframework',
|
||||
)).existsSync() !=
|
||||
if (Directory(
|
||||
path.join(cocoapodsOutputPath, mode, 'FlutterPluginRegistrant.xcframework'),
|
||||
).existsSync() !=
|
||||
isModule) {
|
||||
throw TaskResult.failure(
|
||||
'Unexpected FlutterPluginRegistrant.xcframework.');
|
||||
throw TaskResult.failure('Unexpected FlutterPluginRegistrant.xcframework.');
|
||||
}
|
||||
|
||||
await _checkStatic(path.join(
|
||||
cocoapodsOutputPath,
|
||||
mode,
|
||||
'package_info.xcframework',
|
||||
'ios-arm64',
|
||||
'package_info.framework',
|
||||
'package_info',
|
||||
));
|
||||
await _checkStatic(
|
||||
path.join(
|
||||
cocoapodsOutputPath,
|
||||
mode,
|
||||
'package_info.xcframework',
|
||||
'ios-arm64',
|
||||
'package_info.framework',
|
||||
'package_info',
|
||||
),
|
||||
);
|
||||
|
||||
await _checkStatic(path.join(
|
||||
cocoapodsOutputPath,
|
||||
mode,
|
||||
'connectivity.xcframework',
|
||||
'ios-arm64',
|
||||
'connectivity.framework',
|
||||
'connectivity',
|
||||
));
|
||||
await _checkStatic(
|
||||
path.join(
|
||||
cocoapodsOutputPath,
|
||||
mode,
|
||||
'connectivity.xcframework',
|
||||
'ios-arm64',
|
||||
'connectivity.framework',
|
||||
'connectivity',
|
||||
),
|
||||
);
|
||||
|
||||
checkDirectoryExists(path.join(
|
||||
cocoapodsOutputPath,
|
||||
mode,
|
||||
'Reachability.xcframework',
|
||||
));
|
||||
checkDirectoryExists(path.join(cocoapodsOutputPath, mode, 'Reachability.xcframework'));
|
||||
}
|
||||
|
||||
if (File(path.join(
|
||||
outputPath,
|
||||
'GeneratedPluginRegistrant.h',
|
||||
)).existsSync() ==
|
||||
isModule) {
|
||||
if (File(path.join(outputPath, 'GeneratedPluginRegistrant.h')).existsSync() == isModule) {
|
||||
throw TaskResult.failure('Unexpected GeneratedPluginRegistrant.h.');
|
||||
}
|
||||
|
||||
if (File(path.join(
|
||||
outputPath,
|
||||
'GeneratedPluginRegistrant.m',
|
||||
)).existsSync() ==
|
||||
isModule) {
|
||||
if (File(path.join(outputPath, 'GeneratedPluginRegistrant.m')).existsSync() == isModule) {
|
||||
throw TaskResult.failure('Unexpected GeneratedPluginRegistrant.m.');
|
||||
}
|
||||
|
||||
@@ -493,7 +459,6 @@ Future<void> _testBuildIosFramework(Directory projectDir, { bool isModule = fals
|
||||
await _testStaticAndNoPlugins(projectDir);
|
||||
}
|
||||
|
||||
|
||||
Future<void> _testBuildMacOSFramework(Directory projectDir) async {
|
||||
// This builds all build modes' frameworks by default
|
||||
section('Build macOS frameworks');
|
||||
@@ -533,49 +498,44 @@ Future<void> _testBuildMacOSFramework(Directory projectDir) async {
|
||||
);
|
||||
checkSymlinkExists(debugAppFrameworkPath);
|
||||
|
||||
checkFileExists(path.join(
|
||||
outputPath,
|
||||
'Debug',
|
||||
'App.xcframework',
|
||||
'macos-arm64_x86_64',
|
||||
'App.framework',
|
||||
'Resources',
|
||||
'Info.plist',
|
||||
));
|
||||
checkFileExists(
|
||||
path.join(
|
||||
outputPath,
|
||||
'Debug',
|
||||
'App.xcframework',
|
||||
'macos-arm64_x86_64',
|
||||
'App.framework',
|
||||
'Resources',
|
||||
'Info.plist',
|
||||
),
|
||||
);
|
||||
|
||||
section('Check debug build has Dart snapshot as asset');
|
||||
|
||||
checkFileExists(path.join(
|
||||
outputPath,
|
||||
'Debug',
|
||||
'App.xcframework',
|
||||
'macos-arm64_x86_64',
|
||||
'App.framework',
|
||||
'Resources',
|
||||
'flutter_assets',
|
||||
'vm_snapshot_data',
|
||||
));
|
||||
checkFileExists(
|
||||
path.join(
|
||||
outputPath,
|
||||
'Debug',
|
||||
'App.xcframework',
|
||||
'macos-arm64_x86_64',
|
||||
'App.framework',
|
||||
'Resources',
|
||||
'flutter_assets',
|
||||
'vm_snapshot_data',
|
||||
),
|
||||
);
|
||||
|
||||
section('Check obfuscation symbols');
|
||||
|
||||
checkFileExists(path.join(
|
||||
projectDir.path,
|
||||
'symbols',
|
||||
'app.darwin-arm64.symbols',
|
||||
));
|
||||
checkFileExists(path.join(projectDir.path, 'symbols', 'app.darwin-arm64.symbols'));
|
||||
|
||||
checkFileExists(path.join(
|
||||
projectDir.path,
|
||||
'symbols',
|
||||
'app.darwin-x86_64.symbols',
|
||||
));
|
||||
checkFileExists(path.join(projectDir.path, 'symbols', 'app.darwin-x86_64.symbols'));
|
||||
|
||||
section('Check debug build has no Dart AOT');
|
||||
|
||||
final String aotSymbols = await dumpSymbolTable(debugAppFrameworkPath);
|
||||
|
||||
if (aotSymbols.contains('architecture') ||
|
||||
aotSymbols.contains('_kDartVmSnapshot')) {
|
||||
if (aotSymbols.contains('architecture') || aotSymbols.contains('_kDartVmSnapshot')) {
|
||||
throw TaskResult.failure('Debug App.framework contains AOT');
|
||||
}
|
||||
|
||||
@@ -599,26 +559,30 @@ Future<void> _testBuildMacOSFramework(Directory projectDir) async {
|
||||
throw TaskResult.failure('$mode App.framework missing Dart AOT');
|
||||
}
|
||||
|
||||
checkFileNotExists(path.join(
|
||||
outputPath,
|
||||
mode,
|
||||
'App.xcframework',
|
||||
'macos-arm64_x86_64',
|
||||
'App.framework',
|
||||
'Resources',
|
||||
'flutter_assets',
|
||||
'vm_snapshot_data',
|
||||
));
|
||||
checkFileNotExists(
|
||||
path.join(
|
||||
outputPath,
|
||||
mode,
|
||||
'App.xcframework',
|
||||
'macos-arm64_x86_64',
|
||||
'App.framework',
|
||||
'Resources',
|
||||
'flutter_assets',
|
||||
'vm_snapshot_data',
|
||||
),
|
||||
);
|
||||
|
||||
checkFileExists(path.join(
|
||||
outputPath,
|
||||
mode,
|
||||
'App.xcframework',
|
||||
'macos-arm64_x86_64',
|
||||
'App.framework',
|
||||
'Resources',
|
||||
'Info.plist',
|
||||
));
|
||||
checkFileExists(
|
||||
path.join(
|
||||
outputPath,
|
||||
mode,
|
||||
'App.xcframework',
|
||||
'macos-arm64_x86_64',
|
||||
'App.framework',
|
||||
'Resources',
|
||||
'Info.plist',
|
||||
),
|
||||
);
|
||||
|
||||
final String appFrameworkDsymPath = path.join(
|
||||
outputPath,
|
||||
@@ -626,16 +590,10 @@ Future<void> _testBuildMacOSFramework(Directory projectDir) async {
|
||||
'App.xcframework',
|
||||
'macos-arm64_x86_64',
|
||||
'dSYMs',
|
||||
'App.framework.dSYM'
|
||||
'App.framework.dSYM',
|
||||
);
|
||||
checkDirectoryExists(appFrameworkDsymPath);
|
||||
await _checkDsym(path.join(
|
||||
appFrameworkDsymPath,
|
||||
'Contents',
|
||||
'Resources',
|
||||
'DWARF',
|
||||
'App',
|
||||
));
|
||||
await _checkDsym(path.join(appFrameworkDsymPath, 'Contents', 'Resources', 'DWARF', 'App'));
|
||||
}
|
||||
|
||||
section("Check all modes' engine dylib");
|
||||
@@ -651,15 +609,17 @@ Future<void> _testBuildMacOSFramework(Directory projectDir) async {
|
||||
);
|
||||
checkSymlinkExists(engineBinary);
|
||||
|
||||
checkFileExists(path.join(
|
||||
outputPath,
|
||||
mode,
|
||||
'FlutterMacOS.xcframework',
|
||||
'macos-arm64_x86_64',
|
||||
'FlutterMacOS.framework',
|
||||
'Headers',
|
||||
'FlutterMacOS.h',
|
||||
));
|
||||
checkFileExists(
|
||||
path.join(
|
||||
outputPath,
|
||||
mode,
|
||||
'FlutterMacOS.xcframework',
|
||||
'macos-arm64_x86_64',
|
||||
'FlutterMacOS.framework',
|
||||
'Headers',
|
||||
'FlutterMacOS.h',
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
section('Check all modes have plugins');
|
||||
@@ -688,48 +648,58 @@ Future<void> _testBuildMacOSFramework(Directory projectDir) async {
|
||||
'Reachability',
|
||||
);
|
||||
if (await _linksOnFlutterMacOS(transitiveDependencyFrameworkPath)) {
|
||||
throw TaskResult.failure('Transitive dependency $transitiveDependencyFrameworkPath unexpectedly links on Flutter');
|
||||
throw TaskResult.failure(
|
||||
'Transitive dependency $transitiveDependencyFrameworkPath unexpectedly links on Flutter',
|
||||
);
|
||||
}
|
||||
|
||||
checkFileExists(path.join(
|
||||
outputPath,
|
||||
mode,
|
||||
'connectivity_macos.xcframework',
|
||||
'macos-arm64_x86_64',
|
||||
'connectivity_macos.framework',
|
||||
'Headers',
|
||||
'connectivity_macos-Swift.h',
|
||||
));
|
||||
|
||||
checkDirectoryExists(path.join(
|
||||
outputPath,
|
||||
mode,
|
||||
'connectivity_macos.xcframework',
|
||||
'macos-arm64_x86_64',
|
||||
'connectivity_macos.framework',
|
||||
'Modules',
|
||||
'connectivity_macos.swiftmodule',
|
||||
));
|
||||
|
||||
if (mode != 'Debug') {
|
||||
checkDirectoryExists(path.join(
|
||||
checkFileExists(
|
||||
path.join(
|
||||
outputPath,
|
||||
mode,
|
||||
'connectivity_macos.xcframework',
|
||||
'macos-arm64_x86_64',
|
||||
'dSYMs',
|
||||
'connectivity_macos.framework.dSYM',
|
||||
));
|
||||
'connectivity_macos.framework',
|
||||
'Headers',
|
||||
'connectivity_macos-Swift.h',
|
||||
),
|
||||
);
|
||||
|
||||
checkDirectoryExists(
|
||||
path.join(
|
||||
outputPath,
|
||||
mode,
|
||||
'connectivity_macos.xcframework',
|
||||
'macos-arm64_x86_64',
|
||||
'connectivity_macos.framework',
|
||||
'Modules',
|
||||
'connectivity_macos.swiftmodule',
|
||||
),
|
||||
);
|
||||
|
||||
if (mode != 'Debug') {
|
||||
checkDirectoryExists(
|
||||
path.join(
|
||||
outputPath,
|
||||
mode,
|
||||
'connectivity_macos.xcframework',
|
||||
'macos-arm64_x86_64',
|
||||
'dSYMs',
|
||||
'connectivity_macos.framework.dSYM',
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
checkSymlinkExists(path.join(
|
||||
outputPath,
|
||||
mode,
|
||||
'connectivity_macos.xcframework',
|
||||
'macos-arm64_x86_64',
|
||||
'connectivity_macos.framework',
|
||||
'connectivity_macos',
|
||||
));
|
||||
checkSymlinkExists(
|
||||
path.join(
|
||||
outputPath,
|
||||
mode,
|
||||
'connectivity_macos.xcframework',
|
||||
'macos-arm64_x86_64',
|
||||
'connectivity_macos.framework',
|
||||
'connectivity_macos',
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
// This builds all build modes' frameworks by default
|
||||
@@ -752,19 +722,17 @@ Future<void> _testBuildMacOSFramework(Directory projectDir) async {
|
||||
|
||||
final String cocoapodsOutputPath = path.join(projectDir.path, cocoapodsOutputDirectoryName);
|
||||
for (final String mode in <String>['Debug', 'Profile', 'Release']) {
|
||||
checkFileExists(path.join(
|
||||
cocoapodsOutputPath,
|
||||
mode,
|
||||
'FlutterMacOS.podspec',
|
||||
));
|
||||
await _checkDylib(path.join(
|
||||
cocoapodsOutputPath,
|
||||
mode,
|
||||
'App.xcframework',
|
||||
'macos-arm64_x86_64',
|
||||
'App.framework',
|
||||
'App',
|
||||
));
|
||||
checkFileExists(path.join(cocoapodsOutputPath, mode, 'FlutterMacOS.podspec'));
|
||||
await _checkDylib(
|
||||
path.join(
|
||||
cocoapodsOutputPath,
|
||||
mode,
|
||||
'App.xcframework',
|
||||
'macos-arm64_x86_64',
|
||||
'App.framework',
|
||||
'App',
|
||||
),
|
||||
);
|
||||
|
||||
if (mode != 'Debug') {
|
||||
final String appFrameworkDsymPath = path.join(
|
||||
@@ -773,59 +741,44 @@ Future<void> _testBuildMacOSFramework(Directory projectDir) async {
|
||||
'App.xcframework',
|
||||
'macos-arm64_x86_64',
|
||||
'dSYMs',
|
||||
'App.framework.dSYM'
|
||||
'App.framework.dSYM',
|
||||
);
|
||||
checkDirectoryExists(appFrameworkDsymPath);
|
||||
await _checkDsym(path.join(
|
||||
appFrameworkDsymPath,
|
||||
'Contents',
|
||||
'Resources',
|
||||
'DWARF',
|
||||
'App',
|
||||
));
|
||||
await _checkDsym(path.join(appFrameworkDsymPath, 'Contents', 'Resources', 'DWARF', 'App'));
|
||||
}
|
||||
|
||||
await _checkStatic(path.join(
|
||||
cocoapodsOutputPath,
|
||||
mode,
|
||||
'package_info.xcframework',
|
||||
'macos-arm64_x86_64',
|
||||
'package_info.framework',
|
||||
'package_info',
|
||||
));
|
||||
await _checkStatic(
|
||||
path.join(
|
||||
cocoapodsOutputPath,
|
||||
mode,
|
||||
'package_info.xcframework',
|
||||
'macos-arm64_x86_64',
|
||||
'package_info.framework',
|
||||
'package_info',
|
||||
),
|
||||
);
|
||||
|
||||
await _checkStatic(path.join(
|
||||
cocoapodsOutputPath,
|
||||
mode,
|
||||
'connectivity_macos.xcframework',
|
||||
'macos-arm64_x86_64',
|
||||
'connectivity_macos.framework',
|
||||
'connectivity_macos',
|
||||
));
|
||||
await _checkStatic(
|
||||
path.join(
|
||||
cocoapodsOutputPath,
|
||||
mode,
|
||||
'connectivity_macos.xcframework',
|
||||
'macos-arm64_x86_64',
|
||||
'connectivity_macos.framework',
|
||||
'connectivity_macos',
|
||||
),
|
||||
);
|
||||
|
||||
checkDirectoryExists(path.join(
|
||||
cocoapodsOutputPath,
|
||||
mode,
|
||||
'Reachability.xcframework',
|
||||
));
|
||||
checkDirectoryExists(path.join(cocoapodsOutputPath, mode, 'Reachability.xcframework'));
|
||||
}
|
||||
|
||||
checkFileExists(path.join(
|
||||
outputPath,
|
||||
'GeneratedPluginRegistrant.swift',
|
||||
));
|
||||
checkFileExists(path.join(outputPath, 'GeneratedPluginRegistrant.swift'));
|
||||
|
||||
section('Validate embed FlutterMacOS.framework with CocoaPods');
|
||||
|
||||
final File podspec = File(path.join(
|
||||
cocoapodsOutputPath,
|
||||
'Debug',
|
||||
'FlutterMacOS.podspec',
|
||||
));
|
||||
final File podspec = File(path.join(cocoapodsOutputPath, 'Debug', 'FlutterMacOS.podspec'));
|
||||
|
||||
podspec.writeAsStringSync(
|
||||
podspec.readAsStringSync().replaceFirst('null.null.0', '0.0.0'),
|
||||
);
|
||||
podspec.writeAsStringSync(podspec.readAsStringSync().replaceFirst('null.null.0', '0.0.0'));
|
||||
|
||||
final Directory macosDirectory = Directory(path.join(projectDir.path, 'macos'));
|
||||
final File podfile = File(path.join(macosDirectory.path, 'Podfile'));
|
||||
@@ -854,7 +807,10 @@ end
|
||||
await _testBuildFrameworksWithoutPlugins(projectDir, platform: 'macos');
|
||||
}
|
||||
|
||||
Future<void> _testBuildFrameworksWithoutPlugins(Directory projectDir, { required String platform}) async {
|
||||
Future<void> _testBuildFrameworksWithoutPlugins(
|
||||
Directory projectDir, {
|
||||
required String platform,
|
||||
}) async {
|
||||
const String noPluginsOutputDir = 'flutter-frameworks-no-plugins';
|
||||
|
||||
await inDirectory(projectDir, () async {
|
||||
@@ -872,34 +828,16 @@ Future<void> _testBuildFrameworksWithoutPlugins(Directory projectDir, { required
|
||||
|
||||
final String noPluginsOutputPath = path.join(projectDir.path, noPluginsOutputDir);
|
||||
for (final String mode in <String>['Debug', 'Profile', 'Release']) {
|
||||
checkFileExists(path.join(
|
||||
noPluginsOutputPath,
|
||||
mode,
|
||||
'Flutter${platform == 'macos' ? 'MacOS' : ''}.podspec',
|
||||
));
|
||||
checkDirectoryExists(path.join(
|
||||
noPluginsOutputPath,
|
||||
mode,
|
||||
'App.xcframework',
|
||||
));
|
||||
checkFileExists(
|
||||
path.join(noPluginsOutputPath, mode, 'Flutter${platform == 'macos' ? 'MacOS' : ''}.podspec'),
|
||||
);
|
||||
checkDirectoryExists(path.join(noPluginsOutputPath, mode, 'App.xcframework'));
|
||||
|
||||
checkDirectoryNotExists(path.join(
|
||||
noPluginsOutputPath,
|
||||
mode,
|
||||
'package_info.xcframework',
|
||||
));
|
||||
checkDirectoryNotExists(path.join(noPluginsOutputPath, mode, 'package_info.xcframework'));
|
||||
|
||||
checkDirectoryNotExists(path.join(
|
||||
noPluginsOutputPath,
|
||||
mode,
|
||||
'connectivity.xcframework',
|
||||
));
|
||||
checkDirectoryNotExists(path.join(noPluginsOutputPath, mode, 'connectivity.xcframework'));
|
||||
|
||||
checkDirectoryNotExists(path.join(
|
||||
noPluginsOutputPath,
|
||||
mode,
|
||||
'Reachability.xcframework',
|
||||
));
|
||||
checkDirectoryNotExists(path.join(noPluginsOutputPath, mode, 'Reachability.xcframework'));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -907,16 +845,16 @@ Future<void> _testStaticAndNoPlugins(Directory projectDir) async {
|
||||
const String noPluginsOutputDir = 'flutter-frameworks-no-plugins-static';
|
||||
final ProcessResult result = await inDirectory(projectDir, () async {
|
||||
return executeFlutter(
|
||||
'build',
|
||||
options: <String>[
|
||||
'ios-framework',
|
||||
'--cocoapods',
|
||||
'--force', // Allow podspec creation on master.
|
||||
'--output=$noPluginsOutputDir',
|
||||
'--no-plugins',
|
||||
'--static'
|
||||
],
|
||||
canFail: true
|
||||
'build',
|
||||
options: <String>[
|
||||
'ios-framework',
|
||||
'--cocoapods',
|
||||
'--force', // Allow podspec creation on master.
|
||||
'--output=$noPluginsOutputDir',
|
||||
'--no-plugins',
|
||||
'--static',
|
||||
],
|
||||
canFail: true,
|
||||
);
|
||||
});
|
||||
if (result.exitCode == 0) {
|
||||
@@ -950,21 +888,11 @@ Future<void> _checkStatic(String pathToLibrary) async {
|
||||
}
|
||||
|
||||
Future<bool> _linksOnFlutter(String pathToBinary) async {
|
||||
final String loadCommands = await eval('otool', <String>[
|
||||
'-l',
|
||||
'-arch',
|
||||
'arm64',
|
||||
pathToBinary,
|
||||
]);
|
||||
final String loadCommands = await eval('otool', <String>['-l', '-arch', 'arm64', pathToBinary]);
|
||||
return loadCommands.contains('Flutter.framework');
|
||||
}
|
||||
|
||||
Future<bool> _linksOnFlutterMacOS(String pathToBinary) async {
|
||||
final String loadCommands = await eval('otool', <String>[
|
||||
'-l',
|
||||
'-arch',
|
||||
'arm64',
|
||||
pathToBinary,
|
||||
]);
|
||||
final String loadCommands = await eval('otool', <String>['-l', '-arch', 'arm64', pathToBinary]);
|
||||
return loadCommands.contains('FlutterMacOS.framework');
|
||||
}
|
||||
|
||||
@@ -9,8 +9,10 @@ import 'package:flutter_devicelab/tasks/perf_tests.dart';
|
||||
|
||||
Future<void> main() async {
|
||||
deviceOperatingSystem = DeviceOperatingSystem.android;
|
||||
await task(DevToolsMemoryTest(
|
||||
'${flutterDirectory.path}/dev/benchmarks/complex_layout',
|
||||
'test_driver/scroll_perf.dart',
|
||||
).run);
|
||||
await task(
|
||||
DevToolsMemoryTest(
|
||||
'${flutterDirectory.path}/dev/benchmarks/complex_layout',
|
||||
'test_driver/scroll_perf.dart',
|
||||
).run,
|
||||
);
|
||||
}
|
||||
|
||||
@@ -9,10 +9,12 @@ import 'package:flutter_devicelab/tasks/perf_tests.dart';
|
||||
|
||||
Future<void> main() async {
|
||||
deviceOperatingSystem = DeviceOperatingSystem.android;
|
||||
await task(MemoryTest(
|
||||
'${flutterDirectory.path}/dev/benchmarks/complex_layout',
|
||||
'test_memory/scroll_perf.dart',
|
||||
'com.yourcompany.complexLayout',
|
||||
requiresTapToStart: true,
|
||||
).run);
|
||||
await task(
|
||||
MemoryTest(
|
||||
'${flutterDirectory.path}/dev/benchmarks/complex_layout',
|
||||
'test_memory/scroll_perf.dart',
|
||||
'com.yourcompany.complexLayout',
|
||||
requiresTapToStart: true,
|
||||
).run,
|
||||
);
|
||||
}
|
||||
|
||||
@@ -19,25 +19,35 @@ void main() {
|
||||
final String deviceId = device.deviceId;
|
||||
await flutter('packages', options: <String>['get']);
|
||||
|
||||
final String complexLayoutPath = p.join(flutterDirectory.path, 'dev', 'benchmarks', 'complex_layout');
|
||||
final String complexLayoutPath = p.join(
|
||||
flutterDirectory.path,
|
||||
'dev',
|
||||
'benchmarks',
|
||||
'complex_layout',
|
||||
);
|
||||
|
||||
await inDirectory(complexLayoutPath, () async {
|
||||
await flutter('drive', options: <String>[
|
||||
'--no-android-gradle-daemon',
|
||||
'-v',
|
||||
'--profile',
|
||||
'--trace-startup', // Enables "endless" timeline event buffering.
|
||||
'-t',
|
||||
p.join(complexLayoutPath, 'test_driver', 'semantics_perf.dart'),
|
||||
'-d',
|
||||
deviceId,
|
||||
]);
|
||||
await flutter(
|
||||
'drive',
|
||||
options: <String>[
|
||||
'--no-android-gradle-daemon',
|
||||
'-v',
|
||||
'--profile',
|
||||
'--trace-startup', // Enables "endless" timeline event buffering.
|
||||
'-t',
|
||||
p.join(complexLayoutPath, 'test_driver', 'semantics_perf.dart'),
|
||||
'-d',
|
||||
deviceId,
|
||||
],
|
||||
);
|
||||
});
|
||||
|
||||
final String outputPath = Platform.environment['FLUTTER_TEST_OUTPUTS_DIR'] ?? p.join(complexLayoutPath, 'build');
|
||||
final String outputPath =
|
||||
Platform.environment['FLUTTER_TEST_OUTPUTS_DIR'] ?? p.join(complexLayoutPath, 'build');
|
||||
final String dataPath = p.join(outputPath, 'complex_layout_semantics_perf.json');
|
||||
return TaskResult.successFromFile(file(dataPath), benchmarkScoreKeys: <String>[
|
||||
'initialSemanticsTreeCreation',
|
||||
]);
|
||||
return TaskResult.successFromFile(
|
||||
file(dataPath),
|
||||
benchmarkScoreKeys: <String>['initialSemanticsTreeCreation'],
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -9,7 +9,5 @@ import 'package:flutter_devicelab/tasks/perf_tests.dart';
|
||||
|
||||
Future<void> main() async {
|
||||
deviceOperatingSystem = DeviceOperatingSystem.android;
|
||||
await task(DevtoolsStartupTest(
|
||||
'${flutterDirectory.path}/examples/hello_world',
|
||||
).run);
|
||||
await task(DevtoolsStartupTest('${flutterDirectory.path}/examples/hello_world').run);
|
||||
}
|
||||
|
||||
@@ -9,13 +9,11 @@ import 'package:flutter_devicelab/framework/utils.dart';
|
||||
|
||||
Future<String> _runWithMode(String mode, String deviceId) async {
|
||||
final StringBuffer stderr = StringBuffer();
|
||||
await evalFlutter('drive', stderr: stderr, options: <String>[
|
||||
mode,
|
||||
'-t',
|
||||
'test_driver/scroll_perf.dart',
|
||||
'-d',
|
||||
deviceId,
|
||||
]);
|
||||
await evalFlutter(
|
||||
'drive',
|
||||
stderr: stderr,
|
||||
options: <String>[mode, '-t', 'test_driver/scroll_perf.dart', '-d', deviceId],
|
||||
);
|
||||
return stderr.toString();
|
||||
}
|
||||
|
||||
@@ -30,16 +28,12 @@ Future<TaskResult> run() async {
|
||||
|
||||
final String debugOutput = await _runWithMode('--debug', deviceId);
|
||||
if (!debugOutput.contains(warningPiece)) {
|
||||
return TaskResult.failure(
|
||||
'Could not find the following warning message piece: $warningPiece'
|
||||
);
|
||||
return TaskResult.failure('Could not find the following warning message piece: $warningPiece');
|
||||
}
|
||||
|
||||
final String profileOutput = await _runWithMode('--profile', deviceId);
|
||||
if (profileOutput.contains(warningPiece)) {
|
||||
return TaskResult.failure(
|
||||
'Unexpected warning message piece in profile mode: $warningPiece'
|
||||
);
|
||||
return TaskResult.failure('Unexpected warning message piece in profile mode: $warningPiece');
|
||||
}
|
||||
|
||||
return TaskResult.success(null);
|
||||
|
||||
@@ -29,7 +29,9 @@ Future<void> main() async {
|
||||
await runProjectTest((FlutterProject flutterProject) async {
|
||||
await inDirectory(path.join(flutterProject.rootPath, 'android'), () async {
|
||||
section('Insert gradle testing script');
|
||||
final File buildFile = getAndroidBuildFile(path.join(flutterProject.rootPath, 'android', 'app'));
|
||||
final File buildFile = getAndroidBuildFile(
|
||||
path.join(flutterProject.rootPath, 'android', 'app'),
|
||||
);
|
||||
buildFile.writeAsStringSync(
|
||||
'''
|
||||
tasks.register("printEngineMavenUrl") {
|
||||
@@ -49,18 +51,16 @@ tasks.register("printEngineMavenUrl") {
|
||||
|
||||
section('Checking default maven URL');
|
||||
|
||||
String gradleOutput = await eval(
|
||||
gradlewExecutable,
|
||||
<String>['printEngineMavenUrl', '-q'],
|
||||
);
|
||||
String gradleOutput = await eval(gradlewExecutable, <String>['printEngineMavenUrl', '-q']);
|
||||
const LineSplitter splitter = LineSplitter();
|
||||
List<String> outputLines = splitter.convert(gradleOutput);
|
||||
String mavenUrl = outputLines.last;
|
||||
print('Returned maven url: $mavenUrl');
|
||||
|
||||
String realm = File(
|
||||
path.join(flutterDirectory.path, 'bin', 'internal', 'engine.realm'),
|
||||
).readAsStringSync().trim();
|
||||
String realm =
|
||||
File(
|
||||
path.join(flutterDirectory.path, 'bin', 'internal', 'engine.realm'),
|
||||
).readAsStringSync().trim();
|
||||
if (realm.isNotEmpty) {
|
||||
realm = '$realm/';
|
||||
}
|
||||
@@ -76,10 +76,8 @@ tasks.register("printEngineMavenUrl") {
|
||||
section('Checking overridden maven URL');
|
||||
gradleOutput = await eval(
|
||||
gradlewExecutable,
|
||||
<String>['printEngineMavenUrl','-q'],
|
||||
environment: <String, String>{
|
||||
'FLUTTER_STORAGE_BASE_URL': 'https://my.special.proxy',
|
||||
},
|
||||
<String>['printEngineMavenUrl', '-q'],
|
||||
environment: <String, String>{'FLUTTER_STORAGE_BASE_URL': 'https://my.special.proxy'},
|
||||
);
|
||||
outputLines = splitter.convert(gradleOutput);
|
||||
mavenUrl = outputLines.last;
|
||||
|
||||
@@ -11,10 +11,11 @@ const String kPackageName = 'com.example.macrobenchmarks';
|
||||
|
||||
class FastScrollHeavyGridViewMemoryTest extends MemoryTest {
|
||||
FastScrollHeavyGridViewMemoryTest()
|
||||
: super(
|
||||
'${flutterDirectory.path}/dev/benchmarks/macrobenchmarks',
|
||||
'test_memory/heavy_gridview.dart', kPackageName,
|
||||
);
|
||||
: super(
|
||||
'${flutterDirectory.path}/dev/benchmarks/macrobenchmarks',
|
||||
'test_memory/heavy_gridview.dart',
|
||||
kPackageName,
|
||||
);
|
||||
|
||||
@override
|
||||
AndroidDevice? get device => super.device as AndroidDevice?;
|
||||
|
||||
@@ -11,10 +11,11 @@ const String kPackageName = 'com.example.macrobenchmarks';
|
||||
|
||||
class FastScrollLargeImagesMemoryTest extends MemoryTest {
|
||||
FastScrollLargeImagesMemoryTest()
|
||||
: super(
|
||||
'${flutterDirectory.path}/dev/benchmarks/macrobenchmarks',
|
||||
'test_memory/large_images.dart', kPackageName,
|
||||
);
|
||||
: super(
|
||||
'${flutterDirectory.path}/dev/benchmarks/macrobenchmarks',
|
||||
'test_memory/large_images.dart',
|
||||
kPackageName,
|
||||
);
|
||||
|
||||
@override
|
||||
AndroidDevice? get device => super.device as AndroidDevice?;
|
||||
|
||||
@@ -21,20 +21,18 @@ Future<void> main() async {
|
||||
await createIntegrationTestFlavorsTest().call();
|
||||
|
||||
final String projectPath = '${flutterDirectory.path}/dev/integration_tests/flavors';
|
||||
final TaskResult installTestsResult = await inDirectory(
|
||||
projectPath,
|
||||
() async {
|
||||
final List<TaskResult> testResults = <TaskResult>[
|
||||
await _testInstallDebugPaidFlavor(projectPath),
|
||||
await _testInstallBogusFlavor(),
|
||||
];
|
||||
final TaskResult installTestsResult = await inDirectory(projectPath, () async {
|
||||
final List<TaskResult> testResults = <TaskResult>[
|
||||
await _testInstallDebugPaidFlavor(projectPath),
|
||||
await _testInstallBogusFlavor(),
|
||||
];
|
||||
|
||||
final TaskResult? firstInstallFailure = testResults
|
||||
.firstWhereOrNull((TaskResult element) => element.failed);
|
||||
final TaskResult? firstInstallFailure = testResults.firstWhereOrNull(
|
||||
(TaskResult element) => element.failed,
|
||||
);
|
||||
|
||||
return firstInstallFailure ?? TaskResult.success(null);
|
||||
},
|
||||
);
|
||||
return firstInstallFailure ?? TaskResult.success(null);
|
||||
});
|
||||
|
||||
return installTestsResult;
|
||||
});
|
||||
@@ -42,34 +40,44 @@ Future<void> main() async {
|
||||
|
||||
// Ensures installation works. Also tests asset bundling while we are at it.
|
||||
Future<TaskResult> _testInstallDebugPaidFlavor(String projectDir) async {
|
||||
await evalFlutter(
|
||||
'install',
|
||||
options: <String>['--debug', '--flavor', 'paid'],
|
||||
);
|
||||
await evalFlutter('install', options: <String>['--debug', '--flavor', 'paid']);
|
||||
|
||||
final Uint8List assetManifestFileData = File(
|
||||
path.join(projectDir, 'build', 'app', 'intermediates', 'assets', 'paidDebug', 'mergePaidDebugAssets', 'flutter_assets', 'AssetManifest.bin'),
|
||||
).readAsBytesSync();
|
||||
final Uint8List assetManifestFileData =
|
||||
File(
|
||||
path.join(
|
||||
projectDir,
|
||||
'build',
|
||||
'app',
|
||||
'intermediates',
|
||||
'assets',
|
||||
'paidDebug',
|
||||
'mergePaidDebugAssets',
|
||||
'flutter_assets',
|
||||
'AssetManifest.bin',
|
||||
),
|
||||
).readAsBytesSync();
|
||||
|
||||
final Map<Object?, Object?> assetManifest = const StandardMessageCodec()
|
||||
.decodeMessage(ByteData.sublistView(assetManifestFileData)) as Map<Object?, Object?>;
|
||||
final Map<Object?, Object?> assetManifest =
|
||||
const StandardMessageCodec().decodeMessage(ByteData.sublistView(assetManifestFileData))
|
||||
as Map<Object?, Object?>;
|
||||
|
||||
if (assetManifest.containsKey('assets/free/free.txt')) {
|
||||
return TaskResult.failure('Expected the asset "assets/free/free.txt", which '
|
||||
return TaskResult.failure(
|
||||
'Expected the asset "assets/free/free.txt", which '
|
||||
' was declared with a flavor of "free" to not be included in the asset bundle '
|
||||
' because the --flavor was set to "paid".');
|
||||
' because the --flavor was set to "paid".',
|
||||
);
|
||||
}
|
||||
|
||||
if (!assetManifest.containsKey('assets/paid/paid.txt')) {
|
||||
return TaskResult.failure('Expected the asset "assets/paid/paid.txt", which '
|
||||
return TaskResult.failure(
|
||||
'Expected the asset "assets/paid/paid.txt", which '
|
||||
' was declared with a flavor of "paid" to be included in the asset bundle '
|
||||
' because the --flavor was set to "paid".');
|
||||
' because the --flavor was set to "paid".',
|
||||
);
|
||||
}
|
||||
|
||||
await flutter(
|
||||
'install',
|
||||
options: <String>['--debug', '--flavor', 'paid', '--uninstall-only'],
|
||||
);
|
||||
await flutter('install', options: <String>['--debug', '--flavor', 'paid', '--uninstall-only']);
|
||||
|
||||
return TaskResult.success(null);
|
||||
}
|
||||
@@ -84,7 +92,13 @@ Future<TaskResult> _testInstallBogusFlavor() async {
|
||||
);
|
||||
|
||||
final String stderrString = stderr.toString();
|
||||
final String expectedApkPath = path.join('build', 'app', 'outputs', 'flutter-apk', 'app-bogus-release.apk');
|
||||
final String expectedApkPath = path.join(
|
||||
'build',
|
||||
'app',
|
||||
'outputs',
|
||||
'flutter-apk',
|
||||
'app-bogus-release.apk',
|
||||
);
|
||||
if (!stderrString.contains('"$expectedApkPath" does not exist.')) {
|
||||
print(stderrString);
|
||||
return TaskResult.failure('Should not succeed with bogus flavor');
|
||||
|
||||
@@ -21,63 +21,61 @@ Future<void> main() async {
|
||||
await createIntegrationTestFlavorsTest().call();
|
||||
// test install and uninstall of flavors app
|
||||
final String projectDir = '${flutterDirectory.path}/dev/integration_tests/flavors';
|
||||
final TaskResult installTestsResult = await inDirectory(
|
||||
projectDir,
|
||||
() async {
|
||||
final List<TaskResult> testResults = <TaskResult>[
|
||||
await _testInstallDebugPaidFlavor(projectDir),
|
||||
await _testInstallBogusFlavor(),
|
||||
];
|
||||
final TaskResult installTestsResult = await inDirectory(projectDir, () async {
|
||||
final List<TaskResult> testResults = <TaskResult>[
|
||||
await _testInstallDebugPaidFlavor(projectDir),
|
||||
await _testInstallBogusFlavor(),
|
||||
];
|
||||
|
||||
final TaskResult? firstInstallFailure = testResults
|
||||
.firstWhereOrNull((TaskResult element) => element.failed);
|
||||
final TaskResult? firstInstallFailure = testResults.firstWhereOrNull(
|
||||
(TaskResult element) => element.failed,
|
||||
);
|
||||
|
||||
return firstInstallFailure ?? TaskResult.success(null);
|
||||
},
|
||||
);
|
||||
return firstInstallFailure ?? TaskResult.success(null);
|
||||
});
|
||||
|
||||
return installTestsResult;
|
||||
});
|
||||
}
|
||||
|
||||
Future<TaskResult> _testInstallDebugPaidFlavor(String projectDir) async {
|
||||
await evalFlutter(
|
||||
'install',
|
||||
options: <String>['--flavor', 'paid'],
|
||||
);
|
||||
final Uint8List assetManifestFileData = File(
|
||||
path.join(
|
||||
projectDir,
|
||||
'build',
|
||||
'ios',
|
||||
'iphoneos',
|
||||
'Paid App.app',
|
||||
'Frameworks',
|
||||
'App.framework',
|
||||
'flutter_assets',
|
||||
'AssetManifest.bin',
|
||||
),
|
||||
).readAsBytesSync();
|
||||
await evalFlutter('install', options: <String>['--flavor', 'paid']);
|
||||
final Uint8List assetManifestFileData =
|
||||
File(
|
||||
path.join(
|
||||
projectDir,
|
||||
'build',
|
||||
'ios',
|
||||
'iphoneos',
|
||||
'Paid App.app',
|
||||
'Frameworks',
|
||||
'App.framework',
|
||||
'flutter_assets',
|
||||
'AssetManifest.bin',
|
||||
),
|
||||
).readAsBytesSync();
|
||||
|
||||
final Map<Object?, Object?> assetManifest = const StandardMessageCodec()
|
||||
.decodeMessage(ByteData.sublistView(assetManifestFileData)) as Map<Object?, Object?>;
|
||||
final Map<Object?, Object?> assetManifest =
|
||||
const StandardMessageCodec().decodeMessage(ByteData.sublistView(assetManifestFileData))
|
||||
as Map<Object?, Object?>;
|
||||
|
||||
if (assetManifest.containsKey('assets/free/free.txt')) {
|
||||
return TaskResult.failure('Expected the asset "assets/free/free.txt", which '
|
||||
return TaskResult.failure(
|
||||
'Expected the asset "assets/free/free.txt", which '
|
||||
' was declared with a flavor of "free" to not be included in the asset bundle '
|
||||
' because the --flavor was set to "paid".');
|
||||
' because the --flavor was set to "paid".',
|
||||
);
|
||||
}
|
||||
|
||||
if (!assetManifest.containsKey('assets/paid/paid.txt')) {
|
||||
return TaskResult.failure('Expected the asset "assets/paid/paid.txt", which '
|
||||
return TaskResult.failure(
|
||||
'Expected the asset "assets/paid/paid.txt", which '
|
||||
' was declared with a flavor of "paid" to be included in the asset bundle '
|
||||
' because the --flavor was set to "paid".');
|
||||
' because the --flavor was set to "paid".',
|
||||
);
|
||||
}
|
||||
|
||||
await flutter(
|
||||
'install',
|
||||
options: <String>['--flavor', 'paid', '--uninstall-only'],
|
||||
);
|
||||
await flutter('install', options: <String>['--flavor', 'paid', '--uninstall-only']);
|
||||
|
||||
return TaskResult.success(null);
|
||||
}
|
||||
|
||||
@@ -20,68 +20,68 @@ Future<void> main() async {
|
||||
await createIntegrationTestFlavorsTest().call();
|
||||
|
||||
final String projectDir = '${flutterDirectory.path}/dev/integration_tests/flavors';
|
||||
final TaskResult installTestsResult = await inDirectory(
|
||||
projectDir,
|
||||
() async {
|
||||
await flutter(
|
||||
'install',
|
||||
options: <String>['--flavor', 'paid', '-d', 'macos'],
|
||||
final TaskResult installTestsResult = await inDirectory(projectDir, () async {
|
||||
await flutter('install', options: <String>['--flavor', 'paid', '-d', 'macos']);
|
||||
await flutter(
|
||||
'install',
|
||||
options: <String>['--flavor', 'paid', '--uninstall-only', '-d', 'macos'],
|
||||
);
|
||||
final StringBuffer stderr = StringBuffer();
|
||||
await evalFlutter(
|
||||
'build',
|
||||
canFail: true,
|
||||
stderr: stderr,
|
||||
options: <String>['macos', '--flavor', 'bogus'],
|
||||
);
|
||||
|
||||
final Uint8List assetManifestFileData =
|
||||
File(
|
||||
path.join(
|
||||
projectDir,
|
||||
'build',
|
||||
'macos',
|
||||
'Build',
|
||||
'Products',
|
||||
'Debug-paid',
|
||||
'Debug Paid.app',
|
||||
'Contents',
|
||||
'Frameworks',
|
||||
'App.framework',
|
||||
'Resources',
|
||||
'flutter_assets',
|
||||
'AssetManifest.bin',
|
||||
),
|
||||
).readAsBytesSync();
|
||||
|
||||
final Map<Object?, Object?> assetManifest =
|
||||
const StandardMessageCodec().decodeMessage(ByteData.sublistView(assetManifestFileData))
|
||||
as Map<Object?, Object?>;
|
||||
|
||||
if (assetManifest.containsKey('assets/free/free.txt')) {
|
||||
return TaskResult.failure(
|
||||
'Expected the asset "assets/free/free.txt", which '
|
||||
' was declared with a flavor of "free" to not be included in the asset bundle '
|
||||
' because the --flavor was set to "paid".',
|
||||
);
|
||||
await flutter(
|
||||
'install',
|
||||
options: <String>['--flavor', 'paid', '--uninstall-only', '-d', 'macos'],
|
||||
);
|
||||
final StringBuffer stderr = StringBuffer();
|
||||
await evalFlutter(
|
||||
'build',
|
||||
canFail: true,
|
||||
stderr: stderr,
|
||||
options: <String>['macos', '--flavor', 'bogus'],
|
||||
}
|
||||
|
||||
if (!assetManifest.containsKey('assets/paid/paid.txt')) {
|
||||
return TaskResult.failure(
|
||||
'Expected the asset "assets/paid/paid.txt", which '
|
||||
' was declared with a flavor of "paid" to be included in the asset bundle '
|
||||
' because the --flavor was set to "paid".',
|
||||
);
|
||||
}
|
||||
|
||||
final Uint8List assetManifestFileData = File(
|
||||
path.join(
|
||||
projectDir,
|
||||
'build',
|
||||
'macos',
|
||||
'Build',
|
||||
'Products',
|
||||
'Debug-paid',
|
||||
'Debug Paid.app',
|
||||
'Contents',
|
||||
'Frameworks',
|
||||
'App.framework',
|
||||
'Resources',
|
||||
'flutter_assets',
|
||||
'AssetManifest.bin'
|
||||
),
|
||||
).readAsBytesSync();
|
||||
|
||||
final Map<Object?, Object?> assetManifest = const StandardMessageCodec()
|
||||
.decodeMessage(ByteData.sublistView(assetManifestFileData)) as Map<Object?, Object?>;
|
||||
|
||||
if (assetManifest.containsKey('assets/free/free.txt')) {
|
||||
return TaskResult.failure('Expected the asset "assets/free/free.txt", which '
|
||||
' was declared with a flavor of "free" to not be included in the asset bundle '
|
||||
' because the --flavor was set to "paid".');
|
||||
}
|
||||
|
||||
if (!assetManifest.containsKey('assets/paid/paid.txt')) {
|
||||
return TaskResult.failure('Expected the asset "assets/paid/paid.txt", which '
|
||||
' was declared with a flavor of "paid" to be included in the asset bundle '
|
||||
' because the --flavor was set to "paid".');
|
||||
}
|
||||
|
||||
final String stderrString = stderr.toString();
|
||||
final String stderrString = stderr.toString();
|
||||
print(stderrString);
|
||||
if (!stderrString.contains('The Xcode project defines schemes:')) {
|
||||
print(stderrString);
|
||||
if (!stderrString.contains('The Xcode project defines schemes:')) {
|
||||
print(stderrString);
|
||||
return TaskResult.failure('Should not succeed with bogus flavor');
|
||||
}
|
||||
return TaskResult.failure('Should not succeed with bogus flavor');
|
||||
}
|
||||
|
||||
return TaskResult.success(null);
|
||||
},
|
||||
);
|
||||
return TaskResult.success(null);
|
||||
});
|
||||
|
||||
return installTestsResult;
|
||||
});
|
||||
|
||||
@@ -16,7 +16,10 @@ const String _activityName = 'MainActivity';
|
||||
const int _numberOfIterations = 10;
|
||||
|
||||
Future<void> _withApkInstall(
|
||||
String apkPath, String bundleName, Future<void> Function(AndroidDevice) body) async {
|
||||
String apkPath,
|
||||
String bundleName,
|
||||
Future<void> Function(AndroidDevice) body,
|
||||
) async {
|
||||
final DeviceDiscovery devices = DeviceDiscovery();
|
||||
final AndroidDevice device = await devices.workingDevice as AndroidDevice;
|
||||
await device.unlock();
|
||||
@@ -39,37 +42,56 @@ void _copyGradleFromModule(String source, String destination) {
|
||||
final String windowsWrapperDestinationPath = path.join(destination, 'gradlew.bat');
|
||||
File(wrapperPath).copySync(wrapperDestinationPath);
|
||||
File(windowsWrapperPath).copySync(windowsWrapperDestinationPath);
|
||||
final Directory gradleDestinationDirectory = Directory(path.join(destination, 'gradle', 'wrapper'));
|
||||
final Directory gradleDestinationDirectory = Directory(
|
||||
path.join(destination, 'gradle', 'wrapper'),
|
||||
);
|
||||
if (!gradleDestinationDirectory.existsSync()) {
|
||||
gradleDestinationDirectory.createSync(recursive: true);
|
||||
}
|
||||
final String gradleDestinationPath = path.join(gradleDestinationDirectory.path, 'gradle-wrapper.jar');
|
||||
final String gradlePath = path.join(source, '.android', 'gradle', 'wrapper', 'gradle-wrapper.jar');
|
||||
final String gradleDestinationPath = path.join(
|
||||
gradleDestinationDirectory.path,
|
||||
'gradle-wrapper.jar',
|
||||
);
|
||||
final String gradlePath = path.join(
|
||||
source,
|
||||
'.android',
|
||||
'gradle',
|
||||
'wrapper',
|
||||
'gradle-wrapper.jar',
|
||||
);
|
||||
File(gradlePath).copySync(gradleDestinationPath);
|
||||
}
|
||||
|
||||
Future<TaskResult> _doTest() async {
|
||||
try {
|
||||
final String flutterDirectory = utils.flutterDirectory.path;
|
||||
final String multipleFluttersPath =
|
||||
path.join(flutterDirectory, 'dev', 'benchmarks', 'multiple_flutters');
|
||||
final String multipleFluttersPath = path.join(
|
||||
flutterDirectory,
|
||||
'dev',
|
||||
'benchmarks',
|
||||
'multiple_flutters',
|
||||
);
|
||||
final String modulePath = path.join(multipleFluttersPath, 'module');
|
||||
final String androidPath = path.join(multipleFluttersPath, 'android');
|
||||
|
||||
final String gradlew = Platform.isWindows ? 'gradlew.bat' : 'gradlew';
|
||||
final String gradlewExecutable =
|
||||
Platform.isWindows ? '.\\$gradlew' : './$gradlew';
|
||||
await utils.flutter('precache', options: <String>['--android'],
|
||||
workingDirectory: modulePath);
|
||||
await utils.flutter('pub', options: <String>['get'],
|
||||
workingDirectory: modulePath);
|
||||
final String gradlewExecutable = Platform.isWindows ? '.\\$gradlew' : './$gradlew';
|
||||
await utils.flutter('precache', options: <String>['--android'], workingDirectory: modulePath);
|
||||
await utils.flutter('pub', options: <String>['get'], workingDirectory: modulePath);
|
||||
_copyGradleFromModule(modulePath, androidPath);
|
||||
|
||||
await utils.eval(gradlewExecutable, <String>['assembleRelease'],
|
||||
workingDirectory: androidPath);
|
||||
await utils.eval(gradlewExecutable, <String>['assembleRelease'], workingDirectory: androidPath);
|
||||
|
||||
final String apkPath = path.join(multipleFluttersPath, 'android', 'app',
|
||||
'build', 'outputs', 'apk', 'release', 'app-release.apk');
|
||||
final String apkPath = path.join(
|
||||
multipleFluttersPath,
|
||||
'android',
|
||||
'app',
|
||||
'build',
|
||||
'outputs',
|
||||
'apk',
|
||||
'release',
|
||||
'app-release.apk',
|
||||
);
|
||||
|
||||
TaskResult? result;
|
||||
await _withApkInstall(apkPath, _bundleName, (AndroidDevice device) async {
|
||||
@@ -83,20 +105,17 @@ Future<TaskResult> _doTest() async {
|
||||
'$_bundleName/$_bundleName.$_activityName',
|
||||
]);
|
||||
await Future<void>.delayed(const Duration(seconds: 10));
|
||||
final Map<String, dynamic> memoryStats =
|
||||
await device.getMemoryStats(_bundleName);
|
||||
final Map<String, dynamic> memoryStats = await device.getMemoryStats(_bundleName);
|
||||
final int totalMemory = memoryStats['total_kb'] as int;
|
||||
totalMemorySamples.add(totalMemory);
|
||||
await device.stop(_bundleName);
|
||||
}
|
||||
final ListStatistics totalMemoryStatistics =
|
||||
ListStatistics(totalMemorySamples);
|
||||
final ListStatistics totalMemoryStatistics = ListStatistics(totalMemorySamples);
|
||||
|
||||
final Map<String, dynamic> results = <String, dynamic>{
|
||||
...totalMemoryStatistics.asMap('totalMemory'),
|
||||
};
|
||||
result = TaskResult.success(results,
|
||||
benchmarkScoreKeys: results.keys.toList());
|
||||
result = TaskResult.success(results, benchmarkScoreKeys: results.keys.toList());
|
||||
});
|
||||
|
||||
return result ?? TaskResult.failure('no results found');
|
||||
|
||||
@@ -13,7 +13,12 @@ const String activityName = 'io.flutter.demo.gallery.MainActivity';
|
||||
/// Measure application memory usage after pausing and resuming the app
|
||||
/// with the Android back button.
|
||||
class BackButtonMemoryTest extends MemoryTest {
|
||||
BackButtonMemoryTest() : super('${flutterDirectory.path}/dev/integration_tests/flutter_gallery', 'test_memory/back_button.dart', packageName);
|
||||
BackButtonMemoryTest()
|
||||
: super(
|
||||
'${flutterDirectory.path}/dev/integration_tests/flutter_gallery',
|
||||
'test_memory/back_button.dart',
|
||||
packageName,
|
||||
);
|
||||
|
||||
@override
|
||||
AndroidDevice? get device => super.device as AndroidDevice?;
|
||||
@@ -39,7 +44,11 @@ class BackButtonMemoryTest extends MemoryTest {
|
||||
|
||||
// Relaunch the app, wait for it to launch.
|
||||
prepareForNextMessage('READY');
|
||||
final String output = await device!.shellEval('am', <String>['start', '-n', '$packageName/$activityName']);
|
||||
final String output = await device!.shellEval('am', <String>[
|
||||
'start',
|
||||
'-n',
|
||||
'$packageName/$activityName',
|
||||
]);
|
||||
print('adb shell am start: $output');
|
||||
if (output.contains('Error')) {
|
||||
fail('unable to launch activity');
|
||||
|
||||
@@ -7,9 +7,11 @@ import 'package:flutter_devicelab/framework/utils.dart';
|
||||
import 'package:flutter_devicelab/tasks/perf_tests.dart';
|
||||
|
||||
Future<void> main() async {
|
||||
await task(MemoryTest(
|
||||
'${flutterDirectory.path}/dev/integration_tests/flutter_gallery',
|
||||
'test_memory/image_cache_memory.dart',
|
||||
'io.flutter.demo.gallery',
|
||||
).run);
|
||||
await task(
|
||||
MemoryTest(
|
||||
'${flutterDirectory.path}/dev/integration_tests/flutter_gallery',
|
||||
'test_memory/image_cache_memory.dart',
|
||||
'io.flutter.demo.gallery',
|
||||
).run,
|
||||
);
|
||||
}
|
||||
|
||||
@@ -7,10 +7,12 @@ import 'package:flutter_devicelab/framework/utils.dart';
|
||||
import 'package:flutter_devicelab/tasks/perf_tests.dart';
|
||||
|
||||
Future<void> main() async {
|
||||
await task(MemoryTest(
|
||||
'${flutterDirectory.path}/dev/integration_tests/flutter_gallery',
|
||||
'test_memory/memory_nav.dart',
|
||||
'io.flutter.demo.gallery',
|
||||
requiresTapToStart: true,
|
||||
).run);
|
||||
await task(
|
||||
MemoryTest(
|
||||
'${flutterDirectory.path}/dev/integration_tests/flutter_gallery',
|
||||
'test_memory/memory_nav.dart',
|
||||
'io.flutter.demo.gallery',
|
||||
requiresTapToStart: true,
|
||||
).run,
|
||||
);
|
||||
}
|
||||
|
||||
@@ -12,8 +12,10 @@ Future<void> main() async {
|
||||
await task(() async {
|
||||
final TaskResult withoutSemantics = await createGalleryTransitionTest()();
|
||||
final TaskResult withSemantics = await createGalleryTransitionTest(semanticsEnabled: true)();
|
||||
final bool withSemanticsDataMissing = withSemantics.benchmarkScoreKeys == null || withSemantics.benchmarkScoreKeys!.isEmpty;
|
||||
final bool withoutSemanticsDataMissing = withoutSemantics.benchmarkScoreKeys == null || withoutSemantics.benchmarkScoreKeys!.isEmpty;
|
||||
final bool withSemanticsDataMissing =
|
||||
withSemantics.benchmarkScoreKeys == null || withSemantics.benchmarkScoreKeys!.isEmpty;
|
||||
final bool withoutSemanticsDataMissing =
|
||||
withoutSemantics.benchmarkScoreKeys == null || withoutSemantics.benchmarkScoreKeys!.isEmpty;
|
||||
if (withSemanticsDataMissing || withoutSemanticsDataMissing) {
|
||||
String message = 'Lack of data';
|
||||
if (withSemanticsDataMissing) {
|
||||
|
||||
@@ -32,75 +32,70 @@ class NewGalleryChromeRunTest {
|
||||
|
||||
/// Runs the test.
|
||||
Future<TaskResult> run() async {
|
||||
final TaskResult result = await inDirectory<TaskResult>('${flutterDirectory.path}/dev/integration_tests/new_gallery/', () async {
|
||||
await flutter('create', options: <String>[
|
||||
'--platforms',
|
||||
'web,android,ios',
|
||||
'--no-overwrite',
|
||||
'.'
|
||||
]);
|
||||
await flutter('doctor');
|
||||
await flutter('packages', options: <String>['get']);
|
||||
final TaskResult result = await inDirectory<TaskResult>(
|
||||
'${flutterDirectory.path}/dev/integration_tests/new_gallery/',
|
||||
() async {
|
||||
await flutter(
|
||||
'create',
|
||||
options: <String>['--platforms', 'web,android,ios', '--no-overwrite', '.'],
|
||||
);
|
||||
await flutter('doctor');
|
||||
await flutter('packages', options: <String>['get']);
|
||||
|
||||
await flutter('build', options: <String>[
|
||||
'web',
|
||||
'-v',
|
||||
'--release',
|
||||
'--no-pub',
|
||||
]);
|
||||
await flutter('build', options: <String>['web', '-v', '--release', '--no-pub']);
|
||||
|
||||
final List<String> options = <String>['-d', 'chrome', '--verbose', '--resident'];
|
||||
final Process process = await startFlutter(
|
||||
'run',
|
||||
options: options,
|
||||
);
|
||||
final List<String> options = <String>['-d', 'chrome', '--verbose', '--resident'];
|
||||
final Process process = await startFlutter('run', options: options);
|
||||
|
||||
final Completer<void> stdoutDone = Completer<void>();
|
||||
final Completer<void> stderrDone = Completer<void>();
|
||||
final Completer<void> stdoutDone = Completer<void>();
|
||||
final Completer<void> stderrDone = Completer<void>();
|
||||
|
||||
bool success = true;
|
||||
bool success = true;
|
||||
|
||||
process.stdout
|
||||
.transform<String>(utf8.decoder)
|
||||
.transform<String>(const LineSplitter())
|
||||
.listen((String line) {
|
||||
if (line.contains(successfullyLoadedString)) {
|
||||
// Successfully started.
|
||||
Future<void>.delayed(
|
||||
durationToWaitForError,
|
||||
() {process.stdin.write('q');}
|
||||
);
|
||||
process.stdout
|
||||
.transform<String>(utf8.decoder)
|
||||
.transform<String>(const LineSplitter())
|
||||
.listen(
|
||||
(String line) {
|
||||
if (line.contains(successfullyLoadedString)) {
|
||||
// Successfully started.
|
||||
Future<void>.delayed(durationToWaitForError, () {
|
||||
process.stdin.write('q');
|
||||
});
|
||||
}
|
||||
if (line.contains(exceptionString)) {
|
||||
success = false;
|
||||
}
|
||||
print('stdout: $line');
|
||||
},
|
||||
onDone: () {
|
||||
stdoutDone.complete();
|
||||
},
|
||||
);
|
||||
|
||||
process.stderr
|
||||
.transform<String>(utf8.decoder)
|
||||
.transform<String>(const LineSplitter())
|
||||
.listen(
|
||||
(String line) {
|
||||
print('stderr: $line');
|
||||
},
|
||||
onDone: () {
|
||||
stderrDone.complete();
|
||||
},
|
||||
);
|
||||
|
||||
await Future.wait<void>(<Future<void>>[stdoutDone.future, stderrDone.future]);
|
||||
|
||||
await process.exitCode;
|
||||
|
||||
if (success) {
|
||||
return TaskResult.success(<String, dynamic>{});
|
||||
} else {
|
||||
return TaskResult.failure('An exception was thrown.');
|
||||
}
|
||||
if (line.contains(exceptionString)) {
|
||||
success = false;
|
||||
}
|
||||
print('stdout: $line');
|
||||
}, onDone: () {
|
||||
stdoutDone.complete();
|
||||
});
|
||||
|
||||
process.stderr
|
||||
.transform<String>(utf8.decoder)
|
||||
.transform<String>(const LineSplitter())
|
||||
.listen((String line) {
|
||||
print('stderr: $line');
|
||||
}, onDone: () {
|
||||
stderrDone.complete();
|
||||
});
|
||||
|
||||
await Future.wait<void>(<Future<void>>[
|
||||
stdoutDone.future,
|
||||
stderrDone.future,
|
||||
]);
|
||||
|
||||
await process.exitCode;
|
||||
|
||||
if (success) {
|
||||
return TaskResult.success(<String, dynamic>{});
|
||||
} else {
|
||||
return TaskResult.failure('An exception was thrown.');
|
||||
}
|
||||
});
|
||||
},
|
||||
);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -25,12 +25,10 @@ class NewGalleryWebCompileTest {
|
||||
() async {
|
||||
await flutter('doctor');
|
||||
|
||||
await flutter('create', options: <String>[
|
||||
'--platforms',
|
||||
'web,android,ios',
|
||||
'--no-overwrite',
|
||||
'.'
|
||||
]);
|
||||
await flutter(
|
||||
'create',
|
||||
options: <String>['--platforms', 'web,android,ios', '--no-overwrite', '.'],
|
||||
);
|
||||
|
||||
return WebCompileTest.runSingleBuildTest(
|
||||
directory: '${flutterDirectory.path}/dev/integration_tests/new_gallery/',
|
||||
|
||||
@@ -50,14 +50,18 @@ Future<int> runTest({bool coverage = false, bool noPub = false}) async {
|
||||
int badLines = 0;
|
||||
TestStep step = TestStep.starting;
|
||||
|
||||
analysis.stdout.transform<String>(utf8.decoder).transform<String>(const LineSplitter()).listen((String entry) {
|
||||
analysis.stdout.transform<String>(utf8.decoder).transform<String>(const LineSplitter()).listen((
|
||||
String entry,
|
||||
) {
|
||||
print('test stdout ($step): $entry');
|
||||
if (step == TestStep.starting && entry == 'Building flutter tool...') {
|
||||
// ignore this line
|
||||
step = TestStep.buildingFlutterTool;
|
||||
} else if (step == TestStep.testPassed && entry.contains('Collecting coverage information...')) {
|
||||
} else if (step == TestStep.testPassed &&
|
||||
entry.contains('Collecting coverage information...')) {
|
||||
// ignore this line
|
||||
} else if (step.index < TestStep.runningPubGet.index && entry == 'Running "flutter pub get" in automated_tests...') {
|
||||
} else if (step.index < TestStep.runningPubGet.index &&
|
||||
entry == 'Running "flutter pub get" in automated_tests...') {
|
||||
// ignore this line
|
||||
step = TestStep.runningPubGet;
|
||||
} else if (step.index <= TestStep.testWritesFirstCarriageReturn.index && entry.trim() == '') {
|
||||
@@ -68,13 +72,17 @@ Future<int> runTest({bool coverage = false, bool noPub = false}) async {
|
||||
if (match == null) {
|
||||
badLines += 1;
|
||||
} else {
|
||||
if (step.index >= TestStep.testWritesFirstCarriageReturn.index && step.index <= TestStep.testLoading.index && match.group(1)!.startsWith('loading ')) {
|
||||
if (step.index >= TestStep.testWritesFirstCarriageReturn.index &&
|
||||
step.index <= TestStep.testLoading.index &&
|
||||
match.group(1)!.startsWith('loading ')) {
|
||||
// first the test loads
|
||||
step = TestStep.testLoading;
|
||||
} else if (step.index <= TestStep.testRunning.index && match.group(1) == 'A trivial widget test') {
|
||||
} else if (step.index <= TestStep.testRunning.index &&
|
||||
match.group(1) == 'A trivial widget test') {
|
||||
// then the test runs
|
||||
step = TestStep.testRunning;
|
||||
} else if (step.index < TestStep.testPassed.index && match.group(1) == 'All tests passed!') {
|
||||
} else if (step.index < TestStep.testPassed.index &&
|
||||
match.group(1) == 'All tests passed!') {
|
||||
// then the test finishes
|
||||
step = TestStep.testPassed;
|
||||
} else {
|
||||
@@ -83,7 +91,9 @@ Future<int> runTest({bool coverage = false, bool noPub = false}) async {
|
||||
}
|
||||
}
|
||||
});
|
||||
analysis.stderr.transform<String>(utf8.decoder).transform<String>(const LineSplitter()).listen((String entry) {
|
||||
analysis.stderr.transform<String>(utf8.decoder).transform<String>(const LineSplitter()).listen((
|
||||
String entry,
|
||||
) {
|
||||
print('test stderr: $entry');
|
||||
badLines += 1;
|
||||
});
|
||||
@@ -112,26 +122,43 @@ Future<void> pubGetDependencies(List<Directory> directories) async {
|
||||
|
||||
void main() {
|
||||
task(() async {
|
||||
final File nodeSourceFile = File(path.join(
|
||||
flutterDirectory.path, 'packages', 'flutter', 'lib', 'src', 'foundation', 'node.dart',
|
||||
));
|
||||
await pubGetDependencies(<Directory>[Directory(path.join(flutterDirectory.path, 'dev', 'automated_tests')),]);
|
||||
final File nodeSourceFile = File(
|
||||
path.join(
|
||||
flutterDirectory.path,
|
||||
'packages',
|
||||
'flutter',
|
||||
'lib',
|
||||
'src',
|
||||
'foundation',
|
||||
'node.dart',
|
||||
),
|
||||
);
|
||||
await pubGetDependencies(<Directory>[
|
||||
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
|
||||
await runTest(
|
||||
noPub: true,
|
||||
); // first number is meaningless; could have had to build the tool, run pub get, have a cache, etc
|
||||
final int withoutChange = await runTest(noPub: true); // run test again with no change
|
||||
await nodeSourceFile.writeAsString( // only change implementation
|
||||
originalSource
|
||||
.replaceAll('_owner', '_xyzzy')
|
||||
await nodeSourceFile.writeAsString(
|
||||
// only change implementation
|
||||
originalSource.replaceAll('_owner', '_xyzzy'),
|
||||
);
|
||||
final int implementationChange = await runTest(noPub: true); // run test again with implementation changed
|
||||
await nodeSourceFile.writeAsString( // change interface as well
|
||||
final int implementationChange = await runTest(
|
||||
noPub: true,
|
||||
); // run test again with implementation changed
|
||||
await nodeSourceFile.writeAsString(
|
||||
// change interface as well
|
||||
originalSource
|
||||
.replaceAll('_owner', '_xyzzy')
|
||||
.replaceAll('owner', '_owner')
|
||||
.replaceAll('_xyzzy', 'owner')
|
||||
.replaceAll('_owner', '_xyzzy')
|
||||
.replaceAll('owner', '_owner')
|
||||
.replaceAll('_xyzzy', 'owner'),
|
||||
);
|
||||
final int interfaceChange = await runTest(noPub: true); // run test again with interface changed
|
||||
final int interfaceChange = await runTest(
|
||||
noPub: true,
|
||||
); // run test again with interface changed
|
||||
// run test with coverage enabled.
|
||||
final int withCoverage = await runTest(coverage: true, noPub: true);
|
||||
final Map<String, dynamic> data = <String, dynamic>{
|
||||
|
||||
@@ -9,7 +9,6 @@ import 'package:flutter_devicelab/framework/framework.dart';
|
||||
import 'package:flutter_devicelab/framework/task_result.dart';
|
||||
import 'package:flutter_devicelab/framework/utils.dart';
|
||||
|
||||
|
||||
Future<void> main() async {
|
||||
await task(() async {
|
||||
try {
|
||||
@@ -19,12 +18,13 @@ Future<void> main() async {
|
||||
await flutterProject.addPlugin('google_maps_flutter:^2.2.1');
|
||||
|
||||
await inDirectory(flutterProject.rootPath, () async {
|
||||
await flutter('build', options: <String>[
|
||||
'apk',
|
||||
'--debug',
|
||||
'--target-platform=android-arm',
|
||||
]);
|
||||
final File apk = File('${flutterProject.rootPath}/build/app/outputs/flutter-apk/app-debug.apk');
|
||||
await flutter(
|
||||
'build',
|
||||
options: <String>['apk', '--debug', '--target-platform=android-arm'],
|
||||
);
|
||||
final File apk = File(
|
||||
'${flutterProject.rootPath}/build/app/outputs/flutter-apk/app-debug.apk',
|
||||
);
|
||||
if (!apk.existsSync()) {
|
||||
throw TaskResult.failure("Expected ${apk.path} to exist, but it doesn't");
|
||||
}
|
||||
|
||||
@@ -14,7 +14,6 @@ Future<void> main() async {
|
||||
await task(() async {
|
||||
try {
|
||||
await runPluginProjectTest((FlutterPluginProject pluginProject) async {
|
||||
|
||||
section('check main plugin file exists');
|
||||
final File pluginMainKotlinFile = File(
|
||||
path.join(
|
||||
@@ -23,17 +22,14 @@ Future<void> main() async {
|
||||
'src',
|
||||
'main',
|
||||
'kotlin',
|
||||
path.join(
|
||||
'com',
|
||||
'example',
|
||||
'aaa',
|
||||
'AaaPlugin.kt',
|
||||
),
|
||||
path.join('com', 'example', 'aaa', 'AaaPlugin.kt'),
|
||||
),
|
||||
);
|
||||
|
||||
if (!pluginMainKotlinFile.existsSync()) {
|
||||
throw TaskResult.failure("Expected ${pluginMainKotlinFile.path} to exist, but it doesn't");
|
||||
throw TaskResult.failure(
|
||||
"Expected ${pluginMainKotlinFile.path} to exist, but it doesn't",
|
||||
);
|
||||
}
|
||||
|
||||
section('add java 8 feature');
|
||||
@@ -87,14 +83,9 @@ class AaaPlugin: FlutterPlugin, MethodCallHandler {
|
||||
await inDirectory(pluginProject.exampleAndroidPath, () {
|
||||
return flutter(
|
||||
'build',
|
||||
options: <String>[
|
||||
'apk',
|
||||
'--debug',
|
||||
'--target-platform=android-arm',
|
||||
],
|
||||
options: <String>['apk', '--debug', '--target-platform=android-arm'],
|
||||
);
|
||||
});
|
||||
|
||||
});
|
||||
return TaskResult.success(null);
|
||||
} on TaskResult catch (taskResult) {
|
||||
|
||||
@@ -20,9 +20,7 @@ Future<void> main() async {
|
||||
section('App bundle content for task bundleRelease without explicit target platform');
|
||||
|
||||
await inDirectory(project.rootPath, () {
|
||||
return flutter('build', options: <String>[
|
||||
'appbundle',
|
||||
]);
|
||||
return flutter('build', options: <String>['appbundle']);
|
||||
});
|
||||
|
||||
final String releaseBundle = path.join(
|
||||
@@ -47,7 +45,7 @@ Future<void> main() async {
|
||||
await runProjectTest((FlutterProject project) async {
|
||||
section('App bundle content using flavors without explicit target platform');
|
||||
// Add a few flavors.
|
||||
await project.addProductFlavors(<String> [
|
||||
await project.addProductFlavors(<String>[
|
||||
'production',
|
||||
'staging',
|
||||
'development',
|
||||
@@ -55,11 +53,7 @@ Future<void> main() async {
|
||||
]);
|
||||
// Build the production flavor in release mode.
|
||||
await inDirectory(project.rootPath, () {
|
||||
return flutter('build', options: <String>[
|
||||
'appbundle',
|
||||
'--flavor',
|
||||
'production',
|
||||
]);
|
||||
return flutter('build', options: <String>['appbundle', '--flavor', 'production']);
|
||||
});
|
||||
|
||||
final String bundleFromGradlePath = path.join(
|
||||
@@ -82,14 +76,10 @@ Future<void> main() async {
|
||||
|
||||
section('Build app bundle using the flutter tool - flavor: flavor_underscore');
|
||||
|
||||
int exitCode = await inDirectory(project.rootPath, () {
|
||||
int exitCode = await inDirectory(project.rootPath, () {
|
||||
return flutter(
|
||||
'build',
|
||||
options: <String>[
|
||||
'appbundle',
|
||||
'--flavor=flavor_underscore',
|
||||
'--verbose',
|
||||
],
|
||||
options: <String>['appbundle', '--flavor=flavor_underscore', '--verbose'],
|
||||
);
|
||||
});
|
||||
|
||||
@@ -120,11 +110,7 @@ Future<void> main() async {
|
||||
exitCode = await inDirectory(project.rootPath, () {
|
||||
return flutter(
|
||||
'build',
|
||||
options: <String>[
|
||||
'appbundle',
|
||||
'--flavor=production',
|
||||
'--verbose',
|
||||
],
|
||||
options: <String>['appbundle', '--flavor=production', '--verbose'],
|
||||
);
|
||||
});
|
||||
|
||||
@@ -155,13 +141,7 @@ Future<void> main() async {
|
||||
section('App bundle content for task bundleRelease with target platform = android-arm');
|
||||
|
||||
await inDirectory(project.rootPath, () {
|
||||
return flutter(
|
||||
'build',
|
||||
options: <String>[
|
||||
'appbundle',
|
||||
'--target-platform=android-arm',
|
||||
],
|
||||
);
|
||||
return flutter('build', options: <String>['appbundle', '--target-platform=android-arm']);
|
||||
});
|
||||
|
||||
final String releaseBundle = path.join(
|
||||
|
||||
@@ -16,14 +16,7 @@ Future<void> main() async {
|
||||
await runPluginProjectTest((FlutterPluginProject pluginProject) async {
|
||||
section('APK content for task assembleDebug without explicit target platform');
|
||||
await inDirectory(pluginProject.exampleAndroidPath, () {
|
||||
return flutter(
|
||||
'build',
|
||||
options: <String>[
|
||||
'apk',
|
||||
'--debug',
|
||||
'--verbose',
|
||||
],
|
||||
);
|
||||
return flutter('build', options: <String>['apk', '--debug', '--verbose']);
|
||||
});
|
||||
|
||||
Iterable<String> apkFiles = await getFilesInApk(pluginProject.debugApkPath);
|
||||
@@ -49,14 +42,7 @@ Future<void> main() async {
|
||||
section('APK content for task assembleRelease without explicit target platform');
|
||||
|
||||
await inDirectory(pluginProject.exampleAndroidPath, () {
|
||||
return flutter(
|
||||
'build',
|
||||
options: <String>[
|
||||
'apk',
|
||||
'--release',
|
||||
'--verbose',
|
||||
],
|
||||
);
|
||||
return flutter('build', options: <String>['apk', '--release', '--verbose']);
|
||||
});
|
||||
|
||||
apkFiles = await getFilesInApk(pluginProject.releaseApkPath);
|
||||
@@ -74,7 +60,9 @@ Future<void> main() async {
|
||||
|
||||
checkCollectionDoesNotContain<String>(debugAssets, apkFiles);
|
||||
|
||||
section('APK content for task assembleRelease with target platform = android-arm, android-arm64');
|
||||
section(
|
||||
'APK content for task assembleRelease with target platform = android-arm, android-arm64',
|
||||
);
|
||||
|
||||
await inDirectory(pluginProject.exampleAndroidPath, () {
|
||||
return flutter(
|
||||
@@ -101,8 +89,10 @@ Future<void> main() async {
|
||||
|
||||
checkCollectionDoesNotContain<String>(debugAssets, apkFiles);
|
||||
|
||||
section('APK content for task assembleRelease with '
|
||||
'target platform = android-arm, android-arm64 and split per ABI');
|
||||
section(
|
||||
'APK content for task assembleRelease with '
|
||||
'target platform = android-arm, android-arm64 and split per ABI',
|
||||
);
|
||||
|
||||
await inDirectory(pluginProject.exampleAndroidPath, () {
|
||||
return flutter(
|
||||
@@ -128,7 +118,9 @@ Future<void> main() async {
|
||||
|
||||
checkCollectionDoesNotContain<String>(debugAssets, armApkFiles);
|
||||
|
||||
final Iterable<String> arm64ApkFiles = await getFilesInApk(pluginProject.releaseArm64ApkPath);
|
||||
final Iterable<String> arm64ApkFiles = await getFilesInApk(
|
||||
pluginProject.releaseArm64ApkPath,
|
||||
);
|
||||
|
||||
checkCollectionContains<String>(<String>[
|
||||
...flutterAssets,
|
||||
@@ -144,22 +136,12 @@ Future<void> main() async {
|
||||
section('gradlew assembleRelease');
|
||||
|
||||
await inDirectory(project.rootPath, () {
|
||||
return flutter(
|
||||
'build',
|
||||
options: <String>[
|
||||
'apk',
|
||||
'--release',
|
||||
'--verbose',
|
||||
],
|
||||
);
|
||||
return flutter('build', options: <String>['apk', '--release', '--verbose']);
|
||||
});
|
||||
|
||||
// When the platform-target isn't specified, we generate the snapshots
|
||||
// for arm and arm64.
|
||||
final List<String> targetPlatforms = <String>[
|
||||
'arm64-v8a',
|
||||
'armeabi-v7a',
|
||||
];
|
||||
final List<String> targetPlatforms = <String>['arm64-v8a', 'armeabi-v7a'];
|
||||
for (final String targetPlatform in targetPlatforms) {
|
||||
final String androidArmSnapshotPath = path.join(
|
||||
project.rootPath,
|
||||
|
||||
@@ -19,11 +19,7 @@ Future<void> main() async {
|
||||
await inDirectory(pluginProject.exampleAndroidPath, () {
|
||||
return flutter(
|
||||
'build',
|
||||
options: <String>[
|
||||
'apk',
|
||||
'--debug',
|
||||
'--target-platform=android-arm',
|
||||
],
|
||||
options: <String>['apk', '--debug', '--target-platform=android-arm'],
|
||||
);
|
||||
});
|
||||
|
||||
@@ -48,11 +44,7 @@ Future<void> main() async {
|
||||
await inDirectory(pluginProject.exampleAndroidPath, () {
|
||||
return flutter(
|
||||
'build',
|
||||
options: <String>[
|
||||
'apk',
|
||||
'--debug',
|
||||
'--target-platform=android-x86',
|
||||
],
|
||||
options: <String>['apk', '--debug', '--target-platform=android-x86'],
|
||||
);
|
||||
});
|
||||
|
||||
@@ -77,11 +69,7 @@ Future<void> main() async {
|
||||
await inDirectory(pluginProject.exampleAndroidPath, () {
|
||||
return flutter(
|
||||
'build',
|
||||
options: <String>[
|
||||
'apk',
|
||||
'--debug',
|
||||
'--target-platform=android-x64',
|
||||
],
|
||||
options: <String>['apk', '--debug', '--target-platform=android-x64'],
|
||||
);
|
||||
});
|
||||
|
||||
@@ -105,11 +93,7 @@ Future<void> main() async {
|
||||
await inDirectory(pluginProject.exampleAndroidPath, () {
|
||||
return flutter(
|
||||
'build',
|
||||
options: <String>[
|
||||
'apk',
|
||||
'--release',
|
||||
'--target-platform=android-arm',
|
||||
],
|
||||
options: <String>['apk', '--release', '--target-platform=android-arm'],
|
||||
);
|
||||
});
|
||||
|
||||
@@ -133,11 +117,7 @@ Future<void> main() async {
|
||||
await inDirectory(pluginProject.exampleAndroidPath, () {
|
||||
return flutter(
|
||||
'build',
|
||||
options: <String>[
|
||||
'apk',
|
||||
'--release',
|
||||
'--target-platform=android-arm64',
|
||||
],
|
||||
options: <String>['apk', '--release', '--target-platform=android-arm64'],
|
||||
);
|
||||
});
|
||||
|
||||
@@ -160,13 +140,7 @@ Future<void> main() async {
|
||||
await runProjectTest((FlutterProject project) async {
|
||||
section('gradlew assembleDebug');
|
||||
await inDirectory(project.rootPath, () {
|
||||
return flutter(
|
||||
'build',
|
||||
options: <String>[
|
||||
'apk',
|
||||
'--debug',
|
||||
],
|
||||
);
|
||||
return flutter('build', options: <String>['apk', '--debug']);
|
||||
});
|
||||
final String? errorMessage = validateSnapshotDependency(project, 'kernel_blob.bin');
|
||||
if (errorMessage != null) {
|
||||
@@ -175,13 +149,7 @@ Future<void> main() async {
|
||||
|
||||
section('gradlew assembleProfile');
|
||||
await inDirectory(project.rootPath, () {
|
||||
return flutter(
|
||||
'build',
|
||||
options: <String>[
|
||||
'apk',
|
||||
'--profile',
|
||||
],
|
||||
);
|
||||
return flutter('build', options: <String>['apk', '--profile']);
|
||||
});
|
||||
|
||||
section('gradlew assembleLocal (custom debug build)');
|
||||
@@ -244,59 +212,39 @@ Future<void> main() async {
|
||||
section('gradlew on build script with error');
|
||||
await project.introduceError();
|
||||
ProcessResult result = await inDirectory(project.rootPath, () {
|
||||
return executeFlutter(
|
||||
'build',
|
||||
options: <String>[
|
||||
'apk',
|
||||
'--release',
|
||||
],
|
||||
canFail: true,
|
||||
);
|
||||
return executeFlutter('build', options: <String>['apk', '--release'], canFail: true);
|
||||
});
|
||||
|
||||
if (result.exitCode == 0) {
|
||||
throw failure(
|
||||
'Gradle did not exit with error as expected', result);
|
||||
throw failure('Gradle did not exit with error as expected', result);
|
||||
}
|
||||
String output = '${result.stdout}\n${result.stderr}';
|
||||
if (output.contains('GradleException') ||
|
||||
output.contains('Failed to notify') ||
|
||||
output.contains('at org.gradle')) {
|
||||
throw failure(
|
||||
'Gradle output should not contain stacktrace', result);
|
||||
throw failure('Gradle output should not contain stacktrace', result);
|
||||
}
|
||||
if (!output.contains('Build failed')) {
|
||||
throw failure(
|
||||
'Gradle output should contain a readable error message',
|
||||
result);
|
||||
throw failure('Gradle output should contain a readable error message', result);
|
||||
}
|
||||
|
||||
section('flutter build apk on build script with error');
|
||||
await project.introduceError();
|
||||
result = await inDirectory(project.rootPath, () {
|
||||
return executeFlutter(
|
||||
'build',
|
||||
options: <String>[
|
||||
'apk',
|
||||
'--release',
|
||||
],
|
||||
canFail: true,
|
||||
);
|
||||
return executeFlutter('build', options: <String>['apk', '--release'], canFail: true);
|
||||
});
|
||||
if (result.exitCode == 0) {
|
||||
throw failure(
|
||||
'flutter build apk should fail when Gradle does', result);
|
||||
throw failure('flutter build apk should fail when Gradle does', result);
|
||||
}
|
||||
output = '${result.stdout}\n${result.stderr}';
|
||||
if (!output.contains('Build failed')) {
|
||||
throw failure(
|
||||
'flutter build apk output should contain a readable Gradle error message',
|
||||
result);
|
||||
'flutter build apk output should contain a readable Gradle error message',
|
||||
result,
|
||||
);
|
||||
}
|
||||
if (hasMultipleOccurrences(output, 'Build failed')) {
|
||||
throw failure(
|
||||
'flutter build apk should not invoke Gradle repeatedly on error',
|
||||
result);
|
||||
throw failure('flutter build apk should not invoke Gradle repeatedly on error', result);
|
||||
}
|
||||
});
|
||||
|
||||
@@ -304,21 +252,15 @@ Future<void> main() async {
|
||||
section('gradlew assembleDebug forwards stderr');
|
||||
await project.introducePubspecError();
|
||||
final ProcessResult result = await inDirectory(project.rootPath, () {
|
||||
return executeFlutter(
|
||||
'build',
|
||||
options: <String>[
|
||||
'apk',
|
||||
'--release',
|
||||
],
|
||||
canFail: true,
|
||||
);
|
||||
return executeFlutter('build', options: <String>['apk', '--release'], canFail: true);
|
||||
});
|
||||
if (result.exitCode == 0) {
|
||||
throw failure(
|
||||
'Gradle did not exit with error as expected', result);
|
||||
throw failure('Gradle did not exit with error as expected', result);
|
||||
}
|
||||
final String output = '${result.stdout}\n${result.stderr}';
|
||||
if (!output.contains('No file or variants found for asset: lib/gallery/example_code.dart.')) {
|
||||
if (!output.contains(
|
||||
'No file or variants found for asset: lib/gallery/example_code.dart.',
|
||||
)) {
|
||||
throw failure(output, result);
|
||||
}
|
||||
});
|
||||
|
||||
@@ -7,24 +7,22 @@ import 'package:flutter_devicelab/framework/utils.dart';
|
||||
import 'package:flutter_devicelab/tasks/perf_tests.dart';
|
||||
|
||||
class HelloWorldMemoryTest extends MemoryTest {
|
||||
HelloWorldMemoryTest() : super(
|
||||
'${flutterDirectory.path}/examples/hello_world',
|
||||
'lib/main.dart',
|
||||
'io.flutter.examples.hello_world',
|
||||
);
|
||||
HelloWorldMemoryTest()
|
||||
: super(
|
||||
'${flutterDirectory.path}/examples/hello_world',
|
||||
'lib/main.dart',
|
||||
'io.flutter.examples.hello_world',
|
||||
);
|
||||
|
||||
/// Launch an app with no instrumentation and measure its memory usage after
|
||||
/// 1.5s and 3.0s.
|
||||
@override
|
||||
Future<void> useMemory() async {
|
||||
print('launching $project$test on device...');
|
||||
await flutter('run', options: <String>[
|
||||
'--verbose',
|
||||
'--release',
|
||||
'--no-resident',
|
||||
'-d', device!.deviceId,
|
||||
test,
|
||||
]);
|
||||
await flutter(
|
||||
'run',
|
||||
options: <String>['--verbose', '--release', '--no-resident', '-d', device!.deviceId, test],
|
||||
);
|
||||
await Future<void>.delayed(const Duration(milliseconds: 1500));
|
||||
await recordStart();
|
||||
await Future<void>.delayed(const Duration(milliseconds: 3000));
|
||||
|
||||
@@ -17,8 +17,7 @@ Future<TaskResult> run() async {
|
||||
deviceOperatingSystem = DeviceOperatingSystem.android;
|
||||
final Device device = await devices.workingDevice;
|
||||
await device.unlock();
|
||||
final Directory appDir =
|
||||
dir(path.join(flutterDirectory.path, 'examples/hello_world'));
|
||||
final Directory appDir = dir(path.join(flutterDirectory.path, 'examples/hello_world'));
|
||||
|
||||
bool isUsingValidationLayers = false;
|
||||
bool hasValidationErrors = false;
|
||||
@@ -27,38 +26,32 @@ Future<TaskResult> run() async {
|
||||
|
||||
await inDirectory(appDir, () async {
|
||||
await flutter('packages', options: <String>['get']);
|
||||
const String validationLayersMessage = 'Using the Impeller rendering backend (Vulkan with Validation Layers)';
|
||||
final StreamSubscription<String> adb = device.logcat.listen(
|
||||
(String data) {
|
||||
if (data.contains('Using the Impeller rendering backend')) {
|
||||
// Sometimes more than one of these will be printed out if there is a
|
||||
// fallback.
|
||||
if (!data.contains(validationLayersMessage)) {
|
||||
invalidBackendCount += 1;
|
||||
}
|
||||
if (!didReceiveBackendMessage.isCompleted) {
|
||||
didReceiveBackendMessage.complete();
|
||||
}
|
||||
const String validationLayersMessage =
|
||||
'Using the Impeller rendering backend (Vulkan with Validation Layers)';
|
||||
final StreamSubscription<String> adb = device.logcat.listen((String data) {
|
||||
if (data.contains('Using the Impeller rendering backend')) {
|
||||
// Sometimes more than one of these will be printed out if there is a
|
||||
// fallback.
|
||||
if (!data.contains(validationLayersMessage)) {
|
||||
invalidBackendCount += 1;
|
||||
}
|
||||
if (data.contains(validationLayersMessage)) {
|
||||
isUsingValidationLayers = true;
|
||||
if (!didReceiveBackendMessage.isCompleted) {
|
||||
didReceiveBackendMessage.complete();
|
||||
}
|
||||
// "ImpellerValidationBreak" comes from the engine:
|
||||
// https://github.com/flutter/engine/blob/4160ebacdae2081d6f3160432f5f0dd87dbebec1/impeller/base/validation.cc#L40
|
||||
if (data.contains('ImpellerValidationBreak')) {
|
||||
hasValidationErrors = true;
|
||||
}
|
||||
},
|
||||
);
|
||||
}
|
||||
if (data.contains(validationLayersMessage)) {
|
||||
isUsingValidationLayers = true;
|
||||
}
|
||||
// "ImpellerValidationBreak" comes from the engine:
|
||||
// https://github.com/flutter/engine/blob/4160ebacdae2081d6f3160432f5f0dd87dbebec1/impeller/base/validation.cc#L40
|
||||
if (data.contains('ImpellerValidationBreak')) {
|
||||
hasValidationErrors = true;
|
||||
}
|
||||
});
|
||||
|
||||
final Process process = await startFlutter(
|
||||
'run',
|
||||
options: <String>[
|
||||
'--enable-impeller',
|
||||
'--enable-vulkan-validation',
|
||||
'-d',
|
||||
device.deviceId,
|
||||
],
|
||||
options: <String>['--enable-impeller', '--enable-vulkan-validation', '-d', device.deviceId],
|
||||
);
|
||||
|
||||
await didReceiveBackendMessage.future;
|
||||
@@ -72,7 +65,7 @@ Future<TaskResult> run() async {
|
||||
if (!isUsingValidationLayers || invalidBackendCount != 0) {
|
||||
return TaskResult.failure('Not using Vulkan validation layers.');
|
||||
}
|
||||
if (hasValidationErrors){
|
||||
if (hasValidationErrors) {
|
||||
return TaskResult.failure('Impeller validation errors detected.');
|
||||
}
|
||||
return TaskResult.success(null);
|
||||
|
||||
@@ -9,7 +9,5 @@ import 'package:flutter_devicelab/tasks/hot_mode_tests.dart';
|
||||
Future<void> main() async {
|
||||
// TODO(vashworth): Remove once https://github.com/flutter/flutter/issues/142305 is fixed.
|
||||
deviceOperatingSystem = DeviceOperatingSystem.ios;
|
||||
await task(createHotModeTest(
|
||||
additionalOptions: <String>['--no-dds'],
|
||||
));
|
||||
await task(createHotModeTest(additionalOptions: <String>['--no-dds']));
|
||||
}
|
||||
|
||||
@@ -7,11 +7,13 @@ import 'package:flutter_devicelab/framework/utils.dart';
|
||||
import 'package:flutter_devicelab/tasks/perf_tests.dart';
|
||||
|
||||
Future<void> main() async {
|
||||
await task(ReportedDurationTest(
|
||||
ReportedDurationTestFlavor.debug,
|
||||
'${flutterDirectory.path}/examples/image_list',
|
||||
'lib/main.dart',
|
||||
'com.example.image_list',
|
||||
RegExp(r'===image_list=== all loaded in ([\d]+)ms.'),
|
||||
).run);
|
||||
await task(
|
||||
ReportedDurationTest(
|
||||
ReportedDurationTestFlavor.debug,
|
||||
'${flutterDirectory.path}/examples/image_list',
|
||||
'lib/main.dart',
|
||||
'com.example.image_list',
|
||||
RegExp(r'===image_list=== all loaded in ([\d]+)ms.'),
|
||||
).run,
|
||||
);
|
||||
}
|
||||
|
||||
@@ -7,11 +7,13 @@ import 'package:flutter_devicelab/framework/utils.dart';
|
||||
import 'package:flutter_devicelab/tasks/perf_tests.dart';
|
||||
|
||||
Future<void> main() async {
|
||||
await task(ReportedDurationTest(
|
||||
ReportedDurationTestFlavor.release,
|
||||
'${flutterDirectory.path}/examples/image_list',
|
||||
'lib/main.dart',
|
||||
'com.example.image_list',
|
||||
RegExp(r'===image_list=== all loaded in ([\d]+)ms.'),
|
||||
).run);
|
||||
await task(
|
||||
ReportedDurationTest(
|
||||
ReportedDurationTestFlavor.release,
|
||||
'${flutterDirectory.path}/examples/image_list',
|
||||
'lib/main.dart',
|
||||
'com.example.image_list',
|
||||
RegExp(r'===image_list=== all loaded in ([\d]+)ms.'),
|
||||
).run,
|
||||
);
|
||||
}
|
||||
|
||||
@@ -13,15 +13,16 @@ Future<void> main() async {
|
||||
await task(() async {
|
||||
section('Copy test Flutter App with watchOS Companion');
|
||||
|
||||
final Directory tempDir = Directory.systemTemp
|
||||
.createTempSync('flutter_ios_app_with_extensions_test.');
|
||||
final Directory projectDir =
|
||||
Directory(path.join(tempDir.path, 'app_with_extensions'));
|
||||
final Directory tempDir = Directory.systemTemp.createTempSync(
|
||||
'flutter_ios_app_with_extensions_test.',
|
||||
);
|
||||
final Directory projectDir = Directory(path.join(tempDir.path, 'app_with_extensions'));
|
||||
try {
|
||||
mkdir(projectDir);
|
||||
recursiveCopy(
|
||||
Directory(path.join(flutterDirectory.path, 'dev', 'integration_tests',
|
||||
'ios_app_with_extensions')),
|
||||
Directory(
|
||||
path.join(flutterDirectory.path, 'dev', 'integration_tests', 'ios_app_with_extensions'),
|
||||
),
|
||||
projectDir,
|
||||
);
|
||||
|
||||
|
||||
@@ -9,8 +9,10 @@ import 'package:flutter_devicelab/tasks/perf_tests.dart';
|
||||
|
||||
Future<void> main() async {
|
||||
deviceOperatingSystem = DeviceOperatingSystem.android;
|
||||
await task(DevToolsMemoryTest(
|
||||
'${flutterDirectory.path}/dev/benchmarks/macrobenchmarks',
|
||||
'test_driver/large_image_changer.dart',
|
||||
).run);
|
||||
await task(
|
||||
DevToolsMemoryTest(
|
||||
'${flutterDirectory.path}/dev/benchmarks/macrobenchmarks',
|
||||
'test_driver/large_image_changer.dart',
|
||||
).run,
|
||||
);
|
||||
}
|
||||
|
||||
@@ -9,20 +9,22 @@ import 'package:flutter_devicelab/tasks/perf_tests.dart';
|
||||
|
||||
Future<void> main() async {
|
||||
deviceOperatingSystem = DeviceOperatingSystem.ios;
|
||||
await task(PerfTest(
|
||||
'${flutterDirectory.path}/dev/benchmarks/macrobenchmarks',
|
||||
'test_driver/large_image_changer.dart',
|
||||
'large_image_changer',
|
||||
// This benchmark doesn't care about frame times, frame times will be heavily
|
||||
// impacted by IO time for loading the image initially.
|
||||
benchmarkScoreKeys: <String>[
|
||||
'average_cpu_usage',
|
||||
'average_gpu_usage',
|
||||
'average_memory_usage',
|
||||
'90th_percentile_memory_usage',
|
||||
'99th_percentile_memory_usage',
|
||||
'new_gen_gc_count',
|
||||
'old_gen_gc_count',
|
||||
],
|
||||
).run);
|
||||
await task(
|
||||
PerfTest(
|
||||
'${flutterDirectory.path}/dev/benchmarks/macrobenchmarks',
|
||||
'test_driver/large_image_changer.dart',
|
||||
'large_image_changer',
|
||||
// This benchmark doesn't care about frame times, frame times will be heavily
|
||||
// impacted by IO time for loading the image initially.
|
||||
benchmarkScoreKeys: <String>[
|
||||
'average_cpu_usage',
|
||||
'average_gpu_usage',
|
||||
'average_memory_usage',
|
||||
'90th_percentile_memory_usage',
|
||||
'99th_percentile_memory_usage',
|
||||
'new_gen_gc_count',
|
||||
'old_gen_gc_count',
|
||||
],
|
||||
).run,
|
||||
);
|
||||
}
|
||||
|
||||
@@ -18,7 +18,6 @@ final String fileReadWriteMode = Platform.isWindows ? 'rw-rw-rw-' : 'rw-r--r--';
|
||||
/// adding Flutter to an existing Android app.
|
||||
Future<void> main() async {
|
||||
await task(() async {
|
||||
|
||||
section('Find Java');
|
||||
|
||||
final String? javaHome = await findJavaHome();
|
||||
@@ -41,22 +40,16 @@ Future<void> main() async {
|
||||
|
||||
section('Add read-only asset');
|
||||
|
||||
final File readonlyTxtAssetFile = await File(path.join(
|
||||
projectDir.path,
|
||||
'assets',
|
||||
'read-only.txt'
|
||||
))
|
||||
.create(recursive: true);
|
||||
final File readonlyTxtAssetFile = await File(
|
||||
path.join(projectDir.path, 'assets', 'read-only.txt'),
|
||||
).create(recursive: true);
|
||||
|
||||
if (!exists(readonlyTxtAssetFile)) {
|
||||
return TaskResult.failure('Failed to create read-only asset');
|
||||
}
|
||||
|
||||
if (!Platform.isWindows) {
|
||||
await exec('chmod', <String>[
|
||||
'444',
|
||||
readonlyTxtAssetFile.path,
|
||||
]);
|
||||
await exec('chmod', <String>['444', readonlyTxtAssetFile.path]);
|
||||
}
|
||||
|
||||
final File pubspec = File(path.join(projectDir.path, 'pubspec.yaml'));
|
||||
@@ -76,10 +69,7 @@ Future<void> main() async {
|
||||
);
|
||||
await pubspec.writeAsString(content, flush: true);
|
||||
await inDirectory(projectDir, () async {
|
||||
await flutter(
|
||||
'packages',
|
||||
options: <String>['get'],
|
||||
);
|
||||
await flutter('packages', options: <String>['get']);
|
||||
});
|
||||
|
||||
section('Build Flutter module library archive');
|
||||
@@ -88,19 +78,23 @@ Future<void> main() async {
|
||||
await exec(
|
||||
gradlewExecutable,
|
||||
<String>['flutter:assembleDebug'],
|
||||
environment: <String, String>{ 'JAVA_HOME': javaHome },
|
||||
environment: <String, String>{'JAVA_HOME': javaHome},
|
||||
);
|
||||
});
|
||||
|
||||
final bool aarBuilt = exists(File(path.join(
|
||||
projectDir.path,
|
||||
'.android',
|
||||
'Flutter',
|
||||
'build',
|
||||
'outputs',
|
||||
'aar',
|
||||
'flutter-debug.aar',
|
||||
)));
|
||||
final bool aarBuilt = exists(
|
||||
File(
|
||||
path.join(
|
||||
projectDir.path,
|
||||
'.android',
|
||||
'Flutter',
|
||||
'build',
|
||||
'outputs',
|
||||
'aar',
|
||||
'flutter-debug.aar',
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
if (!aarBuilt) {
|
||||
return TaskResult.failure('Failed to build .aar');
|
||||
@@ -109,21 +103,22 @@ Future<void> main() async {
|
||||
section('Build ephemeral host app');
|
||||
|
||||
await inDirectory(projectDir, () async {
|
||||
await flutter(
|
||||
'build',
|
||||
options: <String>['apk'],
|
||||
);
|
||||
await flutter('build', options: <String>['apk']);
|
||||
});
|
||||
|
||||
final bool ephemeralHostApkBuilt = exists(File(path.join(
|
||||
projectDir.path,
|
||||
'build',
|
||||
'host',
|
||||
'outputs',
|
||||
'apk',
|
||||
'release',
|
||||
'app-release.apk',
|
||||
)));
|
||||
final bool ephemeralHostApkBuilt = exists(
|
||||
File(
|
||||
path.join(
|
||||
projectDir.path,
|
||||
'build',
|
||||
'host',
|
||||
'outputs',
|
||||
'apk',
|
||||
'release',
|
||||
'app-release.apk',
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
if (!ephemeralHostApkBuilt) {
|
||||
return TaskResult.failure('Failed to build ephemeral host .apk');
|
||||
@@ -138,30 +133,28 @@ Future<void> main() async {
|
||||
section('Make Android host app editable');
|
||||
|
||||
await inDirectory(projectDir, () async {
|
||||
await flutter(
|
||||
'make-host-app-editable',
|
||||
options: <String>['android'],
|
||||
);
|
||||
await flutter('make-host-app-editable', options: <String>['android']);
|
||||
});
|
||||
|
||||
section('Build editable host app');
|
||||
|
||||
await inDirectory(projectDir, () async {
|
||||
await flutter(
|
||||
'build',
|
||||
options: <String>['apk'],
|
||||
);
|
||||
await flutter('build', options: <String>['apk']);
|
||||
});
|
||||
|
||||
final bool editableHostApkBuilt = exists(File(path.join(
|
||||
projectDir.path,
|
||||
'build',
|
||||
'host',
|
||||
'outputs',
|
||||
'apk',
|
||||
'release',
|
||||
'app-release.apk',
|
||||
)));
|
||||
final bool editableHostApkBuilt = exists(
|
||||
File(
|
||||
path.join(
|
||||
projectDir.path,
|
||||
'build',
|
||||
'host',
|
||||
'outputs',
|
||||
'apk',
|
||||
'release',
|
||||
'app-release.apk',
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
if (!editableHostApkBuilt) {
|
||||
return TaskResult.failure('Failed to build editable host .apk');
|
||||
@@ -183,10 +176,7 @@ Future<void> main() async {
|
||||
),
|
||||
hostApp,
|
||||
);
|
||||
copy(
|
||||
File(path.join(projectDir.path, '.android', gradlew)),
|
||||
hostApp,
|
||||
);
|
||||
copy(File(path.join(projectDir.path, '.android', gradlew)), hostApp);
|
||||
copy(
|
||||
File(path.join(projectDir.path, '.android', 'gradle', 'wrapper', 'gradle-wrapper.jar')),
|
||||
Directory(path.join(hostApp.path, 'gradle', 'wrapper')),
|
||||
@@ -198,7 +188,8 @@ Future<void> main() async {
|
||||
if (!Platform.isWindows) {
|
||||
await exec('chmod', <String>['+x', 'gradlew']);
|
||||
}
|
||||
await exec(gradlewExecutable,
|
||||
await exec(
|
||||
gradlewExecutable,
|
||||
<String>['SampleApp:assembleDebug'],
|
||||
environment: <String, String>{
|
||||
'JAVA_HOME': javaHome,
|
||||
@@ -236,9 +227,10 @@ Future<void> main() async {
|
||||
if (!androidManifestDebug.contains('''
|
||||
<meta-data
|
||||
android:name="flutterProjectType"
|
||||
android:value="module" />''')
|
||||
) {
|
||||
return TaskResult.failure("Debug host APK doesn't contain metadata: flutterProjectType = module ");
|
||||
android:value="module" />''')) {
|
||||
return TaskResult.failure(
|
||||
"Debug host APK doesn't contain metadata: flutterProjectType = module ",
|
||||
);
|
||||
}
|
||||
|
||||
section('Check file access modes for read-only asset from Flutter module');
|
||||
@@ -268,7 +260,8 @@ Future<void> main() async {
|
||||
section('Build release host APK');
|
||||
|
||||
await inDirectory(hostApp, () async {
|
||||
await exec(gradlewExecutable,
|
||||
await exec(
|
||||
gradlewExecutable,
|
||||
<String>['SampleApp:assembleRelease'],
|
||||
environment: <String, String>{
|
||||
'JAVA_HOME': javaHome,
|
||||
@@ -307,9 +300,10 @@ Future<void> main() async {
|
||||
if (!androidManifestRelease.contains('''
|
||||
<meta-data
|
||||
android:name="flutterProjectType"
|
||||
android:value="module" />''')
|
||||
) {
|
||||
return TaskResult.failure("Release host APK doesn't contain metadata: flutterProjectType = module ");
|
||||
android:value="module" />''')) {
|
||||
return TaskResult.failure(
|
||||
"Release host APK doesn't contain metadata: flutterProjectType = module ",
|
||||
);
|
||||
}
|
||||
|
||||
section('Check file access modes for read-only asset from Flutter module');
|
||||
|
||||
@@ -17,7 +17,6 @@ final String gradlewExecutable = Platform.isWindows ? '.\\$gradlew' : './$gradle
|
||||
/// it has custom build types and flavors.
|
||||
Future<void> main() async {
|
||||
await task(() async {
|
||||
|
||||
section('Find Java');
|
||||
|
||||
final String? javaHome = await findJavaHome();
|
||||
@@ -29,10 +28,7 @@ Future<void> main() async {
|
||||
|
||||
section('Create Flutter module project');
|
||||
|
||||
await flutter(
|
||||
'precache',
|
||||
options: <String>['--android', '--no-ios'],
|
||||
);
|
||||
await flutter('precache', options: <String>['--android', '--no-ios']);
|
||||
|
||||
final Directory tempDir = Directory.systemTemp.createTempSync('flutter_module_test.');
|
||||
final Directory projectDir = Directory(path.join(tempDir.path, 'hello'));
|
||||
@@ -47,15 +43,14 @@ Future<void> main() async {
|
||||
section('Run flutter pub get');
|
||||
|
||||
await inDirectory(projectDir, () async {
|
||||
await flutter(
|
||||
'pub',
|
||||
options: <String>['get'],
|
||||
);
|
||||
await flutter('pub', options: <String>['get']);
|
||||
});
|
||||
|
||||
section('Add to existing Android app');
|
||||
|
||||
final Directory hostAppDir = Directory(path.join(tempDir.path, 'hello_host_app_with_custom_build'));
|
||||
final Directory hostAppDir = Directory(
|
||||
path.join(tempDir.path, 'hello_host_app_with_custom_build'),
|
||||
);
|
||||
mkdir(hostAppDir);
|
||||
recursiveCopy(
|
||||
Directory(
|
||||
@@ -68,10 +63,7 @@ Future<void> main() async {
|
||||
),
|
||||
hostAppDir,
|
||||
);
|
||||
copy(
|
||||
File(path.join(projectDir.path, '.android', gradlew)),
|
||||
hostAppDir,
|
||||
);
|
||||
copy(File(path.join(projectDir.path, '.android', gradlew)), hostAppDir);
|
||||
copy(
|
||||
File(path.join(projectDir.path, '.android', 'gradle', 'wrapper', 'gradle-wrapper.jar')),
|
||||
Directory(path.join(hostAppDir.path, 'gradle', 'wrapper')),
|
||||
@@ -80,11 +72,10 @@ Future<void> main() async {
|
||||
Future<void> clean() async {
|
||||
section('Clean');
|
||||
await inDirectory(hostAppDir, () async {
|
||||
await exec(gradlewExecutable,
|
||||
await exec(
|
||||
gradlewExecutable,
|
||||
<String>['clean'],
|
||||
environment: <String, String>{
|
||||
'JAVA_HOME': javaHome,
|
||||
},
|
||||
environment: <String, String>{'JAVA_HOME': javaHome},
|
||||
);
|
||||
});
|
||||
}
|
||||
@@ -101,11 +92,10 @@ Future<void> main() async {
|
||||
section('Run app:assembleDemoDebug');
|
||||
|
||||
await inDirectory(hostAppDir, () async {
|
||||
await exec(gradlewExecutable,
|
||||
await exec(
|
||||
gradlewExecutable,
|
||||
<String>['app:assembleDemoDebug'],
|
||||
environment: <String, String>{
|
||||
'JAVA_HOME': javaHome,
|
||||
},
|
||||
environment: <String, String>{'JAVA_HOME': javaHome},
|
||||
);
|
||||
});
|
||||
|
||||
@@ -138,7 +128,8 @@ Future<void> main() async {
|
||||
section('Run app:assembleDemoDebug - Merge assets before processing manifest');
|
||||
|
||||
await inDirectory(hostAppDir, () async {
|
||||
await exec(gradlewExecutable,
|
||||
await exec(
|
||||
gradlewExecutable,
|
||||
<String>[
|
||||
// Normally, `app:processDemoDebugManifest` runs before `app:mergeDemoDebugAssets`.
|
||||
// In this case, we run `app:mergeDemoDebugAssets` first.
|
||||
@@ -146,9 +137,7 @@ Future<void> main() async {
|
||||
'app:processDemoDebugManifest',
|
||||
'app:assembleDemoDebug',
|
||||
],
|
||||
environment: <String, String>{
|
||||
'JAVA_HOME': javaHome,
|
||||
},
|
||||
environment: <String, String>{'JAVA_HOME': javaHome},
|
||||
);
|
||||
});
|
||||
|
||||
@@ -179,11 +168,10 @@ Future<void> main() async {
|
||||
section('Run app:assembleDemoStaging');
|
||||
|
||||
await inDirectory(hostAppDir, () async {
|
||||
await exec(gradlewExecutable,
|
||||
await exec(
|
||||
gradlewExecutable,
|
||||
<String>['app:assembleDemoStaging'],
|
||||
environment: <String, String>{
|
||||
'JAVA_HOME': javaHome,
|
||||
},
|
||||
environment: <String, String>{'JAVA_HOME': javaHome},
|
||||
);
|
||||
});
|
||||
|
||||
@@ -216,11 +204,10 @@ Future<void> main() async {
|
||||
section('Run app:assembleDemoRelease');
|
||||
|
||||
await inDirectory(hostAppDir, () async {
|
||||
await exec(gradlewExecutable,
|
||||
await exec(
|
||||
gradlewExecutable,
|
||||
<String>['app:assembleDemoRelease'],
|
||||
environment: <String, String>{
|
||||
'JAVA_HOME': javaHome,
|
||||
},
|
||||
environment: <String, String>{'JAVA_HOME': javaHome},
|
||||
);
|
||||
});
|
||||
|
||||
@@ -253,12 +240,11 @@ Future<void> main() async {
|
||||
|
||||
section('Run app:assembleDemoProd');
|
||||
|
||||
await inDirectory(hostAppDir, () async {
|
||||
await exec(gradlewExecutable,
|
||||
await inDirectory(hostAppDir, () async {
|
||||
await exec(
|
||||
gradlewExecutable,
|
||||
<String>['app:assembleDemoProd'],
|
||||
environment: <String, String>{
|
||||
'JAVA_HOME': javaHome,
|
||||
},
|
||||
environment: <String, String>{'JAVA_HOME': javaHome},
|
||||
);
|
||||
});
|
||||
|
||||
|
||||
@@ -22,9 +22,7 @@ Future<void> main() async {
|
||||
await eval(
|
||||
'pod',
|
||||
<String>['repo', 'update'],
|
||||
environment: <String, String>{
|
||||
'LANG': 'en_US.UTF-8',
|
||||
},
|
||||
environment: <String, String>{'LANG': 'en_US.UTF-8'},
|
||||
);
|
||||
|
||||
// This variable cannot be `late`, as we reference it in the `finally` block
|
||||
@@ -38,17 +36,21 @@ Future<void> main() async {
|
||||
await inDirectory(tempDir, () async {
|
||||
await flutter(
|
||||
'create',
|
||||
options: <String>[
|
||||
'--org',
|
||||
'io.flutter.devicelab',
|
||||
'--template=module',
|
||||
'hello',
|
||||
],
|
||||
options: <String>['--org', 'io.flutter.devicelab', '--template=module', 'hello'],
|
||||
);
|
||||
});
|
||||
|
||||
// Copy test dart files to new module app.
|
||||
final Directory flutterModuleLibSource = Directory(path.join(flutterDirectory.path, 'dev', 'integration_tests', 'ios_host_app', 'flutterapp', 'lib'));
|
||||
final Directory flutterModuleLibSource = Directory(
|
||||
path.join(
|
||||
flutterDirectory.path,
|
||||
'dev',
|
||||
'integration_tests',
|
||||
'ios_host_app',
|
||||
'flutterapp',
|
||||
'lib',
|
||||
),
|
||||
);
|
||||
final Directory flutterModuleLibDestination = Directory(path.join(projectDir.path, 'lib'));
|
||||
|
||||
// These test files don't have a .dart extension so the analyzer will ignore them. They aren't in a
|
||||
@@ -61,10 +63,7 @@ Future<void> main() async {
|
||||
|
||||
section('Create package with native assets');
|
||||
|
||||
await flutter(
|
||||
'config',
|
||||
options: <String>['--enable-native-assets'],
|
||||
);
|
||||
await flutter('config', options: <String>['--enable-native-assets']);
|
||||
|
||||
const String ffiPackageName = 'ffi_package';
|
||||
await createFfiPackage(ffiPackageName, tempDir);
|
||||
@@ -73,41 +72,30 @@ Future<void> main() async {
|
||||
|
||||
final File pubspec = File(path.join(projectDir.path, 'pubspec.yaml'));
|
||||
String content = await pubspec.readAsString();
|
||||
content = content.replaceFirst(
|
||||
'dependencies:\n',
|
||||
'''
|
||||
content = content.replaceFirst('dependencies:\n', '''
|
||||
dependencies:
|
||||
$ffiPackageName:
|
||||
path: ../$ffiPackageName
|
||||
''',
|
||||
);
|
||||
''');
|
||||
await pubspec.writeAsString(content, flush: true);
|
||||
await inDirectory(projectDir, () async {
|
||||
await flutter(
|
||||
'packages',
|
||||
options: <String>['get'],
|
||||
);
|
||||
await flutter('packages', options: <String>['get']);
|
||||
});
|
||||
|
||||
section('Build ephemeral host app in release mode without CocoaPods');
|
||||
|
||||
await inDirectory(projectDir, () async {
|
||||
await flutter(
|
||||
'build',
|
||||
options: <String>['ios', '--no-codesign', '--verbose'],
|
||||
);
|
||||
await flutter('build', options: <String>['ios', '--no-codesign', '--verbose']);
|
||||
});
|
||||
|
||||
// Check the tool is no longer copying to the legacy xcframework location.
|
||||
checkDirectoryNotExists(path.join(projectDir.path, '.ios', 'Flutter', 'engine', 'Flutter.xcframework'));
|
||||
checkDirectoryNotExists(
|
||||
path.join(projectDir.path, '.ios', 'Flutter', 'engine', 'Flutter.xcframework'),
|
||||
);
|
||||
|
||||
final Directory ephemeralIOSHostApp = Directory(path.join(
|
||||
projectDir.path,
|
||||
'build',
|
||||
'ios',
|
||||
'iphoneos',
|
||||
'Runner.app',
|
||||
));
|
||||
final Directory ephemeralIOSHostApp = Directory(
|
||||
path.join(projectDir.path, 'build', 'ios', 'iphoneos', 'Runner.app'),
|
||||
);
|
||||
|
||||
if (!exists(ephemeralIOSHostApp)) {
|
||||
return TaskResult.failure('Failed to build ephemeral host .app');
|
||||
@@ -115,17 +103,14 @@ dependencies:
|
||||
|
||||
if (!await _isAppAotBuild(ephemeralIOSHostApp)) {
|
||||
return TaskResult.failure(
|
||||
'Ephemeral host app ${ephemeralIOSHostApp.path} was not a release build as expected'
|
||||
'Ephemeral host app ${ephemeralIOSHostApp.path} was not a release build as expected',
|
||||
);
|
||||
}
|
||||
|
||||
section('Build ephemeral host app in profile mode without CocoaPods');
|
||||
|
||||
await inDirectory(projectDir, () async {
|
||||
await flutter(
|
||||
'build',
|
||||
options: <String>['ios', '--no-codesign', '--profile'],
|
||||
);
|
||||
await flutter('build', options: <String>['ios', '--no-codesign', '--profile']);
|
||||
});
|
||||
|
||||
if (!exists(ephemeralIOSHostApp)) {
|
||||
@@ -134,7 +119,7 @@ dependencies:
|
||||
|
||||
if (!await _isAppAotBuild(ephemeralIOSHostApp)) {
|
||||
return TaskResult.failure(
|
||||
'Ephemeral host app ${ephemeralIOSHostApp.path} was not a profile build as expected'
|
||||
'Ephemeral host app ${ephemeralIOSHostApp.path} was not a profile build as expected',
|
||||
);
|
||||
}
|
||||
|
||||
@@ -147,34 +132,33 @@ dependencies:
|
||||
section('Build ephemeral host app in debug mode for simulator without CocoaPods');
|
||||
|
||||
await inDirectory(projectDir, () async {
|
||||
await flutter(
|
||||
'build',
|
||||
options: <String>['ios', '--no-codesign', '--simulator', '--debug'],
|
||||
);
|
||||
await flutter('build', options: <String>['ios', '--no-codesign', '--simulator', '--debug']);
|
||||
});
|
||||
|
||||
final Directory ephemeralSimulatorHostApp = Directory(path.join(
|
||||
projectDir.path,
|
||||
'build',
|
||||
'ios',
|
||||
'iphonesimulator',
|
||||
'Runner.app',
|
||||
));
|
||||
final Directory ephemeralSimulatorHostApp = Directory(
|
||||
path.join(projectDir.path, 'build', 'ios', 'iphonesimulator', 'Runner.app'),
|
||||
);
|
||||
|
||||
if (!exists(ephemeralSimulatorHostApp)) {
|
||||
return TaskResult.failure('Failed to build ephemeral host .app');
|
||||
}
|
||||
checkFileExists(path.join(ephemeralSimulatorHostApp.path, 'Frameworks', 'Flutter.framework', 'Flutter'));
|
||||
checkFileExists(
|
||||
path.join(ephemeralSimulatorHostApp.path, 'Frameworks', 'Flutter.framework', 'Flutter'),
|
||||
);
|
||||
|
||||
if (!exists(File(path.join(
|
||||
ephemeralSimulatorHostApp.path,
|
||||
'Frameworks',
|
||||
'App.framework',
|
||||
'flutter_assets',
|
||||
'isolate_snapshot_data',
|
||||
)))) {
|
||||
if (!exists(
|
||||
File(
|
||||
path.join(
|
||||
ephemeralSimulatorHostApp.path,
|
||||
'Frameworks',
|
||||
'App.framework',
|
||||
'flutter_assets',
|
||||
'isolate_snapshot_data',
|
||||
),
|
||||
),
|
||||
)) {
|
||||
return TaskResult.failure(
|
||||
'Ephemeral host app ${ephemeralSimulatorHostApp.path} was not a debug build as expected'
|
||||
'Ephemeral host app ${ephemeralSimulatorHostApp.path} was not a debug build as expected',
|
||||
);
|
||||
}
|
||||
|
||||
@@ -206,19 +190,13 @@ dependencies:
|
||||
);
|
||||
await pubspec.writeAsString(content, flush: true);
|
||||
await inDirectory(projectDir, () async {
|
||||
await flutter(
|
||||
'packages',
|
||||
options: <String>['get'],
|
||||
);
|
||||
await flutter('packages', options: <String>['get']);
|
||||
});
|
||||
|
||||
section('Build ephemeral host app with CocoaPods');
|
||||
|
||||
await inDirectory(projectDir, () async {
|
||||
await flutter(
|
||||
'build',
|
||||
options: <String>['ios', '--no-codesign', '-v'],
|
||||
);
|
||||
await flutter('build', options: <String>['ios', '--no-codesign', '-v']);
|
||||
});
|
||||
|
||||
final bool ephemeralHostAppWithCocoaPodsBuilt = exists(ephemeralIOSHostApp);
|
||||
@@ -229,28 +207,57 @@ dependencies:
|
||||
|
||||
final File podfileLockFile = File(path.join(projectDir.path, '.ios', 'Podfile.lock'));
|
||||
final String podfileLockOutput = podfileLockFile.readAsStringSync();
|
||||
if (!podfileLockOutput.contains(':path: Flutter')
|
||||
|| !podfileLockOutput.contains(':path: Flutter/FlutterPluginRegistrant')
|
||||
|| !podfileLockOutput.contains(':path: ".symlinks/plugins/url_launcher_ios/ios"')
|
||||
|| podfileLockOutput.contains('android_alarm_manager')
|
||||
|| podfileLockOutput.contains(dartPluginName)) {
|
||||
if (!podfileLockOutput.contains(':path: Flutter') ||
|
||||
!podfileLockOutput.contains(':path: Flutter/FlutterPluginRegistrant') ||
|
||||
!podfileLockOutput.contains(':path: ".symlinks/plugins/url_launcher_ios/ios"') ||
|
||||
podfileLockOutput.contains('android_alarm_manager') ||
|
||||
podfileLockOutput.contains(dartPluginName)) {
|
||||
print(podfileLockOutput);
|
||||
return TaskResult.failure('Building ephemeral host app Podfile.lock does not contain expected pods');
|
||||
return TaskResult.failure(
|
||||
'Building ephemeral host app Podfile.lock does not contain expected pods',
|
||||
);
|
||||
}
|
||||
|
||||
checkFileExists(path.join(ephemeralIOSHostApp.path, 'Frameworks', 'url_launcher_ios.framework', 'url_launcher_ios'));
|
||||
checkFileExists(
|
||||
path.join(
|
||||
ephemeralIOSHostApp.path,
|
||||
'Frameworks',
|
||||
'url_launcher_ios.framework',
|
||||
'url_launcher_ios',
|
||||
),
|
||||
);
|
||||
// Resources should be embedded.
|
||||
checkDirectoryExists(path.join(ephemeralIOSHostApp.path, 'Frameworks', 'GoogleSignIn.framework', 'GoogleSignIn.bundle'));
|
||||
checkFileExists(path.join(ephemeralIOSHostApp.path, 'Frameworks', 'Flutter.framework', 'Flutter'));
|
||||
checkDirectoryExists(
|
||||
path.join(
|
||||
ephemeralIOSHostApp.path,
|
||||
'Frameworks',
|
||||
'GoogleSignIn.framework',
|
||||
'GoogleSignIn.bundle',
|
||||
),
|
||||
);
|
||||
checkFileExists(
|
||||
path.join(ephemeralIOSHostApp.path, 'Frameworks', 'Flutter.framework', 'Flutter'),
|
||||
);
|
||||
|
||||
// Android-only, no embedded framework.
|
||||
checkDirectoryNotExists(path.join(ephemeralIOSHostApp.path, 'Frameworks', 'android_alarm_manager.framework'));
|
||||
checkDirectoryNotExists(
|
||||
path.join(ephemeralIOSHostApp.path, 'Frameworks', 'android_alarm_manager.framework'),
|
||||
);
|
||||
|
||||
// Dart-only, no embedded framework.
|
||||
checkDirectoryNotExists(path.join(ephemeralIOSHostApp.path, 'Frameworks', '$dartPluginName.framework'));
|
||||
checkDirectoryNotExists(
|
||||
path.join(ephemeralIOSHostApp.path, 'Frameworks', '$dartPluginName.framework'),
|
||||
);
|
||||
|
||||
// Native assets embedded, no embedded framework.
|
||||
checkFileExists(path.join(ephemeralIOSHostApp.path, 'Frameworks', '$ffiPackageName.framework', ffiPackageName));
|
||||
checkFileExists(
|
||||
path.join(
|
||||
ephemeralIOSHostApp.path,
|
||||
'Frameworks',
|
||||
'$ffiPackageName.framework',
|
||||
ffiPackageName,
|
||||
),
|
||||
);
|
||||
|
||||
section('Clean and pub get module');
|
||||
|
||||
@@ -281,16 +288,20 @@ dependencies:
|
||||
final String podFailure = await eval(
|
||||
'pod',
|
||||
<String>['install'],
|
||||
environment: <String, String>{
|
||||
'LANG': 'en_US.UTF-8',
|
||||
},
|
||||
environment: <String, String>{'LANG': 'en_US.UTF-8'},
|
||||
canFail: true,
|
||||
);
|
||||
|
||||
if (!podFailure.contains('Missing `flutter_post_install(installer)` in Podfile `post_install` block')
|
||||
|| !podFailure.contains('Add `flutter_post_install(installer)` to your Podfile `post_install` block to build Flutter plugins')) {
|
||||
if (!podFailure.contains(
|
||||
'Missing `flutter_post_install(installer)` in Podfile `post_install` block',
|
||||
) ||
|
||||
!podFailure.contains(
|
||||
'Add `flutter_post_install(installer)` to your Podfile `post_install` block to build Flutter plugins',
|
||||
)) {
|
||||
print(podfileContent);
|
||||
throw TaskResult.failure('pod install unexpectedly succeed without "flutter_post_install" post_install block');
|
||||
throw TaskResult.failure(
|
||||
'pod install unexpectedly succeed without "flutter_post_install" post_install block',
|
||||
);
|
||||
}
|
||||
podfileContent = '''
|
||||
$podfileContent
|
||||
@@ -304,54 +315,65 @@ end
|
||||
await exec(
|
||||
'pod',
|
||||
<String>['install'],
|
||||
environment: <String, String>{
|
||||
'LANG': 'en_US.UTF-8',
|
||||
},
|
||||
environment: <String, String>{'LANG': 'en_US.UTF-8'},
|
||||
);
|
||||
|
||||
File hostPodfileLockFile = File(path.join(objectiveCHostApp.path, 'Podfile.lock'));
|
||||
String hostPodfileLockOutput = hostPodfileLockFile.readAsStringSync();
|
||||
if (!hostPodfileLockOutput.contains(':path: "../hello/.ios/Flutter"')
|
||||
|| !hostPodfileLockOutput.contains(':path: "../hello/.ios/Flutter/FlutterPluginRegistrant"')
|
||||
|| !hostPodfileLockOutput.contains(':path: "../hello/.ios/.symlinks/plugins/url_launcher_ios/ios"')
|
||||
|| hostPodfileLockOutput.contains('android_alarm_manager')
|
||||
|| hostPodfileLockOutput.contains(dartPluginName)) {
|
||||
if (!hostPodfileLockOutput.contains(':path: "../hello/.ios/Flutter"') ||
|
||||
!hostPodfileLockOutput.contains(
|
||||
':path: "../hello/.ios/Flutter/FlutterPluginRegistrant"',
|
||||
) ||
|
||||
!hostPodfileLockOutput.contains(
|
||||
':path: "../hello/.ios/.symlinks/plugins/url_launcher_ios/ios"',
|
||||
) ||
|
||||
hostPodfileLockOutput.contains('android_alarm_manager') ||
|
||||
hostPodfileLockOutput.contains(dartPluginName)) {
|
||||
print(hostPodfileLockOutput);
|
||||
throw TaskResult.failure('Building host app Podfile.lock does not contain expected pods');
|
||||
}
|
||||
|
||||
section('Validate install_flutter_[engine_pod|plugin_pods|application_pod] methods in the Podfile can be executed normally');
|
||||
section(
|
||||
'Validate install_flutter_[engine_pod|plugin_pods|application_pod] methods in the Podfile can be executed normally',
|
||||
);
|
||||
|
||||
podfileContent = podfileContent.replaceFirst('''
|
||||
podfileContent = podfileContent.replaceFirst(
|
||||
'''
|
||||
install_all_flutter_pods flutter_application_path
|
||||
''', '''
|
||||
''',
|
||||
'''
|
||||
install_flutter_engine_pod(flutter_application_path)
|
||||
install_flutter_plugin_pods(flutter_application_path)
|
||||
install_flutter_application_pod(flutter_application_path)
|
||||
''');
|
||||
''',
|
||||
);
|
||||
await podfile.writeAsString(podfileContent, flush: true);
|
||||
|
||||
await exec(
|
||||
'pod',
|
||||
<String>['install'],
|
||||
environment: <String, String>{
|
||||
'LANG': 'en_US.UTF-8',
|
||||
},
|
||||
environment: <String, String>{'LANG': 'en_US.UTF-8'},
|
||||
);
|
||||
|
||||
hostPodfileLockFile = File(path.join(objectiveCHostApp.path, 'Podfile.lock'));
|
||||
hostPodfileLockOutput = hostPodfileLockFile.readAsStringSync();
|
||||
if (!hostPodfileLockOutput.contains(':path: "../hello/.ios/Flutter"')
|
||||
|| !hostPodfileLockOutput.contains(':path: "../hello/.ios/Flutter/FlutterPluginRegistrant"')
|
||||
|| !hostPodfileLockOutput.contains(':path: "../hello/.ios/.symlinks/plugins/url_launcher_ios/ios"')
|
||||
|| hostPodfileLockOutput.contains('android_alarm_manager')
|
||||
|| hostPodfileLockOutput.contains(dartPluginName)) {
|
||||
if (!hostPodfileLockOutput.contains(':path: "../hello/.ios/Flutter"') ||
|
||||
!hostPodfileLockOutput.contains(
|
||||
':path: "../hello/.ios/Flutter/FlutterPluginRegistrant"',
|
||||
) ||
|
||||
!hostPodfileLockOutput.contains(
|
||||
':path: "../hello/.ios/.symlinks/plugins/url_launcher_ios/ios"',
|
||||
) ||
|
||||
hostPodfileLockOutput.contains('android_alarm_manager') ||
|
||||
hostPodfileLockOutput.contains(dartPluginName)) {
|
||||
print(hostPodfileLockOutput);
|
||||
throw TaskResult.failure('Building host app Podfile.lock does not contain expected pods');
|
||||
}
|
||||
|
||||
// Check the tool is no longer copying to the legacy App.framework location.
|
||||
final File dummyAppFramework = File(path.join(projectDir.path, '.ios', 'Flutter', 'App.framework', 'App'));
|
||||
final File dummyAppFramework = File(
|
||||
path.join(projectDir.path, '.ios', 'Flutter', 'App.framework', 'App'),
|
||||
);
|
||||
checkFileNotExists(dummyAppFramework.path);
|
||||
|
||||
section('Build iOS Objective-C host app');
|
||||
@@ -372,9 +394,7 @@ end
|
||||
'BUILD_DIR=${objectiveCBuildDirectory.path}',
|
||||
'COMPILER_INDEX_STORE_ENABLE=NO',
|
||||
],
|
||||
environment: <String, String> {
|
||||
'FLUTTER_SUPPRESS_ANALYTICS': 'true',
|
||||
},
|
||||
environment: <String, String>{'FLUTTER_SUPPRESS_ANALYTICS': 'true'},
|
||||
);
|
||||
});
|
||||
|
||||
@@ -384,37 +404,27 @@ end
|
||||
'Host.app',
|
||||
);
|
||||
|
||||
final bool existingAppBuilt = exists(File(path.join(
|
||||
hostAppDirectory,
|
||||
'Host',
|
||||
)));
|
||||
final bool existingAppBuilt = exists(File(path.join(hostAppDirectory, 'Host')));
|
||||
if (!existingAppBuilt) {
|
||||
return TaskResult.failure('Failed to build existing Objective-C app .app');
|
||||
}
|
||||
|
||||
final String hostFrameworksDirectory = path.join(
|
||||
hostAppDirectory,
|
||||
'Frameworks',
|
||||
final String hostFrameworksDirectory = path.join(hostAppDirectory, 'Frameworks');
|
||||
|
||||
checkFileExists(path.join(hostFrameworksDirectory, 'Flutter.framework', 'Flutter'));
|
||||
|
||||
checkFileExists(
|
||||
path.join(
|
||||
hostFrameworksDirectory,
|
||||
'App.framework',
|
||||
'flutter_assets',
|
||||
'isolate_snapshot_data',
|
||||
),
|
||||
);
|
||||
|
||||
checkFileExists(path.join(
|
||||
hostFrameworksDirectory,
|
||||
'Flutter.framework',
|
||||
'Flutter',
|
||||
));
|
||||
|
||||
checkFileExists(path.join(
|
||||
hostFrameworksDirectory,
|
||||
'App.framework',
|
||||
'flutter_assets',
|
||||
'isolate_snapshot_data',
|
||||
));
|
||||
|
||||
checkFileExists(path.join(
|
||||
hostFrameworksDirectory,
|
||||
'$ffiPackageName.framework',
|
||||
ffiPackageName,
|
||||
));
|
||||
checkFileExists(
|
||||
path.join(hostFrameworksDirectory, '$ffiPackageName.framework', ffiPackageName),
|
||||
);
|
||||
|
||||
section('Check the NOTICE file is correct');
|
||||
|
||||
@@ -437,7 +447,9 @@ end
|
||||
section('Archive iOS Objective-C host app');
|
||||
|
||||
await inDirectory(objectiveCHostApp, () async {
|
||||
final Directory objectiveCBuildArchiveDirectory = Directory(path.join(tempDir.path, 'build-objc-archive'));
|
||||
final Directory objectiveCBuildArchiveDirectory = Directory(
|
||||
path.join(tempDir.path, 'build-objc-archive'),
|
||||
);
|
||||
await exec(
|
||||
'xcodebuild',
|
||||
<String>[
|
||||
@@ -456,9 +468,7 @@ end
|
||||
'COMPILER_INDEX_STORE_ENABLE=NO',
|
||||
'archive',
|
||||
],
|
||||
environment: <String, String> {
|
||||
'FLUTTER_SUPPRESS_ANALYTICS': 'true',
|
||||
},
|
||||
environment: <String, String>{'FLUTTER_SUPPRESS_ANALYTICS': 'true'},
|
||||
);
|
||||
|
||||
final String archivedAppPath = path.join(
|
||||
@@ -468,18 +478,17 @@ end
|
||||
'Host.app',
|
||||
);
|
||||
|
||||
checkFileExists(path.join(
|
||||
archivedAppPath,
|
||||
'Host',
|
||||
));
|
||||
checkFileExists(path.join(archivedAppPath, 'Host'));
|
||||
|
||||
checkFileNotExists(path.join(
|
||||
archivedAppPath,
|
||||
'Frameworks',
|
||||
'App.framework',
|
||||
'flutter_assets',
|
||||
'isolate_snapshot_data',
|
||||
));
|
||||
checkFileNotExists(
|
||||
path.join(
|
||||
archivedAppPath,
|
||||
'Frameworks',
|
||||
'App.framework',
|
||||
'flutter_assets',
|
||||
'isolate_snapshot_data',
|
||||
),
|
||||
);
|
||||
|
||||
final String builtFlutterBinary = path.join(
|
||||
archivedAppPath,
|
||||
@@ -504,35 +513,33 @@ end
|
||||
}
|
||||
|
||||
// Check native assets are bundled.
|
||||
checkFileExists(path.join(
|
||||
archivedAppPath,
|
||||
'Frameworks',
|
||||
'$ffiPackageName.framework',
|
||||
ffiPackageName,
|
||||
));
|
||||
checkFileExists(
|
||||
path.join(archivedAppPath, 'Frameworks', '$ffiPackageName.framework', ffiPackageName),
|
||||
);
|
||||
|
||||
// The host app example builds plugins statically, url_launcher_ios.framework
|
||||
// should not exist.
|
||||
checkDirectoryNotExists(path.join(
|
||||
archivedAppPath,
|
||||
'Frameworks',
|
||||
'url_launcher_ios.framework',
|
||||
));
|
||||
checkDirectoryNotExists(
|
||||
path.join(archivedAppPath, 'Frameworks', 'url_launcher_ios.framework'),
|
||||
);
|
||||
|
||||
checkFileExists(path.join(
|
||||
'${objectiveCBuildArchiveDirectory.path}.xcarchive',
|
||||
'dSYMs',
|
||||
'App.framework.dSYM',
|
||||
'Contents',
|
||||
'Resources',
|
||||
'DWARF',
|
||||
'App'
|
||||
));
|
||||
checkFileExists(
|
||||
path.join(
|
||||
'${objectiveCBuildArchiveDirectory.path}.xcarchive',
|
||||
'dSYMs',
|
||||
'App.framework.dSYM',
|
||||
'Contents',
|
||||
'Resources',
|
||||
'DWARF',
|
||||
'App',
|
||||
),
|
||||
);
|
||||
});
|
||||
|
||||
section('Run platform unit tests');
|
||||
|
||||
final String resultBundleTemp = Directory.systemTemp.createTempSync('flutter_module_test_ios_xcresult.').path;
|
||||
final String resultBundleTemp =
|
||||
Directory.systemTemp.createTempSync('flutter_module_test_ios_xcresult.').path;
|
||||
await testWithNewIOSSimulator('TestAdd2AppSim', (String deviceId) async {
|
||||
simulatorDeviceId = deviceId;
|
||||
final String resultBundlePath = path.join(resultBundleTemp, 'result');
|
||||
@@ -562,17 +569,13 @@ end
|
||||
if (dumpDirectory != null) {
|
||||
// Zip the test results to the artifacts directory for upload.
|
||||
await inDirectory(resultBundleTemp, () {
|
||||
final String zipPath = path.join(dumpDirectory.path,
|
||||
'module_test_ios-objc-${DateTime.now().toLocal().toIso8601String()}.zip');
|
||||
final String zipPath = path.join(
|
||||
dumpDirectory.path,
|
||||
'module_test_ios-objc-${DateTime.now().toLocal().toIso8601String()}.zip',
|
||||
);
|
||||
return exec(
|
||||
'zip',
|
||||
<String>[
|
||||
'-r',
|
||||
'-9',
|
||||
'-q',
|
||||
zipPath,
|
||||
'result.xcresult',
|
||||
],
|
||||
<String>['-r', '-9', '-q', zipPath, 'result.xcresult'],
|
||||
canFail: true, // Best effort to get the logs.
|
||||
);
|
||||
});
|
||||
@@ -583,31 +586,34 @@ end
|
||||
});
|
||||
|
||||
section('Fail building existing Objective-C iOS app if flutter script fails');
|
||||
final String xcodebuildOutput = await inDirectory<String>(objectiveCHostApp, () =>
|
||||
eval(
|
||||
'xcodebuild',
|
||||
<String>[
|
||||
'-workspace',
|
||||
'Host.xcworkspace',
|
||||
'-scheme',
|
||||
'Host',
|
||||
'-configuration',
|
||||
'Debug',
|
||||
'FLUTTER_ENGINE=bogus', // Force a Flutter error.
|
||||
'CODE_SIGNING_ALLOWED=NO',
|
||||
'CODE_SIGNING_REQUIRED=NO',
|
||||
'CODE_SIGN_IDENTITY=-',
|
||||
'EXPANDED_CODE_SIGN_IDENTITY=-',
|
||||
'BUILD_DIR=${objectiveCBuildDirectory.path}',
|
||||
'COMPILER_INDEX_STORE_ENABLE=NO',
|
||||
],
|
||||
canFail: true,
|
||||
)
|
||||
final String xcodebuildOutput = await inDirectory<String>(
|
||||
objectiveCHostApp,
|
||||
() => eval('xcodebuild', <String>[
|
||||
'-workspace',
|
||||
'Host.xcworkspace',
|
||||
'-scheme',
|
||||
'Host',
|
||||
'-configuration',
|
||||
'Debug',
|
||||
'FLUTTER_ENGINE=bogus', // Force a Flutter error.
|
||||
'CODE_SIGNING_ALLOWED=NO',
|
||||
'CODE_SIGNING_REQUIRED=NO',
|
||||
'CODE_SIGN_IDENTITY=-',
|
||||
'EXPANDED_CODE_SIGN_IDENTITY=-',
|
||||
'BUILD_DIR=${objectiveCBuildDirectory.path}',
|
||||
'COMPILER_INDEX_STORE_ENABLE=NO',
|
||||
], canFail: true),
|
||||
);
|
||||
|
||||
if (!xcodebuildOutput.contains('flutter --verbose --local-engine-src-path=bogus assemble') || // Verbose output
|
||||
!xcodebuildOutput.contains('Unable to detect a Flutter engine build directory in bogus')) {
|
||||
return TaskResult.failure('Host Objective-C app build succeeded though flutter script failed');
|
||||
if (!xcodebuildOutput.contains(
|
||||
'flutter --verbose --local-engine-src-path=bogus assemble',
|
||||
) || // Verbose output
|
||||
!xcodebuildOutput.contains(
|
||||
'Unable to detect a Flutter engine build directory in bogus',
|
||||
)) {
|
||||
return TaskResult.failure(
|
||||
'Host Objective-C app build succeeded though flutter script failed',
|
||||
);
|
||||
}
|
||||
|
||||
section('Add to existing iOS Swift app');
|
||||
@@ -615,7 +621,9 @@ end
|
||||
final Directory swiftHostApp = Directory(path.join(tempDir.path, 'hello_host_app_swift'));
|
||||
mkdir(swiftHostApp);
|
||||
recursiveCopy(
|
||||
Directory(path.join(flutterDirectory.path, 'dev', 'integration_tests', 'ios_host_app_swift')),
|
||||
Directory(
|
||||
path.join(flutterDirectory.path, 'dev', 'integration_tests', 'ios_host_app_swift'),
|
||||
),
|
||||
swiftHostApp,
|
||||
);
|
||||
|
||||
@@ -626,9 +634,7 @@ end
|
||||
await exec(
|
||||
'pod',
|
||||
<String>['install'],
|
||||
environment: <String, String>{
|
||||
'LANG': 'en_US.UTF-8',
|
||||
},
|
||||
environment: <String, String>{'LANG': 'en_US.UTF-8'},
|
||||
);
|
||||
await exec(
|
||||
'xcodebuild',
|
||||
@@ -646,29 +652,26 @@ end
|
||||
'BUILD_DIR=${swiftBuildDirectory.path}',
|
||||
'COMPILER_INDEX_STORE_ENABLE=NO',
|
||||
],
|
||||
environment: <String, String> {
|
||||
environment: <String, String>{
|
||||
'FLUTTER_ANALYTICS_LOG_FILE': swiftAnalyticsOutputFile.path,
|
||||
},
|
||||
);
|
||||
});
|
||||
|
||||
final bool existingSwiftAppBuilt = exists(File(path.join(
|
||||
swiftBuildDirectory.path,
|
||||
'Debug-iphoneos',
|
||||
'Host.app',
|
||||
'Host',
|
||||
)));
|
||||
final bool existingSwiftAppBuilt = exists(
|
||||
File(path.join(swiftBuildDirectory.path, 'Debug-iphoneos', 'Host.app', 'Host')),
|
||||
);
|
||||
if (!existingSwiftAppBuilt) {
|
||||
return TaskResult.failure('Failed to build existing Swift app .app');
|
||||
}
|
||||
|
||||
final String swiftAnalyticsOutput = swiftAnalyticsOutputFile.readAsStringSync();
|
||||
if (!swiftAnalyticsOutput.contains('cd24: ios')
|
||||
|| !swiftAnalyticsOutput.contains('cd25: true')
|
||||
|| !swiftAnalyticsOutput.contains('viewName: assemble')) {
|
||||
if (!swiftAnalyticsOutput.contains('cd24: ios') ||
|
||||
!swiftAnalyticsOutput.contains('cd25: true') ||
|
||||
!swiftAnalyticsOutput.contains('viewName: assemble')) {
|
||||
return TaskResult.failure(
|
||||
'Building outer Swift app produced the following analytics: "$swiftAnalyticsOutput" '
|
||||
'but not the expected strings: "cd24: ios", "cd25: true", "viewName: assemble"'
|
||||
'but not the expected strings: "cd24: ios", "cd25: true", "viewName: assemble"',
|
||||
);
|
||||
}
|
||||
|
||||
@@ -683,12 +686,7 @@ end
|
||||
}
|
||||
|
||||
Future<bool> _isAppAotBuild(Directory app) async {
|
||||
final String binary = path.join(
|
||||
app.path,
|
||||
'Frameworks',
|
||||
'App.framework',
|
||||
'App',
|
||||
);
|
||||
final String binary = path.join(app.path, 'Frameworks', 'App.framework', 'App');
|
||||
|
||||
final String symbolTable = await dumpSymbolTable(binary);
|
||||
|
||||
|
||||
@@ -14,16 +14,10 @@ Future<void> main() async {
|
||||
String? simulatorDeviceId;
|
||||
TaskResult res = TaskResult.success(null);
|
||||
try {
|
||||
await testWithNewIOSSimulator(
|
||||
'TestNativeAssetsSim',
|
||||
(String deviceId) async {
|
||||
simulatorDeviceId = deviceId;
|
||||
res = await createNativeAssetsTest(
|
||||
deviceIdOverride: deviceId,
|
||||
isIosSimulator: true,
|
||||
)();
|
||||
},
|
||||
);
|
||||
await testWithNewIOSSimulator('TestNativeAssetsSim', (String deviceId) async {
|
||||
simulatorDeviceId = deviceId;
|
||||
res = await createNativeAssetsTest(deviceIdOverride: deviceId, isIosSimulator: true)();
|
||||
});
|
||||
} finally {
|
||||
await removeIOSSimulator(simulatorDeviceId);
|
||||
}
|
||||
|
||||
@@ -12,19 +12,14 @@ import 'package:path/path.dart' as path;
|
||||
Future<void> main() async {
|
||||
deviceOperatingSystem = DeviceOperatingSystem.ios;
|
||||
await task(() async {
|
||||
final String projectDirectory = '${flutterDirectory.path}/dev/integration_tests/ios_platform_view_tests';
|
||||
final String projectDirectory =
|
||||
'${flutterDirectory.path}/dev/integration_tests/ios_platform_view_tests';
|
||||
|
||||
await inDirectory(projectDirectory, () async {
|
||||
|
||||
// To address "Failed to terminate" failure.
|
||||
section('Uninstall previously installed app');
|
||||
|
||||
await flutter(
|
||||
'install',
|
||||
options: <String>[
|
||||
'--uninstall-only',
|
||||
],
|
||||
);
|
||||
await flutter('install', options: <String>['--uninstall-only']);
|
||||
|
||||
section('Build clean');
|
||||
|
||||
@@ -32,15 +27,7 @@ Future<void> main() async {
|
||||
|
||||
section('Build platform view app');
|
||||
|
||||
await flutter(
|
||||
'build',
|
||||
options: <String>[
|
||||
'ios',
|
||||
'-v',
|
||||
'--release',
|
||||
'--config-only',
|
||||
],
|
||||
);
|
||||
await flutter('build', options: <String>['ios', '-v', '--release', '--config-only']);
|
||||
});
|
||||
|
||||
section('Run platform view XCUITests');
|
||||
|
||||
@@ -10,19 +10,13 @@ import 'package:path/path.dart' as path;
|
||||
|
||||
Future<void> main() async {
|
||||
await task(() async {
|
||||
final String projectDirectory = '${flutterDirectory.path}/dev/integration_tests/flutter_gallery';
|
||||
final String projectDirectory =
|
||||
'${flutterDirectory.path}/dev/integration_tests/flutter_gallery';
|
||||
|
||||
await inDirectory(projectDirectory, () async {
|
||||
section('Build gallery app');
|
||||
|
||||
await flutter(
|
||||
'build',
|
||||
options: <String>[
|
||||
'macos',
|
||||
'-v',
|
||||
'--debug',
|
||||
],
|
||||
);
|
||||
await flutter('build', options: <String>['macos', '-v', '--debug']);
|
||||
});
|
||||
|
||||
section('Run platform unit tests');
|
||||
|
||||
@@ -10,9 +10,6 @@ Future<void> main() async {
|
||||
deviceOperatingSystem = DeviceOperatingSystem.android;
|
||||
|
||||
await task(
|
||||
NewGalleryPerfTest(
|
||||
timelineFileName: 'transitions-crane',
|
||||
dartDefine: 'onlyCrane=true',
|
||||
).run,
|
||||
NewGalleryPerfTest(timelineFileName: 'transitions-crane', dartDefine: 'onlyCrane=true').run,
|
||||
);
|
||||
}
|
||||
|
||||
@@ -9,5 +9,10 @@ import 'package:flutter_devicelab/tasks/new_gallery.dart';
|
||||
Future<void> main() async {
|
||||
deviceOperatingSystem = DeviceOperatingSystem.android;
|
||||
|
||||
await task(NewGalleryPerfTest(enableImpeller: true, dartDefine: 'flutter.benchmarks.force_disable_snapshot=true').run);
|
||||
await task(
|
||||
NewGalleryPerfTest(
|
||||
enableImpeller: true,
|
||||
dartDefine: 'flutter.benchmarks.force_disable_snapshot=true',
|
||||
).run,
|
||||
);
|
||||
}
|
||||
|
||||
@@ -9,9 +9,11 @@ import 'package:flutter_devicelab/tasks/perf_tests.dart';
|
||||
|
||||
void main() async {
|
||||
deviceOperatingSystem = DeviceOperatingSystem.android;
|
||||
await task(PerfTest(
|
||||
'${flutterDirectory.path}/dev/integration_tests/flutter_gallery',
|
||||
'test_driver/page_transitions_perf.dart',
|
||||
'page_transition_perf',
|
||||
).run);
|
||||
await task(
|
||||
PerfTest(
|
||||
'${flutterDirectory.path}/dev/integration_tests/flutter_gallery',
|
||||
'test_driver/page_transitions_perf.dart',
|
||||
'page_transition_perf',
|
||||
).run,
|
||||
);
|
||||
}
|
||||
|
||||
@@ -4,9 +4,9 @@
|
||||
|
||||
import 'package:flutter_devicelab/framework/devices.dart' show DeviceOperatingSystem;
|
||||
import 'package:flutter_devicelab/framework/framework.dart' show task;
|
||||
import 'package:flutter_devicelab/tasks/platform_channels_benchmarks.dart' as platform_channels_benchmarks;
|
||||
import 'package:flutter_devicelab/tasks/platform_channels_benchmarks.dart'
|
||||
as platform_channels_benchmarks;
|
||||
|
||||
Future<void> main() async {
|
||||
await task(
|
||||
platform_channels_benchmarks.runTask(DeviceOperatingSystem.android));
|
||||
await task(platform_channels_benchmarks.runTask(DeviceOperatingSystem.android));
|
||||
}
|
||||
|
||||
@@ -4,7 +4,8 @@
|
||||
|
||||
import 'package:flutter_devicelab/framework/devices.dart' show DeviceOperatingSystem;
|
||||
import 'package:flutter_devicelab/framework/framework.dart' show task;
|
||||
import 'package:flutter_devicelab/tasks/platform_channels_benchmarks.dart' as platform_channels_benchmarks;
|
||||
import 'package:flutter_devicelab/tasks/platform_channels_benchmarks.dart'
|
||||
as platform_channels_benchmarks;
|
||||
|
||||
Future<void> main() async {
|
||||
await task(platform_channels_benchmarks.runTask(DeviceOperatingSystem.ios));
|
||||
|
||||
@@ -13,9 +13,7 @@ Future<void> main() async {
|
||||
deviceOperatingSystem = DeviceOperatingSystem.ios;
|
||||
await task(() async {
|
||||
final String platformViewDirectoryPath = '${flutterDirectory.path}/examples/platform_view';
|
||||
final Directory platformViewDirectory = dir(
|
||||
platformViewDirectoryPath
|
||||
);
|
||||
final Directory platformViewDirectory = dir(platformViewDirectoryPath);
|
||||
await inDirectory(platformViewDirectory, () async {
|
||||
await flutter('pub', options: <String>['get']);
|
||||
// Pre-cache the iOS artifacts; this may be the first test run on this machine.
|
||||
|
||||
@@ -18,7 +18,6 @@ import 'package:path/path.dart' as path;
|
||||
/// contains "Unresolved reference: plugin_b".
|
||||
Future<void> main() async {
|
||||
await task(() async {
|
||||
|
||||
section('Find Java');
|
||||
|
||||
final String? javaHome = await findJavaHome();
|
||||
@@ -30,7 +29,6 @@ Future<void> main() async {
|
||||
|
||||
final Directory tempDir = Directory.systemTemp.createTempSync('flutter_plugin_dependencies.');
|
||||
try {
|
||||
|
||||
section('Create plugin A');
|
||||
|
||||
final Directory pluginADirectory = Directory(path.join(tempDir.path, 'plugin_a'));
|
||||
@@ -79,10 +77,7 @@ Future<void> main() async {
|
||||
);
|
||||
});
|
||||
|
||||
checkDirectoryNotExists(path.join(
|
||||
pluginCDirectory.path,
|
||||
'android',
|
||||
));
|
||||
checkDirectoryNotExists(path.join(pluginCDirectory.path, 'android'));
|
||||
|
||||
final File pluginCpubspec = File(path.join(pluginCDirectory.path, 'pubspec.yaml'));
|
||||
await pluginCpubspec.writeAsString('''
|
||||
@@ -120,21 +115,20 @@ environment:
|
||||
);
|
||||
});
|
||||
|
||||
checkDirectoryNotExists(path.join(
|
||||
pluginDDirectory.path,
|
||||
'ios',
|
||||
));
|
||||
checkDirectoryNotExists(path.join(pluginDDirectory.path, 'ios'));
|
||||
|
||||
section('Write dummy Kotlin code in plugin B');
|
||||
|
||||
final File pluginBKotlinClass = File(path.join(
|
||||
pluginBDirectory.path,
|
||||
'android',
|
||||
'src',
|
||||
'main',
|
||||
'kotlin',
|
||||
'DummyPluginBClass.kt',
|
||||
));
|
||||
final File pluginBKotlinClass = File(
|
||||
path.join(
|
||||
pluginBDirectory.path,
|
||||
'android',
|
||||
'src',
|
||||
'main',
|
||||
'kotlin',
|
||||
'DummyPluginBClass.kt',
|
||||
),
|
||||
);
|
||||
|
||||
await pluginBKotlinClass.writeAsString('''
|
||||
package io.flutter.devicelab.plugin_b
|
||||
@@ -154,25 +148,27 @@ public class DummyPluginBClass {
|
||||
pluginApubspecContent = pluginApubspecContent.replaceFirst(
|
||||
'${Platform.lineTerminator}dependencies:${Platform.lineTerminator}',
|
||||
'${Platform.lineTerminator}dependencies:${Platform.lineTerminator}'
|
||||
' plugin_b:${Platform.lineTerminator}'
|
||||
' path: ${pluginBDirectory.path}${Platform.lineTerminator}'
|
||||
' plugin_c:${Platform.lineTerminator}'
|
||||
' path: ${pluginCDirectory.path}${Platform.lineTerminator}'
|
||||
' plugin_d:${Platform.lineTerminator}'
|
||||
' path: ${pluginDDirectory.path}${Platform.lineTerminator}',
|
||||
' plugin_b:${Platform.lineTerminator}'
|
||||
' path: ${pluginBDirectory.path}${Platform.lineTerminator}'
|
||||
' plugin_c:${Platform.lineTerminator}'
|
||||
' path: ${pluginCDirectory.path}${Platform.lineTerminator}'
|
||||
' plugin_d:${Platform.lineTerminator}'
|
||||
' path: ${pluginDDirectory.path}${Platform.lineTerminator}',
|
||||
);
|
||||
await pluginApubspec.writeAsString(pluginApubspecContent, flush: true);
|
||||
|
||||
section('Write Kotlin code in plugin A that references Kotlin code from plugin B');
|
||||
|
||||
final File pluginAKotlinClass = File(path.join(
|
||||
pluginADirectory.path,
|
||||
'android',
|
||||
'src',
|
||||
'main',
|
||||
'kotlin',
|
||||
'DummyPluginAClass.kt',
|
||||
));
|
||||
final File pluginAKotlinClass = File(
|
||||
path.join(
|
||||
pluginADirectory.path,
|
||||
'android',
|
||||
'src',
|
||||
'main',
|
||||
'kotlin',
|
||||
'DummyPluginAClass.kt',
|
||||
),
|
||||
);
|
||||
|
||||
await pluginAKotlinClass.writeAsString('''
|
||||
package io.flutter.devicelab.plugin_a
|
||||
@@ -192,55 +188,56 @@ public class DummyPluginAClass {
|
||||
final Directory exampleApp = Directory(path.join(pluginADirectory.path, 'example'));
|
||||
|
||||
await inDirectory(exampleApp, () async {
|
||||
await flutter(
|
||||
'packages',
|
||||
options: <String>['get'],
|
||||
);
|
||||
await flutter('packages', options: <String>['get']);
|
||||
});
|
||||
|
||||
final File flutterPluginsDependenciesFile =
|
||||
File(path.join(exampleApp.path, '.flutter-plugins-dependencies'));
|
||||
final File flutterPluginsDependenciesFile = File(
|
||||
path.join(exampleApp.path, '.flutter-plugins-dependencies'),
|
||||
);
|
||||
|
||||
if (!flutterPluginsDependenciesFile.existsSync()) {
|
||||
return TaskResult.failure("${flutterPluginsDependenciesFile.path} doesn't exist");
|
||||
}
|
||||
|
||||
final String flutterPluginsDependenciesFileContent = flutterPluginsDependenciesFile.readAsStringSync();
|
||||
final String flutterPluginsDependenciesFileContent =
|
||||
flutterPluginsDependenciesFile.readAsStringSync();
|
||||
|
||||
final Map<String, dynamic> jsonContent = json.decode(flutterPluginsDependenciesFileContent) as Map<String, dynamic>;
|
||||
final Map<String, dynamic>? swiftPackageManagerJson = jsonContent['swift_package_manager_enabled'] as Map<String, dynamic>?;
|
||||
final Map<String, dynamic> jsonContent =
|
||||
json.decode(flutterPluginsDependenciesFileContent) as Map<String, dynamic>;
|
||||
final Map<String, dynamic>? swiftPackageManagerJson =
|
||||
jsonContent['swift_package_manager_enabled'] as Map<String, dynamic>?;
|
||||
|
||||
// Verify the dependencyGraph object is valid. The rest of the contents of this file are not relevant to the
|
||||
// dependency graph and are tested by unit tests.
|
||||
final List<dynamic> dependencyGraph = jsonContent['dependencyGraph'] as List<dynamic>;
|
||||
const String kExpectedPluginsDependenciesContent =
|
||||
'['
|
||||
'['
|
||||
'{'
|
||||
'"name":"integration_test",'
|
||||
'"dependencies":[]'
|
||||
'"name":"integration_test",'
|
||||
'"dependencies":[]'
|
||||
'},'
|
||||
'{'
|
||||
'"name":"plugin_a",'
|
||||
'"dependencies":["plugin_b","plugin_c","plugin_d"]'
|
||||
'"name":"plugin_a",'
|
||||
'"dependencies":["plugin_b","plugin_c","plugin_d"]'
|
||||
'},'
|
||||
'{'
|
||||
'"name":"plugin_b",'
|
||||
'"dependencies":[]'
|
||||
'"name":"plugin_b",'
|
||||
'"dependencies":[]'
|
||||
'},'
|
||||
'{'
|
||||
'"name":"plugin_c",'
|
||||
'"dependencies":[]'
|
||||
'"name":"plugin_c",'
|
||||
'"dependencies":[]'
|
||||
'},'
|
||||
'{'
|
||||
'"name":"plugin_d",'
|
||||
'"dependencies":[]'
|
||||
'"name":"plugin_d",'
|
||||
'"dependencies":[]'
|
||||
'}'
|
||||
']';
|
||||
']';
|
||||
final String graphString = json.encode(dependencyGraph);
|
||||
if (graphString != kExpectedPluginsDependenciesContent) {
|
||||
return TaskResult.failure(
|
||||
'Unexpected file content in ${flutterPluginsDependenciesFile.path}: '
|
||||
'Found "$graphString" instead of "$kExpectedPluginsDependenciesContent"'
|
||||
'Found "$graphString" instead of "$kExpectedPluginsDependenciesContent"',
|
||||
);
|
||||
}
|
||||
|
||||
@@ -260,16 +257,20 @@ public class DummyPluginAClass {
|
||||
return TaskResult.failure('plugin_a cannot reference plugin_b');
|
||||
}
|
||||
|
||||
final bool pluginAExampleApk = exists(File(path.join(
|
||||
pluginADirectory.path,
|
||||
'example',
|
||||
'build',
|
||||
'app',
|
||||
'outputs',
|
||||
'apk',
|
||||
'release',
|
||||
'app-release.apk',
|
||||
)));
|
||||
final bool pluginAExampleApk = exists(
|
||||
File(
|
||||
path.join(
|
||||
pluginADirectory.path,
|
||||
'example',
|
||||
'build',
|
||||
'app',
|
||||
'outputs',
|
||||
'apk',
|
||||
'release',
|
||||
'app-release.apk',
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
if (!pluginAExampleApk) {
|
||||
return TaskResult.failure('Failed to build plugin A example APK');
|
||||
@@ -279,24 +280,12 @@ public class DummyPluginAClass {
|
||||
section('Build plugin A example iOS app');
|
||||
|
||||
await inDirectory(exampleApp, () async {
|
||||
await evalFlutter(
|
||||
'build',
|
||||
options: <String>[
|
||||
'ios',
|
||||
'--no-codesign',
|
||||
'--verbose',
|
||||
],
|
||||
);
|
||||
await evalFlutter('build', options: <String>['ios', '--no-codesign', '--verbose']);
|
||||
});
|
||||
|
||||
final Directory appBundle = Directory(path.join(
|
||||
pluginADirectory.path,
|
||||
'example',
|
||||
'build',
|
||||
'ios',
|
||||
'iphoneos',
|
||||
'Runner.app',
|
||||
));
|
||||
final Directory appBundle = Directory(
|
||||
path.join(pluginADirectory.path, 'example', 'build', 'ios', 'iphoneos', 'Runner.app'),
|
||||
);
|
||||
|
||||
if (!exists(appBundle)) {
|
||||
return TaskResult.failure('Failed to build plugin A example iOS app');
|
||||
@@ -326,14 +315,12 @@ public class DummyPluginAClass {
|
||||
|
||||
if (!foundA || !foundB || !foundC) {
|
||||
return TaskResult.failure(
|
||||
'Failed to find plugins_a, plugin_b, or plugin_c symbols in the app'
|
||||
'Failed to find plugins_a, plugin_b, or plugin_c symbols in the app',
|
||||
);
|
||||
}
|
||||
|
||||
if (foundD) {
|
||||
return TaskResult.failure(
|
||||
'Found Android plugin_d symbols in iOS app'
|
||||
);
|
||||
return TaskResult.failure('Found Android plugin_d symbols in iOS app');
|
||||
}
|
||||
} else {
|
||||
// Check plugins are built dynamically if using CocoaPods.
|
||||
|
||||
@@ -13,42 +13,45 @@ import 'package:path/path.dart' as path;
|
||||
/// to confirm the plugin module can be imported into an app.
|
||||
Future<void> main() async {
|
||||
await task(() async {
|
||||
|
||||
final Directory tempDir = Directory.systemTemp.createTempSync('flutter_plugin_test.');
|
||||
try {
|
||||
section('Lint integration_test');
|
||||
|
||||
await inDirectory(tempDir, () async {
|
||||
// Update pod repo.
|
||||
await exec(
|
||||
'pod',
|
||||
<String>['repo', 'update'],
|
||||
);
|
||||
await exec('pod', <String>['repo', 'update']);
|
||||
|
||||
// Relative to this script.
|
||||
final String flutterRoot = path.dirname(path.dirname(path.dirname(path.dirname(path.dirname(path.fromUri(Platform.script))))));
|
||||
final String flutterRoot = path.dirname(
|
||||
path.dirname(path.dirname(path.dirname(path.dirname(path.fromUri(Platform.script))))),
|
||||
);
|
||||
print('Flutter root at $flutterRoot');
|
||||
final String integrationTestPackage = path.join(flutterRoot, 'packages', 'integration_test');
|
||||
final String iosintegrationTestPodspec = path.join(integrationTestPackage, 'ios', 'integration_test.podspec');
|
||||
|
||||
await exec(
|
||||
'pod',
|
||||
<String>[
|
||||
'lib',
|
||||
'lint',
|
||||
iosintegrationTestPodspec,
|
||||
'--use-libraries',
|
||||
'--verbose',
|
||||
],
|
||||
final String integrationTestPackage = path.join(
|
||||
flutterRoot,
|
||||
'packages',
|
||||
'integration_test',
|
||||
);
|
||||
final String iosintegrationTestPodspec = path.join(
|
||||
integrationTestPackage,
|
||||
'ios',
|
||||
'integration_test.podspec',
|
||||
);
|
||||
|
||||
final String macosintegrationTestPodspec = path.join(integrationTestPackage, 'integration_test_macos', 'macos', 'integration_test_macos.podspec');
|
||||
await _tryMacOSLint(
|
||||
macosintegrationTestPodspec,
|
||||
<String>[
|
||||
'--verbose',
|
||||
],
|
||||
await exec('pod', <String>[
|
||||
'lib',
|
||||
'lint',
|
||||
iosintegrationTestPodspec,
|
||||
'--use-libraries',
|
||||
'--verbose',
|
||||
]);
|
||||
|
||||
final String macosintegrationTestPodspec = path.join(
|
||||
integrationTestPackage,
|
||||
'integration_test_macos',
|
||||
'macos',
|
||||
'integration_test_macos.podspec',
|
||||
);
|
||||
await _tryMacOSLint(macosintegrationTestPodspec, <String>['--verbose']);
|
||||
});
|
||||
|
||||
section('Create Objective-C plugin');
|
||||
@@ -73,32 +76,26 @@ Future<void> main() async {
|
||||
final String objcPluginPath = path.join(tempDir.path, objcPluginName);
|
||||
final String objcPodspecPath = path.join(objcPluginPath, 'ios', '$objcPluginName.podspec');
|
||||
await inDirectory(tempDir, () async {
|
||||
await exec(
|
||||
'pod',
|
||||
<String>[
|
||||
'lib',
|
||||
'lint',
|
||||
objcPodspecPath,
|
||||
'--allow-warnings',
|
||||
'--verbose',
|
||||
],
|
||||
);
|
||||
await exec('pod', <String>[
|
||||
'lib',
|
||||
'lint',
|
||||
objcPodspecPath,
|
||||
'--allow-warnings',
|
||||
'--verbose',
|
||||
]);
|
||||
});
|
||||
|
||||
section('Lint Objective-C iOS podspec plugin as library');
|
||||
|
||||
await inDirectory(tempDir, () async {
|
||||
await exec(
|
||||
'pod',
|
||||
<String>[
|
||||
'lib',
|
||||
'lint',
|
||||
objcPodspecPath,
|
||||
'--allow-warnings',
|
||||
'--use-libraries',
|
||||
'--verbose',
|
||||
],
|
||||
);
|
||||
await exec('pod', <String>[
|
||||
'lib',
|
||||
'lint',
|
||||
objcPodspecPath,
|
||||
'--allow-warnings',
|
||||
'--use-libraries',
|
||||
'--verbose',
|
||||
]);
|
||||
});
|
||||
|
||||
section('Create Swift plugin');
|
||||
@@ -123,58 +120,47 @@ Future<void> main() async {
|
||||
final String swiftPluginPath = path.join(tempDir.path, swiftPluginName);
|
||||
final String swiftPodspecPath = path.join(swiftPluginPath, 'ios', '$swiftPluginName.podspec');
|
||||
await inDirectory(tempDir, () async {
|
||||
await exec(
|
||||
'pod',
|
||||
<String>[
|
||||
'lib',
|
||||
'lint',
|
||||
swiftPodspecPath,
|
||||
'--allow-warnings',
|
||||
'--verbose',
|
||||
],
|
||||
);
|
||||
await exec('pod', <String>[
|
||||
'lib',
|
||||
'lint',
|
||||
swiftPodspecPath,
|
||||
'--allow-warnings',
|
||||
'--verbose',
|
||||
]);
|
||||
});
|
||||
|
||||
section('Lint Swift iOS podspec plugin as library');
|
||||
|
||||
await inDirectory(tempDir, () async {
|
||||
await exec(
|
||||
'pod',
|
||||
<String>[
|
||||
'lib',
|
||||
'lint',
|
||||
swiftPodspecPath,
|
||||
'--allow-warnings',
|
||||
'--use-libraries',
|
||||
'--verbose',
|
||||
],
|
||||
);
|
||||
await exec('pod', <String>[
|
||||
'lib',
|
||||
'lint',
|
||||
swiftPodspecPath,
|
||||
'--allow-warnings',
|
||||
'--use-libraries',
|
||||
'--verbose',
|
||||
]);
|
||||
});
|
||||
|
||||
section('Lint Swift macOS podspec plugin as framework');
|
||||
|
||||
final String macOSPodspecPath = path.join(swiftPluginPath, 'macos', '$swiftPluginName.podspec');
|
||||
final String macOSPodspecPath = path.join(
|
||||
swiftPluginPath,
|
||||
'macos',
|
||||
'$swiftPluginName.podspec',
|
||||
);
|
||||
await inDirectory(tempDir, () async {
|
||||
await _tryMacOSLint(
|
||||
macOSPodspecPath,
|
||||
<String>[
|
||||
'--allow-warnings',
|
||||
'--verbose',
|
||||
],
|
||||
);
|
||||
await _tryMacOSLint(macOSPodspecPath, <String>['--allow-warnings', '--verbose']);
|
||||
});
|
||||
|
||||
section('Lint Swift macOS podspec plugin as library');
|
||||
|
||||
await inDirectory(tempDir, () async {
|
||||
await _tryMacOSLint(
|
||||
macOSPodspecPath,
|
||||
<String>[
|
||||
'--allow-warnings',
|
||||
'--use-libraries',
|
||||
'--verbose',
|
||||
],
|
||||
);
|
||||
await _tryMacOSLint(macOSPodspecPath, <String>[
|
||||
'--allow-warnings',
|
||||
'--use-libraries',
|
||||
'--verbose',
|
||||
]);
|
||||
});
|
||||
|
||||
section('Create Objective-C application');
|
||||
@@ -209,19 +195,18 @@ Future<void> main() async {
|
||||
await inDirectory(objcAppPath, () async {
|
||||
await flutter(
|
||||
'build',
|
||||
options: <String>[
|
||||
'ios',
|
||||
'--no-codesign',
|
||||
],
|
||||
options: <String>['ios', '--no-codesign'],
|
||||
// TODO(jmagman): Make Objective-C applications handle Swift libraries https://github.com/flutter/flutter/issues/16049
|
||||
canFail: true
|
||||
canFail: true,
|
||||
);
|
||||
});
|
||||
|
||||
final File objcPodfile = File(path.join(objcAppPath, 'ios', 'Podfile'));
|
||||
String objcPodfileContent = objcPodfile.readAsStringSync();
|
||||
if (objcPodfileContent.contains('use_frameworks!')) {
|
||||
return TaskResult.failure('Expected default Objective-C Podfile to not contain use_frameworks');
|
||||
return TaskResult.failure(
|
||||
'Expected default Objective-C Podfile to not contain use_frameworks',
|
||||
);
|
||||
}
|
||||
_validateIosPodfile(objcAppPath);
|
||||
|
||||
@@ -231,13 +216,7 @@ Future<void> main() async {
|
||||
objcPodfile.writeAsStringSync(objcPodfileContent, flush: true);
|
||||
|
||||
await inDirectory(objcAppPath, () async {
|
||||
await flutter(
|
||||
'build',
|
||||
options: <String>[
|
||||
'ios',
|
||||
'--no-codesign',
|
||||
],
|
||||
);
|
||||
await flutter('build', options: <String>['ios', '--no-codesign']);
|
||||
});
|
||||
|
||||
section('Create Swift application');
|
||||
@@ -264,13 +243,7 @@ Future<void> main() async {
|
||||
swiftPubspec.writeAsStringSync(pubspecContent, flush: true);
|
||||
|
||||
await inDirectory(swiftAppPath, () async {
|
||||
await flutter(
|
||||
'build',
|
||||
options: <String>[
|
||||
'ios',
|
||||
'--no-codesign',
|
||||
],
|
||||
);
|
||||
await flutter('build', options: <String>['ios', '--no-codesign']);
|
||||
});
|
||||
|
||||
final File swiftPodfile = File(path.join(swiftAppPath, 'ios', 'Podfile'));
|
||||
@@ -285,25 +258,14 @@ Future<void> main() async {
|
||||
swiftPodfile.writeAsStringSync(swiftPodfileContent, flush: true);
|
||||
|
||||
await inDirectory(swiftAppPath, () async {
|
||||
await flutter(
|
||||
'build',
|
||||
options: <String>[
|
||||
'ios',
|
||||
'--no-codesign',
|
||||
],
|
||||
);
|
||||
await flutter('build', options: <String>['ios', '--no-codesign']);
|
||||
});
|
||||
|
||||
_validateIosPodfile(swiftAppPath);
|
||||
|
||||
section('Build Swift macOS application with plugins as frameworks');
|
||||
await inDirectory(swiftAppPath, () async {
|
||||
await flutter(
|
||||
'build',
|
||||
options: <String>[
|
||||
'macos',
|
||||
],
|
||||
);
|
||||
await flutter('build', options: <String>['macos']);
|
||||
});
|
||||
|
||||
final File macOSPodfile = File(path.join(swiftAppPath, 'macos', 'Podfile'));
|
||||
@@ -320,12 +282,7 @@ Future<void> main() async {
|
||||
macOSPodfile.writeAsStringSync(macosPodfileContent, flush: true);
|
||||
|
||||
await inDirectory(swiftAppPath, () async {
|
||||
await flutter(
|
||||
'build',
|
||||
options: <String>[
|
||||
'macos',
|
||||
],
|
||||
);
|
||||
await flutter('build', options: <String>['macos']);
|
||||
});
|
||||
|
||||
_validateMacOSPodfile(swiftAppPath);
|
||||
@@ -349,52 +306,31 @@ Future<void> main() async {
|
||||
|
||||
await inDirectory(swiftAppPath, () async {
|
||||
await flutter('clean');
|
||||
await flutter(
|
||||
'build',
|
||||
options: <String>[
|
||||
'ios',
|
||||
'--no-codesign',
|
||||
],
|
||||
);
|
||||
await flutter('build', options: <String>['ios', '--no-codesign']);
|
||||
});
|
||||
|
||||
section('Validate plugin without iOS platform');
|
||||
|
||||
final File podfileLockFile = File(path.join(swiftAppPath, 'ios', 'Podfile.lock'));
|
||||
final String podfileLockOutput = podfileLockFile.readAsStringSync();
|
||||
if (!podfileLockOutput.contains(':path: ".symlinks/plugins/url_launcher_ios/ios"')
|
||||
|| !podfileLockOutput.contains(':path: Flutter')
|
||||
if (!podfileLockOutput.contains(':path: ".symlinks/plugins/url_launcher_ios/ios"') ||
|
||||
!podfileLockOutput.contains(':path: Flutter')
|
||||
// test_plugin_objc no longer supports iOS, shouldn't be present.
|
||||
|| podfileLockOutput.contains(':path: ".symlinks/plugins/test_plugin_objc/ios"')
|
||||
|| !podfileLockOutput.contains(':path: ".symlinks/plugins/test_plugin_swift/ios"')) {
|
||||
||
|
||||
podfileLockOutput.contains(':path: ".symlinks/plugins/test_plugin_objc/ios"') ||
|
||||
!podfileLockOutput.contains(':path: ".symlinks/plugins/test_plugin_swift/ios"')) {
|
||||
print(podfileLockOutput);
|
||||
return TaskResult.failure('Podfile.lock does not contain expected pods');
|
||||
}
|
||||
|
||||
final String pluginSymlinks = path.join(
|
||||
swiftAppPath,
|
||||
'ios',
|
||||
'.symlinks',
|
||||
'plugins',
|
||||
);
|
||||
final String pluginSymlinks = path.join(swiftAppPath, 'ios', '.symlinks', 'plugins');
|
||||
|
||||
checkDirectoryExists(path.join(
|
||||
pluginSymlinks,
|
||||
'url_launcher_ios',
|
||||
'ios',
|
||||
));
|
||||
checkDirectoryExists(path.join(pluginSymlinks, 'url_launcher_ios', 'ios'));
|
||||
|
||||
checkDirectoryExists(path.join(
|
||||
pluginSymlinks,
|
||||
'test_plugin_swift',
|
||||
'ios',
|
||||
));
|
||||
checkDirectoryExists(path.join(pluginSymlinks, 'test_plugin_swift', 'ios'));
|
||||
|
||||
// test_plugin_objc no longer supports iOS, shouldn't exist!
|
||||
checkDirectoryNotExists(path.join(
|
||||
pluginSymlinks,
|
||||
'test_plugin_objc',
|
||||
));
|
||||
checkDirectoryNotExists(path.join(pluginSymlinks, 'test_plugin_objc'));
|
||||
|
||||
return TaskResult.success(null);
|
||||
} catch (e) {
|
||||
@@ -410,65 +346,31 @@ void _validateIosPodfile(String appPath) {
|
||||
|
||||
final File podfileLockFile = File(path.join(appPath, 'ios', 'Podfile.lock'));
|
||||
final String podfileLockOutput = podfileLockFile.readAsStringSync();
|
||||
if (!podfileLockOutput.contains(':path: ".symlinks/plugins/url_launcher_ios/ios"')
|
||||
|| !podfileLockOutput.contains(':path: Flutter')
|
||||
|| !podfileLockOutput.contains(':path: ".symlinks/plugins/test_plugin_objc/ios"')
|
||||
|| !podfileLockOutput.contains(':path: ".symlinks/plugins/test_plugin_swift/ios"')
|
||||
|| podfileLockOutput.contains('url_launcher_macos')) {
|
||||
if (!podfileLockOutput.contains(':path: ".symlinks/plugins/url_launcher_ios/ios"') ||
|
||||
!podfileLockOutput.contains(':path: Flutter') ||
|
||||
!podfileLockOutput.contains(':path: ".symlinks/plugins/test_plugin_objc/ios"') ||
|
||||
!podfileLockOutput.contains(':path: ".symlinks/plugins/test_plugin_swift/ios"') ||
|
||||
podfileLockOutput.contains('url_launcher_macos')) {
|
||||
print(podfileLockOutput);
|
||||
throw TaskResult.failure('iOS Podfile.lock does not contain expected pods');
|
||||
}
|
||||
|
||||
checkDirectoryNotExists(path.join(
|
||||
appPath,
|
||||
'ios',
|
||||
'Flutter',
|
||||
'Flutter.framework',
|
||||
));
|
||||
checkDirectoryNotExists(path.join(appPath, 'ios', 'Flutter', 'Flutter.framework'));
|
||||
|
||||
checkFileExists(path.join(
|
||||
appPath,
|
||||
'ios',
|
||||
'Flutter',
|
||||
'Flutter.podspec',
|
||||
));
|
||||
checkFileExists(path.join(appPath, 'ios', 'Flutter', 'Flutter.podspec'));
|
||||
|
||||
final String pluginSymlinks = path.join(
|
||||
appPath,
|
||||
'ios',
|
||||
'.symlinks',
|
||||
'plugins',
|
||||
);
|
||||
final String pluginSymlinks = path.join(appPath, 'ios', '.symlinks', 'plugins');
|
||||
|
||||
checkDirectoryExists(path.join(
|
||||
pluginSymlinks,
|
||||
'url_launcher_ios',
|
||||
'ios',
|
||||
));
|
||||
checkDirectoryExists(path.join(pluginSymlinks, 'url_launcher_ios', 'ios'));
|
||||
|
||||
checkDirectoryNotExists(path.join(
|
||||
pluginSymlinks,
|
||||
'url_launcher_macos',
|
||||
));
|
||||
checkDirectoryNotExists(path.join(pluginSymlinks, 'url_launcher_macos'));
|
||||
|
||||
checkDirectoryExists(path.join(
|
||||
pluginSymlinks,
|
||||
'test_plugin_objc',
|
||||
'ios',
|
||||
));
|
||||
checkDirectoryExists(path.join(pluginSymlinks, 'test_plugin_objc', 'ios'));
|
||||
|
||||
checkDirectoryExists(path.join(
|
||||
pluginSymlinks,
|
||||
'test_plugin_swift',
|
||||
'ios',
|
||||
));
|
||||
checkDirectoryExists(path.join(pluginSymlinks, 'test_plugin_swift', 'ios'));
|
||||
|
||||
// Make sure no Xcode build settings are leaking derived data/build directory into the ios directory.
|
||||
checkDirectoryNotExists(path.join(
|
||||
appPath,
|
||||
'ios',
|
||||
'build',
|
||||
));
|
||||
checkDirectoryNotExists(path.join(appPath, 'ios', 'build'));
|
||||
}
|
||||
|
||||
void _validateMacOSPodfile(String appPath) {
|
||||
@@ -476,21 +378,19 @@ void _validateMacOSPodfile(String appPath) {
|
||||
|
||||
final File podfileLockFile = File(path.join(appPath, 'macos', 'Podfile.lock'));
|
||||
final String podfileLockOutput = podfileLockFile.readAsStringSync();
|
||||
if (!podfileLockOutput.contains(':path: Flutter/ephemeral\n')
|
||||
|| !podfileLockOutput.contains(':path: Flutter/ephemeral/.symlinks/plugins/url_launcher_macos/macos')
|
||||
|| !podfileLockOutput.contains(':path: Flutter/ephemeral/.symlinks/plugins/test_plugin_swift/macos')
|
||||
|| podfileLockOutput.contains('url_launcher_ios/')) {
|
||||
if (!podfileLockOutput.contains(':path: Flutter/ephemeral\n') ||
|
||||
!podfileLockOutput.contains(
|
||||
':path: Flutter/ephemeral/.symlinks/plugins/url_launcher_macos/macos',
|
||||
) ||
|
||||
!podfileLockOutput.contains(
|
||||
':path: Flutter/ephemeral/.symlinks/plugins/test_plugin_swift/macos',
|
||||
) ||
|
||||
podfileLockOutput.contains('url_launcher_ios/')) {
|
||||
print(podfileLockOutput);
|
||||
throw TaskResult.failure('macOS Podfile.lock does not contain expected pods');
|
||||
}
|
||||
|
||||
checkFileExists(path.join(
|
||||
appPath,
|
||||
'macos',
|
||||
'Flutter',
|
||||
'ephemeral',
|
||||
'FlutterMacOS.podspec',
|
||||
));
|
||||
checkFileExists(path.join(appPath, 'macos', 'Flutter', 'ephemeral', 'FlutterMacOS.podspec'));
|
||||
|
||||
final String pluginSymlinks = path.join(
|
||||
appPath,
|
||||
@@ -501,35 +401,13 @@ void _validateMacOSPodfile(String appPath) {
|
||||
'plugins',
|
||||
);
|
||||
|
||||
checkDirectoryExists(path.join(
|
||||
pluginSymlinks,
|
||||
'url_launcher_macos',
|
||||
'macos',
|
||||
));
|
||||
checkDirectoryExists(path.join(pluginSymlinks, 'url_launcher_macos', 'macos'));
|
||||
|
||||
checkDirectoryNotExists(path.join(
|
||||
pluginSymlinks,
|
||||
'url_launcher_ios',
|
||||
));
|
||||
checkDirectoryNotExists(path.join(pluginSymlinks, 'url_launcher_ios'));
|
||||
|
||||
checkDirectoryExists(path.join(
|
||||
pluginSymlinks,
|
||||
'test_plugin_swift',
|
||||
'macos',
|
||||
));
|
||||
checkDirectoryExists(path.join(pluginSymlinks, 'test_plugin_swift', 'macos'));
|
||||
}
|
||||
|
||||
Future<void> _tryMacOSLint(
|
||||
String podspecPath,
|
||||
List<String> extraArguments,
|
||||
) async {
|
||||
await eval(
|
||||
'pod',
|
||||
<String>[
|
||||
'lib',
|
||||
'lint',
|
||||
podspecPath,
|
||||
...extraArguments,
|
||||
],
|
||||
);
|
||||
Future<void> _tryMacOSLint(String podspecPath, List<String> extraArguments) async {
|
||||
await eval('pod', <String>['lib', 'lint', podspecPath, ...extraArguments]);
|
||||
}
|
||||
|
||||
@@ -6,12 +6,14 @@ import 'package:flutter_devicelab/framework/framework.dart';
|
||||
import 'package:flutter_devicelab/tasks/plugin_tests.dart';
|
||||
|
||||
Future<void> main() async {
|
||||
await task(combine(<TaskFunction>[
|
||||
PluginTest('apk', <String>['-a', 'java', '--platforms=android']).call,
|
||||
PluginTest('apk', <String>['-a', 'kotlin', '--platforms=android']).call,
|
||||
// Test that Dart-only plugins are supported.
|
||||
PluginTest('apk', <String>['--platforms=android'], dartOnlyPlugin: true).call,
|
||||
// Test that FFI plugins are supported.
|
||||
PluginTest('apk', <String>['--platforms=android'], template: 'plugin_ffi').call,
|
||||
]));
|
||||
await task(
|
||||
combine(<TaskFunction>[
|
||||
PluginTest('apk', <String>['-a', 'java', '--platforms=android']).call,
|
||||
PluginTest('apk', <String>['-a', 'kotlin', '--platforms=android']).call,
|
||||
// Test that Dart-only plugins are supported.
|
||||
PluginTest('apk', <String>['--platforms=android'], dartOnlyPlugin: true).call,
|
||||
// Test that FFI plugins are supported.
|
||||
PluginTest('apk', <String>['--platforms=android'], template: 'plugin_ffi').call,
|
||||
]),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -6,16 +6,22 @@ import 'package:flutter_devicelab/framework/framework.dart';
|
||||
import 'package:flutter_devicelab/tasks/plugin_tests.dart';
|
||||
|
||||
Future<void> main() async {
|
||||
await task(combine(<TaskFunction>[
|
||||
PluginTest('ios', <String>['-i', 'objc', '--platforms=ios']).call,
|
||||
PluginTest('ios', <String>['-i', 'swift', '--platforms=ios']).call,
|
||||
// Test that app builds with Flutter as a transitive dependency.
|
||||
PluginTest('ios', <String>['-i', 'objc', '--platforms=ios'], cocoapodsTransitiveFlutterDependency: true).call,
|
||||
// Test that Dart-only plugins are supported.
|
||||
PluginTest('ios', <String>['--platforms=ios'], dartOnlyPlugin: true).call,
|
||||
// Test that shared darwin directories are supported.
|
||||
PluginTest('ios', <String>['--platforms=ios,macos'], sharedDarwinSource: true).call,
|
||||
// Test that FFI plugins are supported.
|
||||
PluginTest('ios', <String>['--platforms=ios'], template: 'plugin_ffi').call,
|
||||
]));
|
||||
await task(
|
||||
combine(<TaskFunction>[
|
||||
PluginTest('ios', <String>['-i', 'objc', '--platforms=ios']).call,
|
||||
PluginTest('ios', <String>['-i', 'swift', '--platforms=ios']).call,
|
||||
// Test that app builds with Flutter as a transitive dependency.
|
||||
PluginTest('ios', <String>[
|
||||
'-i',
|
||||
'objc',
|
||||
'--platforms=ios',
|
||||
], cocoapodsTransitiveFlutterDependency: true).call,
|
||||
// Test that Dart-only plugins are supported.
|
||||
PluginTest('ios', <String>['--platforms=ios'], dartOnlyPlugin: true).call,
|
||||
// Test that shared darwin directories are supported.
|
||||
PluginTest('ios', <String>['--platforms=ios,macos'], sharedDarwinSource: true).call,
|
||||
// Test that FFI plugins are supported.
|
||||
PluginTest('ios', <String>['--platforms=ios'], template: 'plugin_ffi').call,
|
||||
]),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -6,11 +6,13 @@ import 'package:flutter_devicelab/framework/framework.dart';
|
||||
import 'package:flutter_devicelab/tasks/plugin_tests.dart';
|
||||
|
||||
Future<void> main() async {
|
||||
await task(combine(<TaskFunction>[
|
||||
PluginTest('linux', <String>['--platforms=linux']).call,
|
||||
// Test that Dart-only plugins are supported.
|
||||
PluginTest('linux', <String>['--platforms=linux'], dartOnlyPlugin: true).call,
|
||||
// Test that FFI plugins are supported.
|
||||
PluginTest('linux', <String>['--platforms=linux'], template: 'plugin_ffi').call,
|
||||
]));
|
||||
await task(
|
||||
combine(<TaskFunction>[
|
||||
PluginTest('linux', <String>['--platforms=linux']).call,
|
||||
// Test that Dart-only plugins are supported.
|
||||
PluginTest('linux', <String>['--platforms=linux'], dartOnlyPlugin: true).call,
|
||||
// Test that FFI plugins are supported.
|
||||
PluginTest('linux', <String>['--platforms=linux'], template: 'plugin_ffi').call,
|
||||
]),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -6,13 +6,15 @@ import 'package:flutter_devicelab/framework/framework.dart';
|
||||
import 'package:flutter_devicelab/tasks/plugin_tests.dart';
|
||||
|
||||
Future<void> main() async {
|
||||
await task(combine(<TaskFunction>[
|
||||
PluginTest('macos', <String>['--platforms=macos']).call,
|
||||
// Test that Dart-only plugins are supported.
|
||||
PluginTest('macos', <String>['--platforms=macos'], dartOnlyPlugin: true).call,
|
||||
// Test that shared darwin directories are supported.
|
||||
PluginTest('macos', <String>['--platforms=ios,macos'], sharedDarwinSource: true).call,
|
||||
// Test that FFI plugins are supported.
|
||||
PluginTest('macos', <String>['--platforms=macos'], template: 'plugin_ffi').call,
|
||||
]));
|
||||
await task(
|
||||
combine(<TaskFunction>[
|
||||
PluginTest('macos', <String>['--platforms=macos']).call,
|
||||
// Test that Dart-only plugins are supported.
|
||||
PluginTest('macos', <String>['--platforms=macos'], dartOnlyPlugin: true).call,
|
||||
// Test that shared darwin directories are supported.
|
||||
PluginTest('macos', <String>['--platforms=ios,macos'], sharedDarwinSource: true).call,
|
||||
// Test that FFI plugins are supported.
|
||||
PluginTest('macos', <String>['--platforms=macos'], template: 'plugin_ffi').call,
|
||||
]),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -6,11 +6,13 @@ import 'package:flutter_devicelab/framework/framework.dart';
|
||||
import 'package:flutter_devicelab/tasks/plugin_tests.dart';
|
||||
|
||||
Future<void> main() async {
|
||||
await task(combine(<TaskFunction>[
|
||||
PluginTest('windows', <String>['--platforms=windows']).call,
|
||||
// Test that Dart-only plugins are supported.
|
||||
PluginTest('windows', <String>['--platforms=windows'], dartOnlyPlugin: true).call,
|
||||
// Test that FFI plugins are supported.
|
||||
PluginTest('windows', <String>['--platforms=windows'], template: 'plugin_ffi').call,
|
||||
]));
|
||||
await task(
|
||||
combine(<TaskFunction>[
|
||||
PluginTest('windows', <String>['--platforms=windows']).call,
|
||||
// Test that Dart-only plugins are supported.
|
||||
PluginTest('windows', <String>['--platforms=windows'], dartOnlyPlugin: true).call,
|
||||
// Test that FFI plugins are supported.
|
||||
PluginTest('windows', <String>['--platforms=windows'], template: 'plugin_ffi').call,
|
||||
]),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -41,56 +41,69 @@ void main() {
|
||||
final Process run = await startFlutter(
|
||||
'run',
|
||||
// --fast-start does not support routes.
|
||||
options: <String>['--verbose', '--disable-service-auth-codes', '--no-fast-start', '--no-publish-port', '-d', device.deviceId, '--route', '/smuggle-it', 'lib/route.dart'],
|
||||
options: <String>[
|
||||
'--verbose',
|
||||
'--disable-service-auth-codes',
|
||||
'--no-fast-start',
|
||||
'--no-publish-port',
|
||||
'-d',
|
||||
device.deviceId,
|
||||
'--route',
|
||||
'/smuggle-it',
|
||||
'lib/route.dart',
|
||||
],
|
||||
);
|
||||
run.stdout
|
||||
.transform<String>(utf8.decoder)
|
||||
.transform<String>(const LineSplitter())
|
||||
.listen((String line) {
|
||||
print('run:stdout: $line');
|
||||
if (vmServicePort == null) {
|
||||
vmServicePort = parseServicePort(line);
|
||||
if (vmServicePort != null) {
|
||||
print('service protocol connection available at port $vmServicePort');
|
||||
print('run: ready!');
|
||||
ready.complete();
|
||||
ok = true;
|
||||
}
|
||||
run.stdout.transform<String>(utf8.decoder).transform<String>(const LineSplitter()).listen((
|
||||
String line,
|
||||
) {
|
||||
print('run:stdout: $line');
|
||||
if (vmServicePort == null) {
|
||||
vmServicePort = parseServicePort(line);
|
||||
if (vmServicePort != null) {
|
||||
print('service protocol connection available at port $vmServicePort');
|
||||
print('run: ready!');
|
||||
ready.complete();
|
||||
ok = true;
|
||||
}
|
||||
});
|
||||
run.stderr
|
||||
.transform<String>(utf8.decoder)
|
||||
.transform<String>(const LineSplitter())
|
||||
.listen((String line) {
|
||||
stderr.writeln('run:stderr: $line');
|
||||
});
|
||||
unawaited(run.exitCode.then<void>((int exitCode) { ok = false; }));
|
||||
await Future.any<dynamic>(<Future<dynamic>>[ ready.future, run.exitCode ]);
|
||||
}
|
||||
});
|
||||
run.stderr.transform<String>(utf8.decoder).transform<String>(const LineSplitter()).listen((
|
||||
String line,
|
||||
) {
|
||||
stderr.writeln('run:stderr: $line');
|
||||
});
|
||||
unawaited(
|
||||
run.exitCode.then<void>((int exitCode) {
|
||||
ok = false;
|
||||
}),
|
||||
);
|
||||
await Future.any<dynamic>(<Future<dynamic>>[ready.future, run.exitCode]);
|
||||
if (!ok) {
|
||||
throw 'Failed to run test app.';
|
||||
}
|
||||
print('drive: starting...');
|
||||
final Process drive = await startFlutter(
|
||||
'drive',
|
||||
options: <String>['--use-existing-app', 'http://127.0.0.1:$vmServicePort/', '--no-keep-app-running', 'lib/route.dart'],
|
||||
options: <String>[
|
||||
'--use-existing-app',
|
||||
'http://127.0.0.1:$vmServicePort/',
|
||||
'--no-keep-app-running',
|
||||
'lib/route.dart',
|
||||
],
|
||||
);
|
||||
drive.stdout
|
||||
.transform<String>(utf8.decoder)
|
||||
.transform<String>(const LineSplitter())
|
||||
.listen((String line) {
|
||||
print('drive:stdout: $line');
|
||||
});
|
||||
drive.stderr
|
||||
.transform<String>(utf8.decoder)
|
||||
.transform<String>(const LineSplitter())
|
||||
.listen((String line) {
|
||||
stderr.writeln('drive:stderr: $line');
|
||||
});
|
||||
drive.stdout.transform<String>(utf8.decoder).transform<String>(const LineSplitter()).listen((
|
||||
String line,
|
||||
) {
|
||||
print('drive:stdout: $line');
|
||||
});
|
||||
drive.stderr.transform<String>(utf8.decoder).transform<String>(const LineSplitter()).listen((
|
||||
String line,
|
||||
) {
|
||||
stderr.writeln('drive:stderr: $line');
|
||||
});
|
||||
int result;
|
||||
result = await drive.exitCode;
|
||||
await flutter('install', options: <String>[
|
||||
'--uninstall-only',
|
||||
]);
|
||||
await flutter('install', options: <String>['--uninstall-only']);
|
||||
if (result != 0) {
|
||||
throw 'Failed to drive test app (exit code $result).';
|
||||
}
|
||||
|
||||
@@ -27,12 +27,19 @@ void main() {
|
||||
print('run: starting...');
|
||||
final Process run = await startFlutter(
|
||||
'run',
|
||||
options: <String>['--verbose', '--no-fast-start', '--no-publish-port', '--disable-service-auth-codes', '-d', device.deviceId, 'lib/main.dart'],
|
||||
options: <String>[
|
||||
'--verbose',
|
||||
'--no-fast-start',
|
||||
'--no-publish-port',
|
||||
'--disable-service-auth-codes',
|
||||
'-d',
|
||||
device.deviceId,
|
||||
'lib/main.dart',
|
||||
],
|
||||
);
|
||||
run.stdout
|
||||
.transform<String>(utf8.decoder)
|
||||
.transform<String>(const LineSplitter())
|
||||
.listen((String line) {
|
||||
run.stdout.transform<String>(utf8.decoder).transform<String>(const LineSplitter()).listen((
|
||||
String line,
|
||||
) {
|
||||
print('run:stdout: $line');
|
||||
if (vmServicePort == null) {
|
||||
vmServicePort = parseServicePort(line);
|
||||
@@ -44,14 +51,17 @@ void main() {
|
||||
}
|
||||
}
|
||||
});
|
||||
run.stderr
|
||||
.transform<String>(utf8.decoder)
|
||||
.transform<String>(const LineSplitter())
|
||||
.listen((String line) {
|
||||
run.stderr.transform<String>(utf8.decoder).transform<String>(const LineSplitter()).listen((
|
||||
String line,
|
||||
) {
|
||||
stderr.writeln('run:stderr: $line');
|
||||
});
|
||||
unawaited(run.exitCode.then<void>((int exitCode) { ok = false; }));
|
||||
await Future.any<dynamic>(<Future<dynamic>>[ ready.future, run.exitCode ]);
|
||||
unawaited(
|
||||
run.exitCode.then<void>((int exitCode) {
|
||||
ok = false;
|
||||
}),
|
||||
);
|
||||
await Future.any<dynamic>(<Future<dynamic>>[ready.future, run.exitCode]);
|
||||
if (!ok) {
|
||||
throw 'Failed to run test app.';
|
||||
}
|
||||
@@ -107,7 +117,8 @@ void main() {
|
||||
final Event navigationEvent = await navigationFuture;
|
||||
// validate the fields
|
||||
expect(navigationEvent.extensionData!.data['route'] is Map<dynamic, dynamic>);
|
||||
final Map<dynamic, dynamic> route = navigationEvent.extensionData!.data['route'] as Map<dynamic, dynamic>;
|
||||
final Map<dynamic, dynamic> route =
|
||||
navigationEvent.extensionData!.data['route'] as Map<dynamic, dynamic>;
|
||||
expect(route['description'] is String);
|
||||
expect(route['settings'] is Map<dynamic, dynamic>);
|
||||
final Map<dynamic, dynamic> settings = route['settings'] as Map<dynamic, dynamic>;
|
||||
|
||||
@@ -12,14 +12,10 @@ Future<void> main() async {
|
||||
await task(() async {
|
||||
final Device device = await devices.workingDevice;
|
||||
if (device.deviceId == 'FAKE_SUCCESS') {
|
||||
return TaskResult.success(<String, dynamic>{
|
||||
'metric1': 42,
|
||||
'metric2': 123,
|
||||
'not_a_metric': 'something',
|
||||
}, benchmarkScoreKeys: <String>[
|
||||
'metric1',
|
||||
'metric2',
|
||||
]);
|
||||
return TaskResult.success(
|
||||
<String, dynamic>{'metric1': 42, 'metric2': 123, 'not_a_metric': 'something'},
|
||||
benchmarkScoreKeys: <String>['metric1', 'metric2'],
|
||||
);
|
||||
} else {
|
||||
return TaskResult.failure('Failed');
|
||||
}
|
||||
|
||||
@@ -8,13 +8,9 @@ import 'package:flutter_devicelab/framework/task_result.dart';
|
||||
/// Smoke test of a successful task.
|
||||
Future<void> main() async {
|
||||
await task(() async {
|
||||
return TaskResult.success(<String, dynamic>{
|
||||
'metric1': 42,
|
||||
'metric2': 123,
|
||||
'not_a_metric': 'something',
|
||||
}, benchmarkScoreKeys: <String>[
|
||||
'metric1',
|
||||
'metric2',
|
||||
]);
|
||||
return TaskResult.success(
|
||||
<String, dynamic>{'metric1': 42, 'metric2': 123, 'not_a_metric': 'something'},
|
||||
benchmarkScoreKeys: <String>['metric1', 'metric2'],
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -16,7 +16,8 @@ import 'package:pubspec_parse/pubspec_parse.dart';
|
||||
const double todoCost = 1009.0; // about two average SWE days, in dollars
|
||||
const double ignoreCost = 2003.0; // four average SWE days, in dollars
|
||||
const double pythonCost = 3001.0; // six average SWE days, in dollars
|
||||
const double skipCost = 2473.0; // 20 hours: 5 to fix the issue we're ignoring, 15 to fix the bugs we missed because the test was off
|
||||
const double skipCost =
|
||||
2473.0; // 20 hours: 5 to fix the issue we're ignoring, 15 to fix the bugs we missed because the test was off
|
||||
const double ignoreForFileCost = 2477.0; // similar thinking as skipCost
|
||||
const double asDynamicCost = 2011.0; // a few days to refactor the code.
|
||||
const double deprecationCost = 233.0; // a few hours to remove the old code.
|
||||
@@ -85,13 +86,15 @@ bool isOptingOutOfNullSafety(String line) {
|
||||
return false;
|
||||
}
|
||||
assert(match.groupCount == 2);
|
||||
return Version(int.parse(match.group(1)!), int.parse(match.group(2)!), 0) < firstNullSafeDartVersion;
|
||||
return Version(int.parse(match.group(1)!), int.parse(match.group(2)!), 0) <
|
||||
firstNullSafeDartVersion;
|
||||
}
|
||||
|
||||
bool packageIsNullSafe(File file) {
|
||||
assert(path.basename(file.path) == 'pubspec.yaml');
|
||||
final Pubspec pubspec = Pubspec.parse(file.readAsStringSync());
|
||||
final VersionConstraint? constraint = pubspec.environment == null ? null : pubspec.environment!['sdk'];
|
||||
final VersionConstraint? constraint =
|
||||
pubspec.environment == null ? null : pubspec.environment!['sdk'];
|
||||
final bool hasConstraint = constraint != null && !constraint.isAny && !constraint.isEmpty;
|
||||
return hasConstraint &&
|
||||
constraint is VersionRange &&
|
||||
@@ -113,13 +116,15 @@ Future<int> findGlobalsForFile(File file) async {
|
||||
}
|
||||
|
||||
Future<double> findCostsForRepo() async {
|
||||
final Process git = await startProcess(
|
||||
'git',
|
||||
<String>['ls-files', '--full-name', flutterDirectory.path],
|
||||
workingDirectory: flutterDirectory.path,
|
||||
);
|
||||
final Process git = await startProcess('git', <String>[
|
||||
'ls-files',
|
||||
'--full-name',
|
||||
flutterDirectory.path,
|
||||
], workingDirectory: flutterDirectory.path);
|
||||
double total = 0.0;
|
||||
await for (final String entry in git.stdout.transform<String>(utf8.decoder).transform<String>(const LineSplitter())) {
|
||||
await for (final String entry in git.stdout
|
||||
.transform<String>(utf8.decoder)
|
||||
.transform<String>(const LineSplitter())) {
|
||||
total += await findCostsForFile(File(path.join(flutterDirectory.path, entry)));
|
||||
}
|
||||
final int gitExitCode = await git.exitCode;
|
||||
@@ -130,13 +135,15 @@ Future<double> findCostsForRepo() async {
|
||||
}
|
||||
|
||||
Future<int> findGlobalsForTool() async {
|
||||
final Process git = await startProcess(
|
||||
'git',
|
||||
<String>['ls-files', '--full-name', path.join(flutterDirectory.path, 'packages', 'flutter_tools')],
|
||||
workingDirectory: flutterDirectory.path,
|
||||
);
|
||||
final Process git = await startProcess('git', <String>[
|
||||
'ls-files',
|
||||
'--full-name',
|
||||
path.join(flutterDirectory.path, 'packages', 'flutter_tools'),
|
||||
], workingDirectory: flutterDirectory.path);
|
||||
int total = 0;
|
||||
await for (final String entry in git.stdout.transform<String>(utf8.decoder).transform<String>(const LineSplitter())) {
|
||||
await for (final String entry in git.stdout
|
||||
.transform<String>(utf8.decoder)
|
||||
.transform<String>(const LineSplitter())) {
|
||||
total += await findGlobalsForFile(File(path.join(flutterDirectory.path, entry)));
|
||||
}
|
||||
final int gitExitCode = await git.exitCode;
|
||||
@@ -153,7 +160,9 @@ Future<int> countDependencies() async {
|
||||
)).split('\n');
|
||||
final int count = lines.where((String line) => line.contains('->')).length;
|
||||
if (count < 2) {
|
||||
throw Exception('"flutter update-packages --transitive-closure" returned bogus output:\n${lines.join("\n")}');
|
||||
throw Exception(
|
||||
'"flutter update-packages --transitive-closure" returned bogus output:\n${lines.join("\n")}',
|
||||
);
|
||||
}
|
||||
return count;
|
||||
}
|
||||
@@ -165,7 +174,9 @@ Future<int> countConsumerDependencies() async {
|
||||
)).split('\n');
|
||||
final int count = lines.where((String line) => line.contains('->')).length;
|
||||
if (count < 2) {
|
||||
throw Exception('"flutter update-packages --transitive-closure" returned bogus output:\n${lines.join("\n")}');
|
||||
throw Exception(
|
||||
'"flutter update-packages --transitive-closure" returned bogus output:\n${lines.join("\n")}',
|
||||
);
|
||||
}
|
||||
return count;
|
||||
}
|
||||
|
||||
@@ -8,9 +8,6 @@ import 'package:flutter_devicelab/tasks/web_benchmarks.dart';
|
||||
/// Runs all Web benchmarks using the CanvasKit rendering backend.
|
||||
Future<void> main() async {
|
||||
await task(() async {
|
||||
return runWebBenchmark((
|
||||
useWasm: false,
|
||||
forceSingleThreadedSkwasm: false,
|
||||
));
|
||||
return runWebBenchmark((useWasm: false, forceSingleThreadedSkwasm: false));
|
||||
});
|
||||
}
|
||||
|
||||
@@ -8,9 +8,6 @@ import 'package:flutter_devicelab/tasks/web_benchmarks.dart';
|
||||
/// Runs all Web benchmarks using the Skwasm rendering backend.
|
||||
Future<void> main() async {
|
||||
await task(() async {
|
||||
return runWebBenchmark((
|
||||
useWasm: true,
|
||||
forceSingleThreadedSkwasm: false,
|
||||
));
|
||||
return runWebBenchmark((useWasm: true, forceSingleThreadedSkwasm: false));
|
||||
});
|
||||
}
|
||||
|
||||
@@ -8,9 +8,6 @@ import 'package:flutter_devicelab/tasks/web_benchmarks.dart';
|
||||
/// Runs all Web benchmarks using the Skwasm rendering backend.
|
||||
Future<void> main() async {
|
||||
await task(() async {
|
||||
return runWebBenchmark((
|
||||
useWasm: true,
|
||||
forceSingleThreadedSkwasm: true,
|
||||
));
|
||||
return runWebBenchmark((useWasm: true, forceSingleThreadedSkwasm: true));
|
||||
});
|
||||
}
|
||||
|
||||
@@ -6,5 +6,5 @@ import 'package:flutter_devicelab/framework/framework.dart';
|
||||
import 'package:flutter_devicelab/tasks/perf_tests.dart';
|
||||
|
||||
Future<void> main() async {
|
||||
await task(createWebCompileTest());
|
||||
await task(createWebCompileTest());
|
||||
}
|
||||
|
||||
@@ -16,10 +16,12 @@ final CommandRunner<void> runner =
|
||||
..addCommand(UploadResultsCommand());
|
||||
|
||||
Future<void> main(List<String> rawArgs) async {
|
||||
unawaited(runner.run(rawArgs).catchError((dynamic error) {
|
||||
stderr.writeln('$error\n');
|
||||
stderr.writeln('Usage:\n');
|
||||
stderr.writeln(runner.usage);
|
||||
exit(64); // Exit code 64 indicates a usage error.
|
||||
}));
|
||||
unawaited(
|
||||
runner.run(rawArgs).catchError((dynamic error) {
|
||||
stderr.writeln('$error\n');
|
||||
stderr.writeln('Usage:\n');
|
||||
stderr.writeln(runner.usage);
|
||||
exit(64); // Exit code 64 indicates a usage error.
|
||||
}),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -8,17 +8,24 @@ import '../framework/runner.dart';
|
||||
|
||||
class TestCommand extends Command<void> {
|
||||
TestCommand() {
|
||||
argParser.addOption('task',
|
||||
abbr: 't',
|
||||
help: 'The name of a task listed under bin/tasks.\n'
|
||||
' Example: complex_layout__start_up.\n');
|
||||
argParser.addMultiOption('task-args',
|
||||
help: 'List of arguments to pass to the task.\n'
|
||||
'For example, "--task-args build" is passed as "bin/task/task.dart --build"');
|
||||
argParser.addOption(
|
||||
'task',
|
||||
abbr: 't',
|
||||
help:
|
||||
'The name of a task listed under bin/tasks.\n'
|
||||
' Example: complex_layout__start_up.\n',
|
||||
);
|
||||
argParser.addMultiOption(
|
||||
'task-args',
|
||||
help:
|
||||
'List of arguments to pass to the task.\n'
|
||||
'For example, "--task-args build" is passed as "bin/task/task.dart --build"',
|
||||
);
|
||||
argParser.addOption(
|
||||
'device-id',
|
||||
abbr: 'd',
|
||||
help: 'Target device id (prefixes are allowed, names are not supported).\n'
|
||||
help:
|
||||
'Target device id (prefixes are allowed, names are not supported).\n'
|
||||
'The option will be ignored if the test target does not run on a\n'
|
||||
'mobile device. This still respects the device operating system\n'
|
||||
'settings in the test case, and will results in error if no device\n'
|
||||
@@ -26,17 +33,20 @@ class TestCommand extends Command<void> {
|
||||
);
|
||||
argParser.addFlag(
|
||||
'exit',
|
||||
help: 'Exit on the first test failure. Currently flakes are intentionally (though '
|
||||
'incorrectly) not considered to be failures.',
|
||||
help:
|
||||
'Exit on the first test failure. Currently flakes are intentionally (though '
|
||||
'incorrectly) not considered to be failures.',
|
||||
);
|
||||
argParser.addOption(
|
||||
'git-branch',
|
||||
help: '[Flutter infrastructure] Git branch of the current commit. LUCI\n'
|
||||
help:
|
||||
'[Flutter infrastructure] Git branch of the current commit. LUCI\n'
|
||||
'checkouts run in detached HEAD state, so the branch must be passed.',
|
||||
);
|
||||
argParser.addOption(
|
||||
'local-engine',
|
||||
help: 'Name of a build output within the engine out directory, if you\n'
|
||||
help:
|
||||
'Name of a build output within the engine out directory, if you\n'
|
||||
'are building Flutter locally. Use this to select a specific\n'
|
||||
'version of the engine if you have built multiple engine targets.\n'
|
||||
'This path is relative to --local-engine-src-path/out. This option\n'
|
||||
@@ -44,7 +54,8 @@ class TestCommand extends Command<void> {
|
||||
);
|
||||
argParser.addOption(
|
||||
'local-engine-host',
|
||||
help: 'Name of a build output within the engine out directory, if you\n'
|
||||
help:
|
||||
'Name of a build output within the engine out directory, if you\n'
|
||||
'are building Flutter locally. Use this to select a specific\n'
|
||||
'version of the engine to use as the host platform if you have built '
|
||||
'multiple engine targets.\n'
|
||||
@@ -53,22 +64,26 @@ class TestCommand extends Command<void> {
|
||||
);
|
||||
argParser.addOption(
|
||||
'local-engine-src-path',
|
||||
help: 'Path to your engine src directory, if you are building Flutter\n'
|
||||
help:
|
||||
'Path to your engine src directory, if you are building Flutter\n'
|
||||
'locally. Defaults to \$FLUTTER_ENGINE if set, or tries to guess at\n'
|
||||
'the location based on the value of the --flutter-root option.',
|
||||
);
|
||||
argParser.addOption('luci-builder', help: '[Flutter infrastructure] Name of the LUCI builder being run on.');
|
||||
argParser.addOption('results-file',
|
||||
help: '[Flutter infrastructure] File path for test results. If passed with\n'
|
||||
'task, will write test results to the file.');
|
||||
argParser.addOption(
|
||||
'luci-builder',
|
||||
help: '[Flutter infrastructure] Name of the LUCI builder being run on.',
|
||||
);
|
||||
argParser.addOption(
|
||||
'results-file',
|
||||
help:
|
||||
'[Flutter infrastructure] File path for test results. If passed with\n'
|
||||
'task, will write test results to the file.',
|
||||
);
|
||||
argParser.addFlag(
|
||||
'silent',
|
||||
help: 'Suppresses standard output and only print standard error output.',
|
||||
);
|
||||
argParser.addFlag(
|
||||
'use-emulator',
|
||||
help: 'Use an emulator instead of a device to run tests.'
|
||||
);
|
||||
argParser.addFlag('use-emulator', help: 'Use an emulator instead of a device to run tests.');
|
||||
}
|
||||
|
||||
@override
|
||||
|
||||
@@ -14,18 +14,34 @@ class UploadResultsCommand extends Command<void> {
|
||||
'service-account-token-file',
|
||||
help: 'Authentication token for uploading results.',
|
||||
);
|
||||
argParser.addOption('test-flaky', help: 'Flag to show whether the test is flaky: "True" or "False"');
|
||||
argParser.addOption(
|
||||
'test-flaky',
|
||||
help: 'Flag to show whether the test is flaky: "True" or "False"',
|
||||
);
|
||||
argParser.addOption(
|
||||
'git-branch',
|
||||
help: '[Flutter infrastructure] Git branch of the current commit. LUCI\n'
|
||||
help:
|
||||
'[Flutter infrastructure] Git branch of the current commit. LUCI\n'
|
||||
'checkouts run in detached HEAD state, so the branch must be passed.',
|
||||
);
|
||||
argParser.addOption('luci-builder', help: '[Flutter infrastructure] Name of the LUCI builder being run on.');
|
||||
argParser.addOption('task-name', help: '[Flutter infrastructure] Name of the task being run on.');
|
||||
argParser.addOption('benchmark-tags', help: '[Flutter infrastructure] Benchmark tags to surface on Skia Perf');
|
||||
argParser.addOption(
|
||||
'luci-builder',
|
||||
help: '[Flutter infrastructure] Name of the LUCI builder being run on.',
|
||||
);
|
||||
argParser.addOption(
|
||||
'task-name',
|
||||
help: '[Flutter infrastructure] Name of the task being run on.',
|
||||
);
|
||||
argParser.addOption(
|
||||
'benchmark-tags',
|
||||
help: '[Flutter infrastructure] Benchmark tags to surface on Skia Perf',
|
||||
);
|
||||
argParser.addOption('test-status', help: 'Test status: Succeeded|Failed');
|
||||
argParser.addOption('commit-time', help: 'Commit time in UNIX timestamp');
|
||||
argParser.addOption('builder-bucket', help: '[Flutter infrastructure] Luci builder bucket the test is running in.');
|
||||
argParser.addOption(
|
||||
'builder-bucket',
|
||||
help: '[Flutter infrastructure] Luci builder bucket the test is running in.',
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
|
||||
@@ -26,18 +26,18 @@ enum FieldJustification { LEFT, RIGHT, CENTER }
|
||||
/// See [printSummary] for more.
|
||||
class ABTest {
|
||||
ABTest({required this.localEngine, required this.localEngineHost, required this.taskName})
|
||||
: runStart = DateTime.now(),
|
||||
_aResults = <String, List<double>>{},
|
||||
_bResults = <String, List<double>>{};
|
||||
: runStart = DateTime.now(),
|
||||
_aResults = <String, List<double>>{},
|
||||
_bResults = <String, List<double>>{};
|
||||
|
||||
ABTest.fromJsonMap(Map<String, dynamic> jsonResults)
|
||||
: localEngine = jsonResults[kLocalEngineKeyName] as String,
|
||||
localEngineHost = jsonResults[kLocalEngineHostKeyName] as String?,
|
||||
taskName = jsonResults[kTaskNameKeyName] as String,
|
||||
runStart = DateTime.parse(jsonResults[kRunStartKeyName] as String),
|
||||
_runEnd = DateTime.parse(jsonResults[kRunEndKeyName] as String),
|
||||
_aResults = _convertFrom(jsonResults[kAResultsKeyName] as Map<String, dynamic>),
|
||||
_bResults = _convertFrom(jsonResults[kBResultsKeyName] as Map<String, dynamic>);
|
||||
: localEngine = jsonResults[kLocalEngineKeyName] as String,
|
||||
localEngineHost = jsonResults[kLocalEngineHostKeyName] as String?,
|
||||
taskName = jsonResults[kTaskNameKeyName] as String,
|
||||
runStart = DateTime.parse(jsonResults[kRunStartKeyName] as String),
|
||||
_runEnd = DateTime.parse(jsonResults[kRunEndKeyName] as String),
|
||||
_aResults = _convertFrom(jsonResults[kAResultsKeyName] as Map<String, dynamic>),
|
||||
_bResults = _convertFrom(jsonResults[kBResultsKeyName] as Map<String, dynamic>);
|
||||
|
||||
final String localEngine;
|
||||
final String? localEngineHost;
|
||||
@@ -51,7 +51,7 @@ class ABTest {
|
||||
|
||||
static Map<String, List<double>> _convertFrom(dynamic results) {
|
||||
final Map<String, dynamic> resultMap = results as Map<String, dynamic>;
|
||||
return <String, List<double>> {
|
||||
return <String, List<double>>{
|
||||
for (final String key in resultMap.keys)
|
||||
key: (resultMap[key] as List<dynamic>).cast<double>(),
|
||||
};
|
||||
@@ -86,16 +86,15 @@ class ABTest {
|
||||
}
|
||||
|
||||
Map<String, dynamic> get jsonMap => <String, dynamic>{
|
||||
kBenchmarkTypeKeyName: kBenchmarkResultsType,
|
||||
kBenchmarkVersionKeyName: kBenchmarkABVersion,
|
||||
kLocalEngineKeyName: localEngine,
|
||||
if (localEngineHost != null)
|
||||
kLocalEngineHostKeyName: localEngineHost,
|
||||
kTaskNameKeyName: taskName,
|
||||
kRunStartKeyName: runStart.toIso8601String(),
|
||||
kRunEndKeyName: runEnd!.toIso8601String(),
|
||||
kAResultsKeyName: _aResults,
|
||||
kBResultsKeyName: _bResults,
|
||||
kBenchmarkTypeKeyName: kBenchmarkResultsType,
|
||||
kBenchmarkVersionKeyName: kBenchmarkABVersion,
|
||||
kLocalEngineKeyName: localEngine,
|
||||
if (localEngineHost != null) kLocalEngineHostKeyName: localEngineHost,
|
||||
kTaskNameKeyName: taskName,
|
||||
kRunStartKeyName: runStart.toIso8601String(),
|
||||
kRunEndKeyName: runEnd!.toIso8601String(),
|
||||
kAResultsKeyName: _aResults,
|
||||
kBResultsKeyName: _bResults,
|
||||
};
|
||||
|
||||
static void updateColumnLengths(List<int> lengths, List<String?> results) {
|
||||
@@ -106,10 +105,12 @@ class ABTest {
|
||||
}
|
||||
}
|
||||
|
||||
static void formatResult(StringBuffer buffer,
|
||||
List<int> lengths,
|
||||
List<FieldJustification> aligns,
|
||||
List<String?> values) {
|
||||
static void formatResult(
|
||||
StringBuffer buffer,
|
||||
List<int> lengths,
|
||||
List<FieldJustification> aligns,
|
||||
List<String?> values,
|
||||
) {
|
||||
for (int column = 0; column < lengths.length; column++) {
|
||||
final int len = lengths[column];
|
||||
String? value = values[column];
|
||||
@@ -117,13 +118,13 @@ class ABTest {
|
||||
value = ''.padRight(len);
|
||||
} else {
|
||||
value = switch (aligns[column]) {
|
||||
FieldJustification.LEFT => value.padRight(len),
|
||||
FieldJustification.RIGHT => value.padLeft(len),
|
||||
FieldJustification.LEFT => value.padRight(len),
|
||||
FieldJustification.RIGHT => value.padLeft(len),
|
||||
FieldJustification.CENTER => value.padLeft((len + value.length) ~/ 2).padRight(len),
|
||||
};
|
||||
}
|
||||
if (column > 0) {
|
||||
value = value.padLeft(len+1);
|
||||
value = value.padLeft(len + 1);
|
||||
}
|
||||
buffer.write(value);
|
||||
}
|
||||
@@ -141,22 +142,28 @@ class ABTest {
|
||||
for (final String scoreKey in <String>{...summariesA.keys, ...summariesB.keys})
|
||||
<String?>[
|
||||
scoreKey,
|
||||
summariesA[scoreKey]?.averageString, summariesA[scoreKey]?.noiseString,
|
||||
summariesB[scoreKey]?.averageString, summariesB[scoreKey]?.noiseString,
|
||||
summariesA[scoreKey]?.averageString,
|
||||
summariesA[scoreKey]?.noiseString,
|
||||
summariesB[scoreKey]?.averageString,
|
||||
summariesB[scoreKey]?.noiseString,
|
||||
summariesA[scoreKey]?.improvementOver(summariesB[scoreKey]),
|
||||
],
|
||||
];
|
||||
|
||||
final List<String> titles = <String>[
|
||||
'Score',
|
||||
'Average A', '(noise)',
|
||||
'Average B', '(noise)',
|
||||
'Average A',
|
||||
'(noise)',
|
||||
'Average B',
|
||||
'(noise)',
|
||||
'Speed-up',
|
||||
];
|
||||
final List<FieldJustification> alignments = <FieldJustification>[
|
||||
FieldJustification.LEFT,
|
||||
FieldJustification.RIGHT, FieldJustification.LEFT,
|
||||
FieldJustification.RIGHT, FieldJustification.LEFT,
|
||||
FieldJustification.RIGHT,
|
||||
FieldJustification.LEFT,
|
||||
FieldJustification.RIGHT,
|
||||
FieldJustification.LEFT,
|
||||
FieldJustification.CENTER,
|
||||
];
|
||||
|
||||
@@ -167,11 +174,10 @@ class ABTest {
|
||||
}
|
||||
|
||||
final StringBuffer buffer = StringBuffer();
|
||||
formatResult(buffer, lengths,
|
||||
<FieldJustification>[
|
||||
FieldJustification.CENTER,
|
||||
...alignments.skip(1),
|
||||
], titles);
|
||||
formatResult(buffer, lengths, <FieldJustification>[
|
||||
FieldJustification.CENTER,
|
||||
...alignments.skip(1),
|
||||
], titles);
|
||||
for (final List<String?> row in tableRows) {
|
||||
formatResult(buffer, lengths, alignments, row);
|
||||
}
|
||||
@@ -208,10 +214,7 @@ class ABTest {
|
||||
return buffer.toString();
|
||||
}
|
||||
|
||||
Set<String> get _allScoreKeys => <String>{
|
||||
..._aResults.keys,
|
||||
..._bResults.keys,
|
||||
};
|
||||
Set<String> get _allScoreKeys => <String>{..._aResults.keys, ..._bResults.keys};
|
||||
|
||||
/// Returns the summary as a tab-separated spreadsheet.
|
||||
///
|
||||
@@ -253,10 +256,7 @@ class ABTest {
|
||||
}
|
||||
|
||||
class _ScoreSummary {
|
||||
_ScoreSummary({
|
||||
required this.average,
|
||||
required this.noise,
|
||||
});
|
||||
_ScoreSummary({required this.average, required this.noise});
|
||||
|
||||
/// Average (arithmetic mean) of a series of values collected by a benchmark.
|
||||
final double average;
|
||||
@@ -283,13 +283,14 @@ void _addResult(TaskResult result, Map<String, List<double>> results) {
|
||||
Map<String, _ScoreSummary> _summarize(Map<String, List<double>> results) {
|
||||
return results.map<String, _ScoreSummary>((String scoreKey, List<double> values) {
|
||||
final double average = _computeAverage(values);
|
||||
return MapEntry<String, _ScoreSummary>(scoreKey, _ScoreSummary(
|
||||
average: average,
|
||||
// If the average is zero, the benchmark got the perfect score with no noise.
|
||||
noise: average > 0
|
||||
? _computeStandardDeviationForPopulation(values) / average
|
||||
: 0.0,
|
||||
));
|
||||
return MapEntry<String, _ScoreSummary>(
|
||||
scoreKey,
|
||||
_ScoreSummary(
|
||||
average: average,
|
||||
// If the average is zero, the benchmark got the perfect score with no noise.
|
||||
noise: average > 0 ? _computeStandardDeviationForPopulation(values) / average : 0.0,
|
||||
),
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -22,14 +22,13 @@ final List<String> debugAssets = <String>[
|
||||
'assets/flutter_assets/vm_snapshot_data',
|
||||
];
|
||||
|
||||
final List<String> baseApkFiles = <String> [
|
||||
'classes.dex',
|
||||
'AndroidManifest.xml',
|
||||
];
|
||||
final List<String> baseApkFiles = <String>['classes.dex', 'AndroidManifest.xml'];
|
||||
|
||||
/// Runs the given [testFunction] on a freshly generated Flutter project.
|
||||
Future<void> runProjectTest(Future<void> Function(FlutterProject project) testFunction) async {
|
||||
final Directory tempDir = Directory.systemTemp.createTempSync('flutter_devicelab_gradle_plugin_test.');
|
||||
final Directory tempDir = Directory.systemTemp.createTempSync(
|
||||
'flutter_devicelab_gradle_plugin_test.',
|
||||
);
|
||||
final FlutterProject project = await FlutterProject.create(tempDir, 'hello');
|
||||
|
||||
try {
|
||||
@@ -40,8 +39,12 @@ Future<void> runProjectTest(Future<void> Function(FlutterProject project) testFu
|
||||
}
|
||||
|
||||
/// Runs the given [testFunction] on a freshly generated Flutter plugin project.
|
||||
Future<void> runPluginProjectTest(Future<void> Function(FlutterPluginProject pluginProject) testFunction) async {
|
||||
final Directory tempDir = Directory.systemTemp.createTempSync('flutter_devicelab_gradle_plugin_test.');
|
||||
Future<void> runPluginProjectTest(
|
||||
Future<void> Function(FlutterPluginProject pluginProject) testFunction,
|
||||
) async {
|
||||
final Directory tempDir = Directory.systemTemp.createTempSync(
|
||||
'flutter_devicelab_gradle_plugin_test.',
|
||||
);
|
||||
final FlutterPluginProject pluginProject = await FlutterPluginProject.create(tempDir, 'aaa');
|
||||
|
||||
try {
|
||||
@@ -52,9 +55,16 @@ Future<void> runPluginProjectTest(Future<void> Function(FlutterPluginProject plu
|
||||
}
|
||||
|
||||
/// Runs the given [testFunction] on a freshly generated Flutter module project.
|
||||
Future<void> runModuleProjectTest(Future<void> Function(FlutterModuleProject moduleProject) testFunction) async {
|
||||
final Directory tempDir = Directory.systemTemp.createTempSync('flutter_devicelab_gradle_module_test.');
|
||||
final FlutterModuleProject moduleProject = await FlutterModuleProject.create(tempDir, 'hello_module');
|
||||
Future<void> runModuleProjectTest(
|
||||
Future<void> Function(FlutterModuleProject moduleProject) testFunction,
|
||||
) async {
|
||||
final Directory tempDir = Directory.systemTemp.createTempSync(
|
||||
'flutter_devicelab_gradle_module_test.',
|
||||
);
|
||||
final FlutterModuleProject moduleProject = await FlutterModuleProject.create(
|
||||
tempDir,
|
||||
'hello_module',
|
||||
);
|
||||
|
||||
try {
|
||||
await testFunction(moduleProject);
|
||||
@@ -66,18 +76,12 @@ Future<void> runModuleProjectTest(Future<void> Function(FlutterModuleProject mod
|
||||
/// Returns the list of files inside an Android Package Kit.
|
||||
Future<Iterable<String>> getFilesInApk(String apk) async {
|
||||
if (!File(apk).existsSync()) {
|
||||
throw TaskResult.failure(
|
||||
'Gradle did not produce an output artifact file at: $apk');
|
||||
throw TaskResult.failure('Gradle did not produce an output artifact file at: $apk');
|
||||
}
|
||||
final String files = await _evalApkAnalyzer(
|
||||
<String>[
|
||||
'files',
|
||||
'list',
|
||||
apk,
|
||||
]
|
||||
);
|
||||
final String files = await _evalApkAnalyzer(<String>['files', 'list', apk]);
|
||||
return files.split('\n').map((String file) => file.substring(1).trim());
|
||||
}
|
||||
|
||||
/// Returns the list of files inside an Android App Bundle.
|
||||
Future<Iterable<String>> getFilesInAppBundle(String bundle) {
|
||||
return getFilesInApk(bundle);
|
||||
@@ -102,8 +106,8 @@ bool hasMultipleOccurrences(String text, Pattern pattern) {
|
||||
|
||||
/// The Android home directory.
|
||||
String get _androidHome {
|
||||
final String? androidHome = Platform.environment['ANDROID_HOME'] ??
|
||||
Platform.environment['ANDROID_SDK_ROOT'];
|
||||
final String? androidHome =
|
||||
Platform.environment['ANDROID_HOME'] ?? Platform.environment['ANDROID_SDK_ROOT'];
|
||||
if (androidHome == null || androidHome.isEmpty) {
|
||||
throw Exception('Environment variable `ANDROID_HOME` is not set.');
|
||||
}
|
||||
@@ -120,19 +124,22 @@ Future<String> _evalApkAnalyzer(
|
||||
if (javaHome == null || javaHome.isEmpty) {
|
||||
throw Exception('No JAVA_HOME set.');
|
||||
}
|
||||
final String apkAnalyzer = path
|
||||
.join(_androidHome, 'cmdline-tools', 'latest', 'bin', Platform.isWindows ? 'apkanalyzer.bat' : 'apkanalyzer');
|
||||
if (canRun(apkAnalyzer)) {
|
||||
return eval(
|
||||
apkAnalyzer,
|
||||
args,
|
||||
printStdout: printStdout,
|
||||
workingDirectory: workingDirectory,
|
||||
environment: <String, String>{
|
||||
'JAVA_HOME': javaHome,
|
||||
},
|
||||
);
|
||||
}
|
||||
final String apkAnalyzer = path.join(
|
||||
_androidHome,
|
||||
'cmdline-tools',
|
||||
'latest',
|
||||
'bin',
|
||||
Platform.isWindows ? 'apkanalyzer.bat' : 'apkanalyzer',
|
||||
);
|
||||
if (canRun(apkAnalyzer)) {
|
||||
return eval(
|
||||
apkAnalyzer,
|
||||
args,
|
||||
printStdout: printStdout,
|
||||
workingDirectory: workingDirectory,
|
||||
environment: <String, String>{'JAVA_HOME': javaHome},
|
||||
);
|
||||
}
|
||||
|
||||
final String javaBinary = path.join(javaHome, 'bin', 'java');
|
||||
assert(canRun(javaBinary));
|
||||
@@ -140,7 +147,7 @@ Future<String> _evalApkAnalyzer(
|
||||
final String libs = path.join(androidTools, 'lib');
|
||||
assert(Directory(libs).existsSync());
|
||||
|
||||
final String classSeparator = Platform.isWindows ? ';' : ':';
|
||||
final String classSeparator = Platform.isWindows ? ';' : ':';
|
||||
return eval(
|
||||
javaBinary,
|
||||
<String>[
|
||||
@@ -171,22 +178,18 @@ class ApkExtractor {
|
||||
if (_extracted) {
|
||||
return;
|
||||
}
|
||||
final String packages = await _evalApkAnalyzer(
|
||||
<String>[
|
||||
'dex',
|
||||
'packages',
|
||||
apkFile.path,
|
||||
],
|
||||
);
|
||||
final String packages = await _evalApkAnalyzer(<String>['dex', 'packages', apkFile.path]);
|
||||
final List<String> lines = packages.split('\n');
|
||||
_classes = Set<String>.from(
|
||||
lines.where((String line) => line.startsWith('C'))
|
||||
.map<String>((String line) => line.split('\t').last),
|
||||
lines
|
||||
.where((String line) => line.startsWith('C'))
|
||||
.map<String>((String line) => line.split('\t').last),
|
||||
);
|
||||
assert(_classes.isNotEmpty);
|
||||
_methods = Set<String>.from(
|
||||
lines.where((String line) => line.startsWith('M'))
|
||||
.map<String>((String line) => line.split('\t').last)
|
||||
lines
|
||||
.where((String line) => line.startsWith('M'))
|
||||
.map<String>((String line) => line.split('\t').last),
|
||||
);
|
||||
assert(_methods.isNotEmpty);
|
||||
_extracted = true;
|
||||
@@ -219,14 +222,7 @@ class ApkExtractor {
|
||||
|
||||
/// Gets the content of the `AndroidManifest.xml`.
|
||||
Future<String> getAndroidManifest(String apk) async {
|
||||
return _evalApkAnalyzer(
|
||||
<String>[
|
||||
'manifest',
|
||||
'print',
|
||||
apk,
|
||||
],
|
||||
workingDirectory: _androidHome,
|
||||
);
|
||||
return _evalApkAnalyzer(<String>['manifest', 'print', apk], workingDirectory: _androidHome);
|
||||
}
|
||||
|
||||
/// Checks that the [apk] includes any classes from a particularly library with
|
||||
@@ -325,14 +321,16 @@ android {
|
||||
Future<void> addProductFlavors(Iterable<String> flavors) async {
|
||||
final File buildScript = appBuildFile;
|
||||
|
||||
final String flavorConfig = flavors.map((String name) {
|
||||
return '''
|
||||
final String flavorConfig = flavors
|
||||
.map((String name) {
|
||||
return '''
|
||||
create("$name") {
|
||||
applicationIdSuffix = ".$name"
|
||||
versionNameSuffix = "-$name"
|
||||
}
|
||||
''';
|
||||
}).join('\n');
|
||||
})
|
||||
.join('\n');
|
||||
|
||||
buildScript.openWrite(mode: FileMode.append).write('''
|
||||
android {
|
||||
@@ -346,21 +344,24 @@ android {
|
||||
|
||||
Future<void> introduceError() async {
|
||||
final File buildScript = appBuildFile;
|
||||
await buildScript.writeAsString((await buildScript.readAsString()).replaceAll('buildTypes', 'builTypes'));
|
||||
await buildScript.writeAsString(
|
||||
(await buildScript.readAsString()).replaceAll('buildTypes', 'builTypes'),
|
||||
);
|
||||
}
|
||||
|
||||
Future<void> introducePubspecError() async {
|
||||
final File pubspec = File(
|
||||
path.join(parent.path, 'hello', 'pubspec.yaml')
|
||||
);
|
||||
final File pubspec = File(path.join(parent.path, 'hello', 'pubspec.yaml'));
|
||||
final String contents = pubspec.readAsStringSync();
|
||||
final String newContents = contents.replaceFirst('${Platform.lineTerminator}flutter:${Platform.lineTerminator}', '''
|
||||
final String newContents = contents.replaceFirst(
|
||||
'${Platform.lineTerminator}flutter:${Platform.lineTerminator}',
|
||||
'''
|
||||
|
||||
flutter:
|
||||
assets:
|
||||
- lib/gallery/example_code.dart
|
||||
|
||||
''');
|
||||
''',
|
||||
);
|
||||
pubspec.writeAsStringSync(newContents);
|
||||
}
|
||||
|
||||
@@ -387,7 +388,11 @@ class FlutterPluginProject {
|
||||
final Directory parent;
|
||||
final String name;
|
||||
|
||||
static Future<FlutterPluginProject> create(Directory directory, String name, {List<String> options = const <String>['--platforms=ios,android']}) async {
|
||||
static Future<FlutterPluginProject> create(
|
||||
Directory directory,
|
||||
String name, {
|
||||
List<String> options = const <String>['--platforms=ios,android'],
|
||||
}) async {
|
||||
await inDirectory(directory, () async {
|
||||
await flutter('create', options: <String>['--template=plugin', ...options, name]);
|
||||
});
|
||||
@@ -397,11 +402,22 @@ class FlutterPluginProject {
|
||||
String get rootPath => path.join(parent.path, name);
|
||||
String get examplePath => path.join(rootPath, 'example');
|
||||
String get exampleAndroidPath => path.join(examplePath, 'android');
|
||||
String get debugApkPath => path.join(examplePath, 'build', 'app', 'outputs', 'flutter-apk', 'app-debug.apk');
|
||||
String get releaseApkPath => path.join(examplePath, 'build', 'app', 'outputs', 'flutter-apk', 'app-release.apk');
|
||||
String get releaseArmApkPath => path.join(examplePath, 'build', 'app', 'outputs', 'flutter-apk','app-armeabi-v7a-release.apk');
|
||||
String get releaseArm64ApkPath => path.join(examplePath, 'build', 'app', 'outputs', 'flutter-apk', 'app-arm64-v8a-release.apk');
|
||||
String get releaseBundlePath => path.join(examplePath, 'build', 'app', 'outputs', 'bundle', 'release', 'app.aab');
|
||||
String get debugApkPath =>
|
||||
path.join(examplePath, 'build', 'app', 'outputs', 'flutter-apk', 'app-debug.apk');
|
||||
String get releaseApkPath =>
|
||||
path.join(examplePath, 'build', 'app', 'outputs', 'flutter-apk', 'app-release.apk');
|
||||
String get releaseArmApkPath => path.join(
|
||||
examplePath,
|
||||
'build',
|
||||
'app',
|
||||
'outputs',
|
||||
'flutter-apk',
|
||||
'app-armeabi-v7a-release.apk',
|
||||
);
|
||||
String get releaseArm64ApkPath =>
|
||||
path.join(examplePath, 'build', 'app', 'outputs', 'flutter-apk', 'app-arm64-v8a-release.apk');
|
||||
String get releaseBundlePath =>
|
||||
path.join(examplePath, 'build', 'app', 'outputs', 'bundle', 'release', 'app.aab');
|
||||
}
|
||||
|
||||
class FlutterModuleProject {
|
||||
@@ -426,9 +442,10 @@ Future<void> _runGradleTask({
|
||||
List<String>? options,
|
||||
}) async {
|
||||
final ProcessResult result = await _resultOfGradleTask(
|
||||
workingDirectory: workingDirectory,
|
||||
task: task,
|
||||
options: options);
|
||||
workingDirectory: workingDirectory,
|
||||
task: task,
|
||||
options: options,
|
||||
);
|
||||
if (result.exitCode != 0) {
|
||||
print('stdout:');
|
||||
print(result.stdout);
|
||||
@@ -454,44 +471,61 @@ Future<ProcessResult> _resultOfGradleTask({
|
||||
|
||||
print('\nUsing JAVA_HOME=$javaHome');
|
||||
|
||||
final List<String> args = <String>[
|
||||
'app:$task',
|
||||
...?options,
|
||||
];
|
||||
final String gradle = path.join(workingDirectory, Platform.isWindows ? 'gradlew.bat' : './gradlew');
|
||||
final List<String> args = <String>['app:$task', ...?options];
|
||||
final String gradle = path.join(
|
||||
workingDirectory,
|
||||
Platform.isWindows ? 'gradlew.bat' : './gradlew',
|
||||
);
|
||||
print('┌── $gradle');
|
||||
print(File(path.join(workingDirectory, gradle)).readAsLinesSync().map((String line) => '| $line').join('\n'));
|
||||
print(
|
||||
File(
|
||||
path.join(workingDirectory, gradle),
|
||||
).readAsLinesSync().map((String line) => '| $line').join('\n'),
|
||||
);
|
||||
print('└─────────────────────────────────────────────────────────────────────────────────────');
|
||||
print(
|
||||
'Running Gradle:\n'
|
||||
' Executable: $gradle\n'
|
||||
' Arguments: ${args.join(' ')}\n'
|
||||
' Working directory: $workingDirectory\n'
|
||||
' JAVA_HOME: $javaHome\n'
|
||||
' JAVA_HOME: $javaHome\n',
|
||||
);
|
||||
return Process.run(
|
||||
gradle,
|
||||
args,
|
||||
workingDirectory: workingDirectory,
|
||||
environment: <String, String>{ 'JAVA_HOME': javaHome },
|
||||
environment: <String, String>{'JAVA_HOME': javaHome},
|
||||
);
|
||||
}
|
||||
|
||||
/// Returns [null] if target matches [expectedTarget], otherwise returns an error message.
|
||||
String? validateSnapshotDependency(FlutterProject project, String expectedTarget) {
|
||||
final File snapshotBlob = File(
|
||||
path.join(project.rootPath, 'build', 'app', 'intermediates',
|
||||
'flutter', 'debug', 'flutter_build.d'));
|
||||
path.join(
|
||||
project.rootPath,
|
||||
'build',
|
||||
'app',
|
||||
'intermediates',
|
||||
'flutter',
|
||||
'debug',
|
||||
'flutter_build.d',
|
||||
),
|
||||
);
|
||||
|
||||
assert(snapshotBlob.existsSync());
|
||||
final String contentSnapshot = snapshotBlob.readAsStringSync();
|
||||
return contentSnapshot.contains('$expectedTarget ')
|
||||
? null : 'Dependency file should have $expectedTarget as target. Instead found $contentSnapshot';
|
||||
? null
|
||||
: 'Dependency file should have $expectedTarget as target. Instead found $contentSnapshot';
|
||||
}
|
||||
|
||||
File getAndroidBuildFile(String androidAppPath, {bool settings = false}) {
|
||||
final File groovyFile = File(path.join(androidAppPath, settings ? 'settings.gradle' : 'build.gradle'));
|
||||
final File kotlinFile = File(path.join(androidAppPath, settings ? 'settings.gradle.kts' : 'build.gradle.kts'));
|
||||
final File groovyFile = File(
|
||||
path.join(androidAppPath, settings ? 'settings.gradle' : 'build.gradle'),
|
||||
);
|
||||
final File kotlinFile = File(
|
||||
path.join(androidAppPath, settings ? 'settings.gradle.kts' : 'build.gradle.kts'),
|
||||
);
|
||||
|
||||
if (groovyFile.existsSync()) {
|
||||
return groovyFile;
|
||||
|
||||
@@ -79,30 +79,32 @@ class Chrome {
|
||||
/// The [onError] callback is called with an error message when the Chrome
|
||||
/// process encounters an error. In particular, [onError] is called when the
|
||||
/// Chrome process exits prematurely, i.e. before [stop] is called.
|
||||
static Future<Chrome> launch(ChromeOptions options, { String? workingDirectory, required ChromeErrorCallback onError }) async {
|
||||
static Future<Chrome> launch(
|
||||
ChromeOptions options, {
|
||||
String? workingDirectory,
|
||||
required ChromeErrorCallback onError,
|
||||
}) async {
|
||||
if (!io.Platform.isWindows) {
|
||||
final io.ProcessResult versionResult = io.Process.runSync(_findSystemChromeExecutable(), const <String>['--version']);
|
||||
final io.ProcessResult versionResult = io.Process.runSync(
|
||||
_findSystemChromeExecutable(),
|
||||
const <String>['--version'],
|
||||
);
|
||||
print('Launching ${versionResult.stdout}');
|
||||
} else {
|
||||
print('Launching Chrome...');
|
||||
}
|
||||
|
||||
final String jsFlags = options.enableWasmGC ? <String>[
|
||||
'--experimental-wasm-gc',
|
||||
'--experimental-wasm-type-reflection',
|
||||
].join(' ') : '';
|
||||
final String jsFlags =
|
||||
options.enableWasmGC
|
||||
? <String>['--experimental-wasm-gc', '--experimental-wasm-type-reflection'].join(' ')
|
||||
: '';
|
||||
final bool withDebugging = options.debugPort != null;
|
||||
final List<String> args = <String>[
|
||||
if (options.userDataDirectory != null)
|
||||
'--user-data-dir=${options.userDataDirectory}',
|
||||
if (options.url != null)
|
||||
options.url!,
|
||||
if (io.Platform.environment['CHROME_NO_SANDBOX'] == 'true')
|
||||
'--no-sandbox',
|
||||
if (options.headless ?? false)
|
||||
'--headless',
|
||||
if (withDebugging)
|
||||
'--remote-debugging-port=${options.debugPort}',
|
||||
if (options.userDataDirectory != null) '--user-data-dir=${options.userDataDirectory}',
|
||||
if (options.url != null) options.url!,
|
||||
if (io.Platform.environment['CHROME_NO_SANDBOX'] == 'true') '--no-sandbox',
|
||||
if (options.headless ?? false) '--headless',
|
||||
if (withDebugging) '--remote-debugging-port=${options.debugPort}',
|
||||
'--window-size=${options.windowWidth},${options.windowHeight}',
|
||||
'--disable-extensions',
|
||||
'--disable-popup-blocking',
|
||||
@@ -134,7 +136,7 @@ class Chrome {
|
||||
final WipConnection? _debugConnection;
|
||||
bool _isStopped = false;
|
||||
|
||||
Completer<void> ?_tracingCompleter;
|
||||
Completer<void>? _tracingCompleter;
|
||||
StreamSubscription<WipEvent>? _tracingSubscription;
|
||||
List<Map<String, dynamic>>? _tracingData;
|
||||
|
||||
@@ -148,7 +150,7 @@ class Chrome {
|
||||
if (_tracingCompleter != null) {
|
||||
throw StateError(
|
||||
'Cannot start a new performance trace. A tracing session labeled '
|
||||
'"$label" is already in progress.'
|
||||
'"$label" is already in progress.',
|
||||
);
|
||||
}
|
||||
_tracingCompleter = Completer<void>();
|
||||
@@ -167,10 +169,14 @@ class Chrome {
|
||||
} else if (event.method == 'Tracing.dataCollected') {
|
||||
final dynamic value = event.params?['value'];
|
||||
if (value is! List) {
|
||||
throw FormatException('"Tracing.dataCollected" returned malformed data. '
|
||||
'Expected a List but got: ${value.runtimeType}');
|
||||
throw FormatException(
|
||||
'"Tracing.dataCollected" returned malformed data. '
|
||||
'Expected a List but got: ${value.runtimeType}',
|
||||
);
|
||||
}
|
||||
_tracingData?.addAll((event.params?['value'] as List<dynamic>).cast<Map<String, dynamic>>());
|
||||
_tracingData?.addAll(
|
||||
(event.params?['value'] as List<dynamic>).cast<Map<String, dynamic>>(),
|
||||
);
|
||||
}
|
||||
});
|
||||
await _debugConnection?.sendCommand('Tracing.start', <String, dynamic>{
|
||||
@@ -226,8 +232,7 @@ String _findSystemChromeExecutable() {
|
||||
}
|
||||
|
||||
if (io.Platform.isLinux) {
|
||||
final io.ProcessResult which =
|
||||
io.Process.runSync('which', <String>['google-chrome']);
|
||||
final io.ProcessResult which = io.Process.runSync('which', <String>['google-chrome']);
|
||||
|
||||
if (which.exitCode != 0) {
|
||||
throw Exception('Failed to locate system Chrome installation.');
|
||||
@@ -238,11 +243,12 @@ String _findSystemChromeExecutable() {
|
||||
return '/Applications/Google Chrome.app/Contents/MacOS/Google Chrome';
|
||||
} else if (io.Platform.isWindows) {
|
||||
const String kWindowsExecutable = r'Google\Chrome\Application\chrome.exe';
|
||||
final List<String> kWindowsPrefixes = <String?>[
|
||||
io.Platform.environment['LOCALAPPDATA'],
|
||||
io.Platform.environment['PROGRAMFILES'],
|
||||
io.Platform.environment['PROGRAMFILES(X86)'],
|
||||
].whereType<String>().toList();
|
||||
final List<String> kWindowsPrefixes =
|
||||
<String?>[
|
||||
io.Platform.environment['LOCALAPPDATA'],
|
||||
io.Platform.environment['PROGRAMFILES'],
|
||||
io.Platform.environment['PROGRAMFILES(X86)'],
|
||||
].whereType<String>().toList();
|
||||
final String windowsPrefix = kWindowsPrefixes.firstWhere((String prefix) {
|
||||
final String expectedPath = path.join(prefix, kWindowsExecutable);
|
||||
return io.File(expectedPath).existsSync();
|
||||
@@ -272,7 +278,8 @@ Future<Uri> _getRemoteDebuggerUrl(Uri base) async {
|
||||
final io.HttpClient client = io.HttpClient();
|
||||
final io.HttpClientRequest request = await client.getUrl(base.resolve('/json/list'));
|
||||
final io.HttpClientResponse response = await request.close();
|
||||
final List<dynamic>? jsonObject = await json.fuse(utf8).decoder.bind(response).single as List<dynamic>?;
|
||||
final List<dynamic>? jsonObject =
|
||||
await json.fuse(utf8).decoder.bind(response).single as List<dynamic>?;
|
||||
if (jsonObject == null || jsonObject.isEmpty) {
|
||||
return base;
|
||||
}
|
||||
@@ -289,10 +296,9 @@ class BlinkTraceSummary {
|
||||
static BlinkTraceSummary? fromJson(List<Map<String, dynamic>> traceJson) {
|
||||
try {
|
||||
// Convert raw JSON data to BlinkTraceEvent objects sorted by timestamp.
|
||||
List<BlinkTraceEvent> events = traceJson
|
||||
.map<BlinkTraceEvent>(BlinkTraceEvent.fromJson)
|
||||
.toList()
|
||||
..sort((BlinkTraceEvent a, BlinkTraceEvent b) => a.ts! - b.ts!);
|
||||
List<BlinkTraceEvent> events =
|
||||
traceJson.map<BlinkTraceEvent>(BlinkTraceEvent.fromJson).toList()
|
||||
..sort((BlinkTraceEvent a, BlinkTraceEvent b) => a.ts! - b.ts!);
|
||||
|
||||
Exception noMeasuredFramesFound() => Exception(
|
||||
'No measured frames found in benchmark tracing data. This likely '
|
||||
@@ -349,12 +355,21 @@ class BlinkTraceSummary {
|
||||
|
||||
// Compute averages and summarize.
|
||||
return BlinkTraceSummary._(
|
||||
averageBeginFrameTime: _computeAverageDuration(frames.map((BlinkFrame frame) => frame.beginFrame).whereType<BlinkTraceEvent>().toList()),
|
||||
averageUpdateLifecyclePhasesTime: _computeAverageDuration(frames.map((BlinkFrame frame) => frame.updateAllLifecyclePhases).whereType<BlinkTraceEvent>().toList()),
|
||||
averageBeginFrameTime: _computeAverageDuration(
|
||||
frames.map((BlinkFrame frame) => frame.beginFrame).whereType<BlinkTraceEvent>().toList(),
|
||||
),
|
||||
averageUpdateLifecyclePhasesTime: _computeAverageDuration(
|
||||
frames
|
||||
.map((BlinkFrame frame) => frame.updateAllLifecyclePhases)
|
||||
.whereType<BlinkTraceEvent>()
|
||||
.toList(),
|
||||
),
|
||||
);
|
||||
} catch (_) {
|
||||
final io.File traceFile = io.File('./chrome-trace.json');
|
||||
io.stderr.writeln('Failed to interpret the Chrome trace contents. The trace was saved in ${traceFile.path}');
|
||||
io.stderr.writeln(
|
||||
'Failed to interpret the Chrome trace contents. The trace was saved in ${traceFile.path}',
|
||||
);
|
||||
traceFile.writeAsStringSync(const JsonEncoder.withIndent(' ').convert(traceJson));
|
||||
rethrow;
|
||||
}
|
||||
@@ -381,9 +396,10 @@ class BlinkTraceSummary {
|
||||
final Duration averageTotalUIFrameTime;
|
||||
|
||||
@override
|
||||
String toString() => '$BlinkTraceSummary('
|
||||
'averageBeginFrameTime: ${averageBeginFrameTime.inMicroseconds / 1000}ms, '
|
||||
'averageUpdateLifecyclePhasesTime: ${averageUpdateLifecyclePhasesTime.inMicroseconds / 1000}ms)';
|
||||
String toString() =>
|
||||
'$BlinkTraceSummary('
|
||||
'averageBeginFrameTime: ${averageBeginFrameTime.inMicroseconds / 1000}ms, '
|
||||
'averageUpdateLifecyclePhasesTime: ${averageUpdateLifecyclePhasesTime.inMicroseconds / 1000}ms)';
|
||||
}
|
||||
|
||||
/// Contains events pertaining to a single frame in the Blink trace data.
|
||||
@@ -405,14 +421,15 @@ class BlinkFrame {
|
||||
/// their average as a [Duration] value.
|
||||
Duration _computeAverageDuration(List<BlinkTraceEvent> events) {
|
||||
// Compute the sum of "tdur" fields of the last _kMeasuredSampleCount events.
|
||||
final double sum = events
|
||||
.skip(math.max(events.length - _kMeasuredSampleCount, 0))
|
||||
.fold(0.0, (double previousValue, BlinkTraceEvent event) {
|
||||
if (event.tdur == null) {
|
||||
throw FormatException('Trace event lacks "tdur" field: $event');
|
||||
}
|
||||
return previousValue + event.tdur!;
|
||||
});
|
||||
final double sum = events.skip(math.max(events.length - _kMeasuredSampleCount, 0)).fold(0.0, (
|
||||
double previousValue,
|
||||
BlinkTraceEvent event,
|
||||
) {
|
||||
if (event.tdur == null) {
|
||||
throw FormatException('Trace event lacks "tdur" field: $event');
|
||||
}
|
||||
return previousValue + event.tdur!;
|
||||
});
|
||||
final int sampleCount = math.min(events.length, _kMeasuredSampleCount);
|
||||
return Duration(microseconds: sum ~/ sampleCount);
|
||||
}
|
||||
@@ -447,15 +464,15 @@ class BlinkTraceEvent {
|
||||
///
|
||||
/// https://docs.google.com/document/d/1CvAClvFfyA5R-PhYUmn5OOQtYMH4h6I0nSsKchNAySU/preview
|
||||
BlinkTraceEvent.fromJson(Map<String, dynamic> json)
|
||||
: args = json['args'] as Map<String, dynamic>,
|
||||
cat = json['cat'] as String,
|
||||
name = json['name'] as String,
|
||||
ph = json['ph'] as String,
|
||||
pid = _readInt(json, 'pid'),
|
||||
tid = _readInt(json, 'tid'),
|
||||
ts = _readInt(json, 'ts'),
|
||||
tts = _readInt(json, 'tts'),
|
||||
tdur = _readInt(json, 'tdur');
|
||||
: args = json['args'] as Map<String, dynamic>,
|
||||
cat = json['cat'] as String,
|
||||
name = json['name'] as String,
|
||||
ph = json['ph'] as String,
|
||||
pid = _readInt(json, 'pid'),
|
||||
tid = _readInt(json, 'tid'),
|
||||
ts = _readInt(json, 'ts'),
|
||||
tts = _readInt(json, 'tts'),
|
||||
tdur = _readInt(json, 'tdur');
|
||||
|
||||
/// Event-specific data.
|
||||
final Map<String, dynamic> args;
|
||||
@@ -496,11 +513,10 @@ class BlinkTraceEvent {
|
||||
///
|
||||
/// This event is a duration event that has its `tdur` populated.
|
||||
bool get isBeginFrame {
|
||||
return ph == 'X' && (
|
||||
name == 'WebViewImpl::beginFrame' ||
|
||||
name == 'WebFrameWidgetBase::BeginMainFrame' ||
|
||||
name == 'WebFrameWidgetImpl::BeginMainFrame'
|
||||
);
|
||||
return ph == 'X' &&
|
||||
(name == 'WebViewImpl::beginFrame' ||
|
||||
name == 'WebFrameWidgetBase::BeginMainFrame' ||
|
||||
name == 'WebFrameWidgetImpl::BeginMainFrame');
|
||||
}
|
||||
|
||||
/// An "update all lifecycle phases" event contains UI thread computations
|
||||
@@ -514,10 +530,9 @@ class BlinkTraceEvent {
|
||||
///
|
||||
/// This event is a duration event that has its `tdur` populated.
|
||||
bool get isUpdateAllLifecyclePhases {
|
||||
return ph == 'X' && (
|
||||
name == 'WebViewImpl::updateAllLifecyclePhases' ||
|
||||
name == 'WebFrameWidgetImpl::UpdateLifecycle'
|
||||
);
|
||||
return ph == 'X' &&
|
||||
(name == 'WebViewImpl::updateAllLifecyclePhases' ||
|
||||
name == 'WebFrameWidgetImpl::UpdateLifecycle');
|
||||
}
|
||||
|
||||
/// Whether this is the beginning of a "measured_frame" event.
|
||||
@@ -537,16 +552,17 @@ class BlinkTraceEvent {
|
||||
bool get isEndMeasuredFrame => ph == 'e' && name == 'measured_frame';
|
||||
|
||||
@override
|
||||
String toString() => '$BlinkTraceEvent('
|
||||
'args: ${json.encode(args)}, '
|
||||
'cat: $cat, '
|
||||
'name: $name, '
|
||||
'ph: $ph, '
|
||||
'pid: $pid, '
|
||||
'tid: $tid, '
|
||||
'ts: $ts, '
|
||||
'tts: $tts, '
|
||||
'tdur: $tdur)';
|
||||
String toString() =>
|
||||
'$BlinkTraceEvent('
|
||||
'args: ${json.encode(args)}, '
|
||||
'cat: $cat, '
|
||||
'name: $name, '
|
||||
'ph: $ph, '
|
||||
'pid: $pid, '
|
||||
'tid: $tid, '
|
||||
'ts: $ts, '
|
||||
'tts: $tts, '
|
||||
'tdur: $tdur)';
|
||||
}
|
||||
|
||||
/// Read an integer out of [json] stored under [key].
|
||||
@@ -572,48 +588,56 @@ int? _readInt(Map<String, dynamic> json, String key) {
|
||||
/// Inconsistency detected by ld.so: ../elf/dl-tls.c: 493: _dl_allocate_tls_init: Assertion `listp->slotinfo[cnt].gen <= GL(dl_tls_generation)' failed!
|
||||
const String _kGlibcError = 'Inconsistency detected by ld.so';
|
||||
|
||||
Future<io.Process> _spawnChromiumProcess(String executable, List<String> args, { String? workingDirectory }) async {
|
||||
Future<io.Process> _spawnChromiumProcess(
|
||||
String executable,
|
||||
List<String> args, {
|
||||
String? workingDirectory,
|
||||
}) async {
|
||||
// Keep attempting to launch the browser until one of:
|
||||
// - Chrome launched successfully, in which case we just return from the loop.
|
||||
// - The tool detected an unretryable Chrome error, in which case we throw ToolExit.
|
||||
while (true) {
|
||||
final io.Process process = await io.Process.start(executable, args, workingDirectory: workingDirectory);
|
||||
final io.Process process = await io.Process.start(
|
||||
executable,
|
||||
args,
|
||||
workingDirectory: workingDirectory,
|
||||
);
|
||||
|
||||
process.stdout
|
||||
.transform(utf8.decoder)
|
||||
.transform(const LineSplitter())
|
||||
.listen((String line) {
|
||||
print('[CHROME STDOUT]: $line');
|
||||
});
|
||||
process.stdout.transform(utf8.decoder).transform(const LineSplitter()).listen((String line) {
|
||||
print('[CHROME STDOUT]: $line');
|
||||
});
|
||||
|
||||
// Wait until the DevTools are listening before trying to connect. This is
|
||||
// only required for flutter_test --platform=chrome and not flutter run.
|
||||
bool hitGlibcBug = false;
|
||||
await process.stderr
|
||||
.transform(utf8.decoder)
|
||||
.transform(const LineSplitter())
|
||||
.map((String line) {
|
||||
print('[CHROME STDERR]:$line');
|
||||
if (line.contains(_kGlibcError)) {
|
||||
hitGlibcBug = true;
|
||||
}
|
||||
return line;
|
||||
})
|
||||
.firstWhere((String line) => line.startsWith('DevTools listening'), orElse: () {
|
||||
if (hitGlibcBug) {
|
||||
print(
|
||||
'Encountered glibc bug https://sourceware.org/bugzilla/show_bug.cgi?id=19329. '
|
||||
'Will try launching browser again.',
|
||||
);
|
||||
return '';
|
||||
}
|
||||
print('Failed to launch browser. Command used to launch it: ${args.join(' ')}');
|
||||
throw Exception(
|
||||
'Failed to launch browser. Make sure you are using an up-to-date '
|
||||
'Chrome or Edge. Otherwise, consider using -d web-server instead '
|
||||
'and filing an issue at https://github.com/flutter/flutter/issues.',
|
||||
.transform(utf8.decoder)
|
||||
.transform(const LineSplitter())
|
||||
.map((String line) {
|
||||
print('[CHROME STDERR]:$line');
|
||||
if (line.contains(_kGlibcError)) {
|
||||
hitGlibcBug = true;
|
||||
}
|
||||
return line;
|
||||
})
|
||||
.firstWhere(
|
||||
(String line) => line.startsWith('DevTools listening'),
|
||||
orElse: () {
|
||||
if (hitGlibcBug) {
|
||||
print(
|
||||
'Encountered glibc bug https://sourceware.org/bugzilla/show_bug.cgi?id=19329. '
|
||||
'Will try launching browser again.',
|
||||
);
|
||||
return '';
|
||||
}
|
||||
print('Failed to launch browser. Command used to launch it: ${args.join(' ')}');
|
||||
throw Exception(
|
||||
'Failed to launch browser. Make sure you are using an up-to-date '
|
||||
'Chrome or Edge. Otherwise, consider using -d web-server instead '
|
||||
'and filing an issue at https://github.com/flutter/flutter/issues.',
|
||||
);
|
||||
},
|
||||
);
|
||||
});
|
||||
|
||||
if (!hitGlibcBug) {
|
||||
return process;
|
||||
@@ -622,9 +646,14 @@ Future<io.Process> _spawnChromiumProcess(String executable, List<String> args, {
|
||||
// A precaution that avoids accumulating browser processes, in case the
|
||||
// glibc bug doesn't cause the browser to quit and we keep looping and
|
||||
// launching more processes.
|
||||
unawaited(process.exitCode.timeout(const Duration(seconds: 1), onTimeout: () {
|
||||
process.kill();
|
||||
return 0;
|
||||
}));
|
||||
unawaited(
|
||||
process.exitCode.timeout(
|
||||
const Duration(seconds: 1),
|
||||
onTimeout: () {
|
||||
process.kill();
|
||||
return 0;
|
||||
},
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,16 +15,17 @@ import 'package:meta/meta.dart';
|
||||
import 'task_result.dart';
|
||||
import 'utils.dart';
|
||||
|
||||
typedef ProcessRunSync = ProcessResult Function(
|
||||
String,
|
||||
List<String>, {
|
||||
Map<String, String>? environment,
|
||||
bool includeParentEnvironment,
|
||||
bool runInShell,
|
||||
Encoding? stderrEncoding,
|
||||
Encoding? stdoutEncoding,
|
||||
String? workingDirectory,
|
||||
});
|
||||
typedef ProcessRunSync =
|
||||
ProcessResult Function(
|
||||
String,
|
||||
List<String>, {
|
||||
Map<String, String>? environment,
|
||||
bool includeParentEnvironment,
|
||||
bool runInShell,
|
||||
Encoding? stderrEncoding,
|
||||
Encoding? stdoutEncoding,
|
||||
String? workingDirectory,
|
||||
});
|
||||
|
||||
/// Class for test runner to interact with Flutter's infrastructure service, Cocoon.
|
||||
///
|
||||
@@ -38,7 +39,11 @@ class Cocoon {
|
||||
@visibleForTesting this.processRunSync = Process.runSync,
|
||||
@visibleForTesting this.requestRetryLimit = 5,
|
||||
@visibleForTesting this.requestTimeoutLimit = 30,
|
||||
}) : _httpClient = AuthenticatedCocoonClient(serviceAccountTokenPath, httpClient: httpClient, filesystem: fs);
|
||||
}) : _httpClient = AuthenticatedCocoonClient(
|
||||
serviceAccountTokenPath,
|
||||
httpClient: httpClient,
|
||||
filesystem: fs,
|
||||
);
|
||||
|
||||
/// Client to make http requests to Cocoon.
|
||||
final AuthenticatedCocoonClient _httpClient;
|
||||
@@ -105,8 +110,10 @@ class Cocoon {
|
||||
resultsJson['TestFlaky'] = isTestFlaky ?? false;
|
||||
if (_shouldUpdateCocoon(resultsJson, builderBucket ?? 'prod')) {
|
||||
await retry(
|
||||
() async => _sendUpdateTaskRequest(resultsJson).timeout(Duration(seconds: requestTimeoutLimit)),
|
||||
retryIf: (Exception e) => e is SocketException || e is TimeoutException || e is ClientException,
|
||||
() async =>
|
||||
_sendUpdateTaskRequest(resultsJson).timeout(Duration(seconds: requestTimeoutLimit)),
|
||||
retryIf:
|
||||
(Exception e) => e is SocketException || e is TimeoutException || e is ClientException,
|
||||
maxAttempts: requestRetryLimit,
|
||||
);
|
||||
}
|
||||
@@ -191,7 +198,8 @@ class Cocoon {
|
||||
/// as version changes to the backend, datastore issues, or latency issues.
|
||||
final Response response = await retry(
|
||||
() => _httpClient.post(url, body: json.encode(jsonData)),
|
||||
retryIf: (Exception e) => e is SocketException || e is TimeoutException || e is ClientException,
|
||||
retryIf:
|
||||
(Exception e) => e is SocketException || e is TimeoutException || e is ClientException,
|
||||
maxAttempts: requestRetryLimit,
|
||||
);
|
||||
return json.decode(response.body) as Map<String, dynamic>;
|
||||
@@ -204,8 +212,8 @@ class AuthenticatedCocoonClient extends BaseClient {
|
||||
this._serviceAccountTokenPath, {
|
||||
@visibleForTesting Client? httpClient,
|
||||
@visibleForTesting FileSystem? filesystem,
|
||||
}) : _delegate = httpClient ?? Client(),
|
||||
_fs = filesystem ?? const LocalFileSystem();
|
||||
}) : _delegate = httpClient ?? Client(),
|
||||
_fs = filesystem ?? const LocalFileSystem();
|
||||
|
||||
/// Authentication token to have the ability to upload and record test results.
|
||||
///
|
||||
@@ -234,12 +242,13 @@ class AuthenticatedCocoonClient extends BaseClient {
|
||||
|
||||
if (response.statusCode != 200) {
|
||||
throw ClientException(
|
||||
'AuthenticatedClientError:\n'
|
||||
' URI: ${request.url}\n'
|
||||
' HTTP Status: ${response.statusCode}\n'
|
||||
' Response body:\n'
|
||||
'${(await Response.fromStream(response)).body}',
|
||||
request.url);
|
||||
'AuthenticatedClientError:\n'
|
||||
' URI: ${request.url}\n'
|
||||
' HTTP Status: ${response.statusCode}\n'
|
||||
' Response body:\n'
|
||||
'${(await Response.fromStream(response)).body}',
|
||||
request.url,
|
||||
);
|
||||
}
|
||||
return response;
|
||||
}
|
||||
|
||||
@@ -64,7 +64,6 @@ final RegExp flutterCompileSdkString = RegExp(r'flutter\.compileSdkVersion|flutt
|
||||
|
||||
/// A simple class containing a Kotlin, Gradle, and AGP version.
|
||||
class VersionTuple {
|
||||
|
||||
VersionTuple({
|
||||
required this.agpVersion,
|
||||
required this.gradleVersion,
|
||||
@@ -94,7 +93,8 @@ class VersionTuple {
|
||||
Future<TaskResult> buildFlutterApkWithSpecifiedDependencyVersions({
|
||||
required List<VersionTuple> versionTuples,
|
||||
required Directory tempDir,
|
||||
required LocalFileSystem localFileSystem,}) async {
|
||||
required LocalFileSystem localFileSystem,
|
||||
}) async {
|
||||
for (final VersionTuple versions in versionTuples) {
|
||||
final Directory innerTempDir = tempDir.createTempSync(versions.gradleVersion);
|
||||
try {
|
||||
@@ -102,25 +102,33 @@ Future<TaskResult> buildFlutterApkWithSpecifiedDependencyVersions({
|
||||
section('Create new app with dependency versions: $versions');
|
||||
await flutter(
|
||||
'create',
|
||||
options: <String>[
|
||||
'dependency_checker_app',
|
||||
'--platforms=android',
|
||||
],
|
||||
options: <String>['dependency_checker_app', '--platforms=android'],
|
||||
workingDirectory: innerTempDir.path,
|
||||
);
|
||||
|
||||
final String appPath = '${innerTempDir.absolute.path}/dependency_checker_app';
|
||||
|
||||
if (versions.compileSdkVersion != null) {
|
||||
final File appGradleBuild = getAndroidBuildFile(localFileSystem.path.join(appPath, 'android', 'app'));
|
||||
final String appBuildContent = appGradleBuild.readAsStringSync()
|
||||
.replaceFirst(flutterCompileSdkString, versions.compileSdkVersion!);
|
||||
final File appGradleBuild = getAndroidBuildFile(
|
||||
localFileSystem.path.join(appPath, 'android', 'app'),
|
||||
);
|
||||
final String appBuildContent = appGradleBuild.readAsStringSync().replaceFirst(
|
||||
flutterCompileSdkString,
|
||||
versions.compileSdkVersion!,
|
||||
);
|
||||
appGradleBuild.writeAsStringSync(appBuildContent);
|
||||
}
|
||||
|
||||
// Modify gradle version to passed in version.
|
||||
final File gradleWrapperProperties = localFileSystem.file(localFileSystem.path.join(
|
||||
appPath, 'android', 'gradle', 'wrapper', 'gradle-wrapper.properties'));
|
||||
final File gradleWrapperProperties = localFileSystem.file(
|
||||
localFileSystem.path.join(
|
||||
appPath,
|
||||
'android',
|
||||
'gradle',
|
||||
'wrapper',
|
||||
'gradle-wrapper.properties',
|
||||
),
|
||||
);
|
||||
final String propertyContent = gradleWrapperPropertiesFileContent.replaceFirst(
|
||||
gradleReplacementString,
|
||||
versions.gradleVersion,
|
||||
@@ -136,20 +144,16 @@ Future<TaskResult> buildFlutterApkWithSpecifiedDependencyVersions({
|
||||
.replaceFirst(kgpReplacementString, versions.kotlinVersion);
|
||||
await gradleSettingsFile.writeAsString(settingsContent, flush: true);
|
||||
|
||||
|
||||
// Ensure that gradle files exists from templates.
|
||||
section("Ensure 'flutter build apk' succeeds with Gradle ${versions.gradleVersion}, AGP ${versions.agpVersion}, and Kotlin ${versions.kotlinVersion}");
|
||||
await flutter(
|
||||
'build',
|
||||
options: <String>[
|
||||
'apk',
|
||||
'--debug',
|
||||
],
|
||||
workingDirectory: appPath,
|
||||
section(
|
||||
"Ensure 'flutter build apk' succeeds with Gradle ${versions.gradleVersion}, AGP ${versions.agpVersion}, and Kotlin ${versions.kotlinVersion}",
|
||||
);
|
||||
await flutter('build', options: <String>['apk', '--debug'], workingDirectory: appPath);
|
||||
} catch (e) {
|
||||
tempDir.deleteSync(recursive: true);
|
||||
return TaskResult.failure('Failed to build app with Gradle ${versions.gradleVersion}, AGP ${versions.agpVersion}, and Kotlin ${versions.kotlinVersion}, error was:\n$e');
|
||||
return TaskResult.failure(
|
||||
'Failed to build app with Gradle ${versions.gradleVersion}, AGP ${versions.agpVersion}, and Kotlin ${versions.kotlinVersion}, error was:\n$e',
|
||||
);
|
||||
}
|
||||
}
|
||||
tempDir.deleteSync(recursive: true);
|
||||
|
||||
@@ -25,12 +25,7 @@ class DeviceException implements Exception {
|
||||
|
||||
/// Gets the artifact path relative to the current directory.
|
||||
String getArtifactPath() {
|
||||
return path.normalize(
|
||||
path.join(
|
||||
path.current,
|
||||
'../../bin/cache/artifacts',
|
||||
)
|
||||
);
|
||||
return path.normalize(path.join(path.current, '../../bin/cache/artifacts'));
|
||||
}
|
||||
|
||||
/// Return the item is in idList if find a match, otherwise return null
|
||||
@@ -201,10 +196,7 @@ abstract class Device {
|
||||
Future<void> awaitDevice();
|
||||
|
||||
Future<void> uninstallApp() async {
|
||||
await flutter('install', options: <String>[
|
||||
'--uninstall-only',
|
||||
'-d',
|
||||
deviceId]);
|
||||
await flutter('install', options: <String>['--uninstall-only', '-d', deviceId]);
|
||||
|
||||
await Future<void>.delayed(const Duration(seconds: 2));
|
||||
|
||||
@@ -217,10 +209,7 @@ abstract class Device {
|
||||
}
|
||||
}
|
||||
|
||||
enum AndroidCPU {
|
||||
arm,
|
||||
arm64,
|
||||
}
|
||||
enum AndroidCPU { arm, arm64 }
|
||||
|
||||
class AndroidDeviceDiscovery implements DeviceDiscovery {
|
||||
factory AndroidDeviceDiscovery({AndroidCPU? cpu}) {
|
||||
@@ -258,7 +247,7 @@ class AndroidDeviceDiscovery implements DeviceDiscovery {
|
||||
return switch (cpu) {
|
||||
null => Future<bool>.value(true),
|
||||
AndroidCPU.arm64 => device.isArm64(),
|
||||
AndroidCPU.arm => device.isArm(),
|
||||
AndroidCPU.arm => device.isArm(),
|
||||
};
|
||||
}
|
||||
|
||||
@@ -266,9 +255,10 @@ class AndroidDeviceDiscovery implements DeviceDiscovery {
|
||||
/// [workingDevice].
|
||||
@override
|
||||
Future<void> chooseWorkingDevice() async {
|
||||
final List<AndroidDevice> allDevices = (await discoverDevices())
|
||||
.map<AndroidDevice>((String id) => AndroidDevice(deviceId: id))
|
||||
.toList();
|
||||
final List<AndroidDevice> allDevices =
|
||||
(await discoverDevices())
|
||||
.map<AndroidDevice>((String id) => AndroidDevice(deviceId: id))
|
||||
.toList();
|
||||
|
||||
if (allDevices.isEmpty) {
|
||||
throw const DeviceException('No Android devices detected');
|
||||
@@ -281,7 +271,6 @@ class AndroidDeviceDiscovery implements DeviceDiscovery {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
} else {
|
||||
// TODO(yjbanov): filter out and warn about those with low battery level
|
||||
_workingDevice = allDevices[math.Random().nextInt(allDevices.length)];
|
||||
@@ -301,7 +290,9 @@ class AndroidDeviceDiscovery implements DeviceDiscovery {
|
||||
_workingDevice = AndroidDevice(deviceId: matchedId);
|
||||
if (cpu != null) {
|
||||
if (!await _matchesCPURequirement(_workingDevice!)) {
|
||||
throw DeviceException('The selected device $matchedId does not match the cpu requirement');
|
||||
throw DeviceException(
|
||||
'The selected device $matchedId does not match the cpu requirement',
|
||||
);
|
||||
}
|
||||
}
|
||||
print('Choose device by ID: $matchedId');
|
||||
@@ -309,14 +300,13 @@ class AndroidDeviceDiscovery implements DeviceDiscovery {
|
||||
}
|
||||
throw DeviceException(
|
||||
'Device with ID $deviceId is not found for operating system: '
|
||||
'$deviceOperatingSystem'
|
||||
);
|
||||
'$deviceOperatingSystem',
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
Future<List<String>> discoverDevices() async {
|
||||
final List<String> output = (await eval(adbPath, <String>['devices', '-l']))
|
||||
.trim().split('\n');
|
||||
final List<String> output = (await eval(adbPath, <String>['devices', '-l'])).trim().split('\n');
|
||||
final List<String> results = <String>[];
|
||||
for (final String line in output) {
|
||||
// Skip lines like: * daemon started successfully *
|
||||
@@ -391,10 +381,10 @@ class LinuxDeviceDiscovery implements DeviceDiscovery {
|
||||
}
|
||||
|
||||
@override
|
||||
Future<void> chooseWorkingDevice() async { }
|
||||
Future<void> chooseWorkingDevice() async {}
|
||||
|
||||
@override
|
||||
Future<void> chooseWorkingDeviceById(String deviceId) async { }
|
||||
Future<void> chooseWorkingDeviceById(String deviceId) async {}
|
||||
|
||||
@override
|
||||
Future<List<String>> discoverDevices() async {
|
||||
@@ -402,10 +392,10 @@ class LinuxDeviceDiscovery implements DeviceDiscovery {
|
||||
}
|
||||
|
||||
@override
|
||||
Future<void> performPreflightTasks() async { }
|
||||
Future<void> performPreflightTasks() async {}
|
||||
|
||||
@override
|
||||
Future<Device> get workingDevice async => _device;
|
||||
Future<Device> get workingDevice async => _device;
|
||||
}
|
||||
|
||||
class MacosDeviceDiscovery implements DeviceDiscovery {
|
||||
@@ -425,10 +415,10 @@ class MacosDeviceDiscovery implements DeviceDiscovery {
|
||||
}
|
||||
|
||||
@override
|
||||
Future<void> chooseWorkingDevice() async { }
|
||||
Future<void> chooseWorkingDevice() async {}
|
||||
|
||||
@override
|
||||
Future<void> chooseWorkingDeviceById(String deviceId) async { }
|
||||
Future<void> chooseWorkingDeviceById(String deviceId) async {}
|
||||
|
||||
@override
|
||||
Future<List<String>> discoverDevices() async {
|
||||
@@ -436,10 +426,10 @@ class MacosDeviceDiscovery implements DeviceDiscovery {
|
||||
}
|
||||
|
||||
@override
|
||||
Future<void> performPreflightTasks() async { }
|
||||
Future<void> performPreflightTasks() async {}
|
||||
|
||||
@override
|
||||
Future<Device> get workingDevice async => _device;
|
||||
Future<Device> get workingDevice async => _device;
|
||||
}
|
||||
|
||||
class WindowsDeviceDiscovery implements DeviceDiscovery {
|
||||
@@ -459,10 +449,10 @@ class WindowsDeviceDiscovery implements DeviceDiscovery {
|
||||
}
|
||||
|
||||
@override
|
||||
Future<void> chooseWorkingDevice() async { }
|
||||
Future<void> chooseWorkingDevice() async {}
|
||||
|
||||
@override
|
||||
Future<void> chooseWorkingDeviceById(String deviceId) async { }
|
||||
Future<void> chooseWorkingDeviceById(String deviceId) async {}
|
||||
|
||||
@override
|
||||
Future<List<String>> discoverDevices() async {
|
||||
@@ -470,10 +460,10 @@ class WindowsDeviceDiscovery implements DeviceDiscovery {
|
||||
}
|
||||
|
||||
@override
|
||||
Future<void> performPreflightTasks() async { }
|
||||
Future<void> performPreflightTasks() async {}
|
||||
|
||||
@override
|
||||
Future<Device> get workingDevice async => _device;
|
||||
Future<Device> get workingDevice async => _device;
|
||||
}
|
||||
|
||||
class FuchsiaDeviceDiscovery implements DeviceDiscovery {
|
||||
@@ -488,7 +478,7 @@ class FuchsiaDeviceDiscovery implements DeviceDiscovery {
|
||||
FuchsiaDevice? _workingDevice;
|
||||
|
||||
String get _ffx {
|
||||
final String ffx = path.join(getArtifactPath(), 'fuchsia', 'tools','x64', 'ffx');
|
||||
final String ffx = path.join(getArtifactPath(), 'fuchsia', 'tools', 'x64', 'ffx');
|
||||
if (!File(ffx).existsSync()) {
|
||||
throw FileSystemException("Couldn't find ffx at location $ffx");
|
||||
}
|
||||
@@ -511,9 +501,10 @@ class FuchsiaDeviceDiscovery implements DeviceDiscovery {
|
||||
/// Picks the first connected Fuchsia device.
|
||||
@override
|
||||
Future<void> chooseWorkingDevice() async {
|
||||
final List<FuchsiaDevice> allDevices = (await discoverDevices())
|
||||
.map<FuchsiaDevice>((String id) => FuchsiaDevice(deviceId: id))
|
||||
.toList();
|
||||
final List<FuchsiaDevice> allDevices =
|
||||
(await discoverDevices())
|
||||
.map<FuchsiaDevice>((String id) => FuchsiaDevice(deviceId: id))
|
||||
.toList();
|
||||
|
||||
if (allDevices.isEmpty) {
|
||||
throw const DeviceException('No Fuchsia devices detected');
|
||||
@@ -532,15 +523,18 @@ class FuchsiaDeviceDiscovery implements DeviceDiscovery {
|
||||
}
|
||||
throw DeviceException(
|
||||
'Device with ID $deviceId is not found for operating system: '
|
||||
'$deviceOperatingSystem'
|
||||
);
|
||||
'$deviceOperatingSystem',
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
Future<List<String>> discoverDevices() async {
|
||||
final List<String> output = (await eval(_ffx, <String>['target', 'list', '-f', 's']))
|
||||
.trim()
|
||||
.split('\n');
|
||||
final List<String> output = (await eval(_ffx, <String>[
|
||||
'target',
|
||||
'list',
|
||||
'-f',
|
||||
's',
|
||||
])).trim().split('\n');
|
||||
|
||||
final List<String> devices = <String>[];
|
||||
for (final String line in output) {
|
||||
@@ -556,20 +550,13 @@ class FuchsiaDeviceDiscovery implements DeviceDiscovery {
|
||||
final Map<String, HealthCheckResult> results = <String, HealthCheckResult>{};
|
||||
for (final String deviceId in await discoverDevices()) {
|
||||
try {
|
||||
final int resolveResult = await exec(
|
||||
_ffx,
|
||||
<String>[
|
||||
'target',
|
||||
'list',
|
||||
'-f',
|
||||
'a',
|
||||
deviceId,
|
||||
]
|
||||
);
|
||||
final int resolveResult = await exec(_ffx, <String>['target', 'list', '-f', 'a', deviceId]);
|
||||
if (resolveResult == 0) {
|
||||
results['fuchsia-device-$deviceId'] = HealthCheckResult.success();
|
||||
} else {
|
||||
results['fuchsia-device-$deviceId'] = HealthCheckResult.failure('Cannot resolve device $deviceId');
|
||||
results['fuchsia-device-$deviceId'] = HealthCheckResult.failure(
|
||||
'Cannot resolve device $deviceId',
|
||||
);
|
||||
}
|
||||
} on Exception catch (error, stacktrace) {
|
||||
results['fuchsia-device-$deviceId'] = HealthCheckResult.error(error, stacktrace);
|
||||
@@ -594,7 +581,11 @@ class AndroidDevice extends Device {
|
||||
|
||||
@override
|
||||
Future<void> toggleFixedPerformanceMode(bool enable) async {
|
||||
await shellExec('cmd', <String>['power', 'set-fixed-performance-mode-enabled', if (enable) 'true' else 'false']);
|
||||
await shellExec('cmd', <String>[
|
||||
'power',
|
||||
'set-fixed-performance-mode-enabled',
|
||||
if (enable) 'true' else 'false',
|
||||
]);
|
||||
}
|
||||
|
||||
/// Whether the device is awake.
|
||||
@@ -677,15 +668,15 @@ class AndroidDevice extends Device {
|
||||
Future<void> _updateDeviceInfo() async {
|
||||
String info;
|
||||
try {
|
||||
info = await shellEval(
|
||||
info = await shellEval('getprop', <String>[
|
||||
'ro.bootimage.build.fingerprint',
|
||||
';',
|
||||
'getprop',
|
||||
<String>[
|
||||
'ro.bootimage.build.fingerprint', ';',
|
||||
'getprop', 'ro.build.version.release', ';',
|
||||
'getprop', 'ro.build.version.sdk',
|
||||
],
|
||||
silent: true,
|
||||
);
|
||||
'ro.build.version.release',
|
||||
';',
|
||||
'getprop',
|
||||
'ro.build.version.sdk',
|
||||
], silent: true);
|
||||
} on IOException {
|
||||
info = '';
|
||||
}
|
||||
@@ -700,22 +691,32 @@ class AndroidDevice extends Device {
|
||||
}
|
||||
|
||||
/// Executes [command] on `adb shell`.
|
||||
Future<void> shellExec(String command, List<String> arguments, { Map<String, String>? environment, bool silent = false }) async {
|
||||
Future<void> shellExec(
|
||||
String command,
|
||||
List<String> arguments, {
|
||||
Map<String, String>? environment,
|
||||
bool silent = false,
|
||||
}) async {
|
||||
await adb(<String>['shell', command, ...arguments], environment: environment, silent: silent);
|
||||
}
|
||||
|
||||
/// Executes [command] on `adb shell` and returns its standard output as a [String].
|
||||
Future<String> shellEval(String command, List<String> arguments, { Map<String, String>? environment, bool silent = false }) {
|
||||
Future<String> shellEval(
|
||||
String command,
|
||||
List<String> arguments, {
|
||||
Map<String, String>? environment,
|
||||
bool silent = false,
|
||||
}) {
|
||||
return adb(<String>['shell', command, ...arguments], environment: environment, silent: silent);
|
||||
}
|
||||
|
||||
/// Runs `adb` with the given [arguments], selecting this device.
|
||||
Future<String> adb(
|
||||
List<String> arguments, {
|
||||
Map<String, String>? environment,
|
||||
bool silent = false,
|
||||
bool canFail = false, // as in, whether failures are ok. False means that they are fatal.
|
||||
}) {
|
||||
List<String> arguments, {
|
||||
Map<String, String>? environment,
|
||||
bool silent = false,
|
||||
bool canFail = false, // as in, whether failures are ok. False means that they are fatal.
|
||||
}) {
|
||||
return eval(
|
||||
adbPath,
|
||||
<String>['-s', deviceId, ...arguments],
|
||||
@@ -731,9 +732,7 @@ class AndroidDevice extends Device {
|
||||
final String meminfo = await shellEval('dumpsys', <String>['meminfo', packageName]);
|
||||
final Match? match = RegExp(r'TOTAL\s+(\d+)').firstMatch(meminfo);
|
||||
assert(match != null, 'could not parse dumpsys meminfo output');
|
||||
return <String, dynamic>{
|
||||
'total_kb': int.parse(match!.group(1)!),
|
||||
};
|
||||
return <String, dynamic>{'total_kb': int.parse(match!.group(1)!)};
|
||||
}
|
||||
|
||||
@override
|
||||
@@ -752,21 +751,23 @@ class AndroidDevice extends Device {
|
||||
// Catch the whole log.
|
||||
<String>['-s', deviceId, 'logcat'],
|
||||
);
|
||||
_loggingProcess!.stdout
|
||||
.transform<String>(const Utf8Decoder(allowMalformed: true))
|
||||
.listen((String line) {
|
||||
sink.write(line);
|
||||
});
|
||||
_loggingProcess!.stderr
|
||||
.transform<String>(const Utf8Decoder(allowMalformed: true))
|
||||
.listen((String line) {
|
||||
sink.write(line);
|
||||
});
|
||||
unawaited(_loggingProcess!.exitCode.then<void>((int exitCode) {
|
||||
if (!_abortedLogging) {
|
||||
sink.writeln('adb logcat failed with exit code $exitCode.\n');
|
||||
}
|
||||
}));
|
||||
_loggingProcess!.stdout.transform<String>(const Utf8Decoder(allowMalformed: true)).listen((
|
||||
String line,
|
||||
) {
|
||||
sink.write(line);
|
||||
});
|
||||
_loggingProcess!.stderr.transform<String>(const Utf8Decoder(allowMalformed: true)).listen((
|
||||
String line,
|
||||
) {
|
||||
sink.write(line);
|
||||
});
|
||||
unawaited(
|
||||
_loggingProcess!.exitCode.then<void>((int exitCode) {
|
||||
if (!_abortedLogging) {
|
||||
sink.writeln('adb logcat failed with exit code $exitCode.\n');
|
||||
}
|
||||
}),
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
@@ -805,27 +806,39 @@ class AndroidDevice extends Device {
|
||||
<String>['-s', deviceId, 'logcat', 'ActivityManager:I', 'flutter:V', '*:F'],
|
||||
);
|
||||
process.stdout
|
||||
.transform<String>(utf8.decoder)
|
||||
.transform<String>(const LineSplitter())
|
||||
.listen((String line) {
|
||||
print('adb logcat: $line');
|
||||
if (!stream.isClosed) {
|
||||
stream.sink.add(line);
|
||||
}
|
||||
}, onDone: () { stdoutDone.complete(); });
|
||||
.transform<String>(utf8.decoder)
|
||||
.transform<String>(const LineSplitter())
|
||||
.listen(
|
||||
(String line) {
|
||||
print('adb logcat: $line');
|
||||
if (!stream.isClosed) {
|
||||
stream.sink.add(line);
|
||||
}
|
||||
},
|
||||
onDone: () {
|
||||
stdoutDone.complete();
|
||||
},
|
||||
);
|
||||
process.stderr
|
||||
.transform<String>(utf8.decoder)
|
||||
.transform<String>(const LineSplitter())
|
||||
.listen((String line) {
|
||||
print('adb logcat stderr: $line');
|
||||
}, onDone: () { stderrDone.complete(); });
|
||||
unawaited(process.exitCode.then<void>((int exitCode) {
|
||||
print('adb logcat process terminated with exit code $exitCode');
|
||||
if (!aborted) {
|
||||
stream.addError(BuildFailedError('adb logcat failed with exit code $exitCode.\n'));
|
||||
processDone.complete();
|
||||
}
|
||||
}));
|
||||
.transform<String>(utf8.decoder)
|
||||
.transform<String>(const LineSplitter())
|
||||
.listen(
|
||||
(String line) {
|
||||
print('adb logcat stderr: $line');
|
||||
},
|
||||
onDone: () {
|
||||
stderrDone.complete();
|
||||
},
|
||||
);
|
||||
unawaited(
|
||||
process.exitCode.then<void>((int exitCode) {
|
||||
print('adb logcat process terminated with exit code $exitCode');
|
||||
if (!aborted) {
|
||||
stream.addError(BuildFailedError('adb logcat failed with exit code $exitCode.\n'));
|
||||
processDone.complete();
|
||||
}
|
||||
}),
|
||||
);
|
||||
await Future.any<dynamic>(<Future<dynamic>>[
|
||||
Future.wait<void>(<Future<void>>[
|
||||
stdoutDone.future,
|
||||
@@ -871,7 +884,11 @@ class AndroidDevice extends Device {
|
||||
print('Waiting for device.');
|
||||
final String waitOut = await adb(<String>['wait-for-device']);
|
||||
print(waitOut);
|
||||
const RetryOptions retryOptions = RetryOptions(delayFactor: Duration(seconds: 1), maxAttempts: 10, maxDelay: Duration(minutes: 1));
|
||||
const RetryOptions retryOptions = RetryOptions(
|
||||
delayFactor: Duration(seconds: 1),
|
||||
maxAttempts: 10,
|
||||
maxDelay: Duration(minutes: 1),
|
||||
);
|
||||
await retryOptions.retry(() async {
|
||||
final String adbShellOut = await adb(<String>['shell', 'getprop sys.boot_completed']);
|
||||
if (adbShellOut != '1') {
|
||||
@@ -913,9 +930,8 @@ class IosDeviceDiscovery implements DeviceDiscovery {
|
||||
/// [workingDevice].
|
||||
@override
|
||||
Future<void> chooseWorkingDevice() async {
|
||||
final List<IosDevice> allDevices = (await discoverDevices())
|
||||
.map<IosDevice>((String id) => IosDevice(deviceId: id))
|
||||
.toList();
|
||||
final List<IosDevice> allDevices =
|
||||
(await discoverDevices()).map<IosDevice>((String id) => IosDevice(deviceId: id)).toList();
|
||||
|
||||
if (allDevices.isEmpty) {
|
||||
throw const DeviceException('No iOS devices detected');
|
||||
@@ -936,16 +952,23 @@ class IosDeviceDiscovery implements DeviceDiscovery {
|
||||
}
|
||||
throw DeviceException(
|
||||
'Device with ID $deviceId is not found for operating system: '
|
||||
'$deviceOperatingSystem'
|
||||
);
|
||||
'$deviceOperatingSystem',
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
Future<List<String>> discoverDevices() async {
|
||||
final List<dynamic> results = json.decode(await eval(
|
||||
path.join(flutterDirectory.path, 'bin', 'flutter'),
|
||||
<String>['devices', '--machine', '--suppress-analytics', '--device-timeout', '5'],
|
||||
)) as List<dynamic>;
|
||||
final List<dynamic> results =
|
||||
json.decode(
|
||||
await eval(path.join(flutterDirectory.path, 'bin', 'flutter'), <String>[
|
||||
'devices',
|
||||
'--machine',
|
||||
'--suppress-analytics',
|
||||
'--device-timeout',
|
||||
'5',
|
||||
]),
|
||||
)
|
||||
as List<dynamic>;
|
||||
|
||||
// [
|
||||
// {
|
||||
@@ -1003,13 +1026,20 @@ class IosDeviceDiscovery implements DeviceDiscovery {
|
||||
|
||||
/// iOS device.
|
||||
class IosDevice extends Device {
|
||||
IosDevice({ required this.deviceId });
|
||||
IosDevice({required this.deviceId});
|
||||
|
||||
@override
|
||||
final String deviceId;
|
||||
|
||||
String get idevicesyslogPath {
|
||||
return path.join(flutterDirectory.path, 'bin', 'cache', 'artifacts', 'libimobiledevice', 'idevicesyslog');
|
||||
return path.join(
|
||||
flutterDirectory.path,
|
||||
'bin',
|
||||
'cache',
|
||||
'artifacts',
|
||||
'libimobiledevice',
|
||||
'idevicesyslog',
|
||||
);
|
||||
}
|
||||
|
||||
String get dyldLibraryPath {
|
||||
@@ -1034,25 +1064,25 @@ class IosDevice extends Device {
|
||||
_loggingProcess = await startProcess(
|
||||
idevicesyslogPath,
|
||||
<String>['-u', deviceId, '--quiet'],
|
||||
environment: <String, String>{
|
||||
'DYLD_LIBRARY_PATH': dyldLibraryPath,
|
||||
},
|
||||
environment: <String, String>{'DYLD_LIBRARY_PATH': dyldLibraryPath},
|
||||
);
|
||||
_loggingProcess!.stdout.transform<String>(const Utf8Decoder(allowMalformed: true)).listen((
|
||||
String line,
|
||||
) {
|
||||
sink.write(line);
|
||||
});
|
||||
_loggingProcess!.stderr.transform<String>(const Utf8Decoder(allowMalformed: true)).listen((
|
||||
String line,
|
||||
) {
|
||||
sink.write(line);
|
||||
});
|
||||
unawaited(
|
||||
_loggingProcess!.exitCode.then<void>((int exitCode) {
|
||||
if (!_abortedLogging) {
|
||||
sink.writeln('idevicesyslog failed with exit code $exitCode.\n');
|
||||
}
|
||||
}),
|
||||
);
|
||||
_loggingProcess!.stdout
|
||||
.transform<String>(const Utf8Decoder(allowMalformed: true))
|
||||
.listen((String line) {
|
||||
sink.write(line);
|
||||
});
|
||||
_loggingProcess!.stderr
|
||||
.transform<String>(const Utf8Decoder(allowMalformed: true))
|
||||
.listen((String line) {
|
||||
sink.write(line);
|
||||
});
|
||||
unawaited(_loggingProcess!.exitCode.then<void>((int exitCode) {
|
||||
if (!_abortedLogging) {
|
||||
sink.writeln('idevicesyslog failed with exit code $exitCode.\n');
|
||||
}
|
||||
}));
|
||||
}
|
||||
|
||||
@override
|
||||
@@ -1132,7 +1162,7 @@ class LinuxDevice extends Device {
|
||||
}
|
||||
|
||||
@override
|
||||
Future<void> home() async { }
|
||||
Future<void> home() async {}
|
||||
|
||||
@override
|
||||
Future<bool> isAsleep() async {
|
||||
@@ -1151,25 +1181,25 @@ class LinuxDevice extends Device {
|
||||
Future<void> clearLogs() async {}
|
||||
|
||||
@override
|
||||
Future<void> reboot() async { }
|
||||
Future<void> reboot() async {}
|
||||
|
||||
@override
|
||||
Future<void> sendToSleep() async { }
|
||||
Future<void> sendToSleep() async {}
|
||||
|
||||
@override
|
||||
Future<void> stop(String packageName) async { }
|
||||
Future<void> stop(String packageName) async {}
|
||||
|
||||
@override
|
||||
Future<void> tap(int x, int y) async { }
|
||||
Future<void> tap(int x, int y) async {}
|
||||
|
||||
@override
|
||||
Future<void> togglePower() async { }
|
||||
Future<void> togglePower() async {}
|
||||
|
||||
@override
|
||||
Future<void> unlock() async { }
|
||||
Future<void> unlock() async {}
|
||||
|
||||
@override
|
||||
Future<void> wakeUp() async { }
|
||||
Future<void> wakeUp() async {}
|
||||
|
||||
@override
|
||||
Future<void> awaitDevice() async {}
|
||||
@@ -1187,7 +1217,7 @@ class MacosDevice extends Device {
|
||||
}
|
||||
|
||||
@override
|
||||
Future<void> home() async { }
|
||||
Future<void> home() async {}
|
||||
|
||||
@override
|
||||
Future<bool> isAsleep() async {
|
||||
@@ -1206,25 +1236,25 @@ class MacosDevice extends Device {
|
||||
Future<void> clearLogs() async {}
|
||||
|
||||
@override
|
||||
Future<void> reboot() async { }
|
||||
Future<void> reboot() async {}
|
||||
|
||||
@override
|
||||
Future<void> sendToSleep() async { }
|
||||
Future<void> sendToSleep() async {}
|
||||
|
||||
@override
|
||||
Future<void> stop(String packageName) async { }
|
||||
Future<void> stop(String packageName) async {}
|
||||
|
||||
@override
|
||||
Future<void> tap(int x, int y) async { }
|
||||
Future<void> tap(int x, int y) async {}
|
||||
|
||||
@override
|
||||
Future<void> togglePower() async { }
|
||||
Future<void> togglePower() async {}
|
||||
|
||||
@override
|
||||
Future<void> unlock() async { }
|
||||
Future<void> unlock() async {}
|
||||
|
||||
@override
|
||||
Future<void> wakeUp() async { }
|
||||
Future<void> wakeUp() async {}
|
||||
|
||||
@override
|
||||
Future<void> awaitDevice() async {}
|
||||
@@ -1242,7 +1272,7 @@ class WindowsDevice extends Device {
|
||||
}
|
||||
|
||||
@override
|
||||
Future<void> home() async { }
|
||||
Future<void> home() async {}
|
||||
|
||||
@override
|
||||
Future<bool> isAsleep() async {
|
||||
@@ -1261,25 +1291,25 @@ class WindowsDevice extends Device {
|
||||
Future<void> clearLogs() async {}
|
||||
|
||||
@override
|
||||
Future<void> reboot() async { }
|
||||
Future<void> reboot() async {}
|
||||
|
||||
@override
|
||||
Future<void> sendToSleep() async { }
|
||||
Future<void> sendToSleep() async {}
|
||||
|
||||
@override
|
||||
Future<void> stop(String packageName) async { }
|
||||
Future<void> stop(String packageName) async {}
|
||||
|
||||
@override
|
||||
Future<void> tap(int x, int y) async { }
|
||||
Future<void> tap(int x, int y) async {}
|
||||
|
||||
@override
|
||||
Future<void> togglePower() async { }
|
||||
Future<void> togglePower() async {}
|
||||
|
||||
@override
|
||||
Future<void> unlock() async { }
|
||||
Future<void> unlock() async {}
|
||||
|
||||
@override
|
||||
Future<void> wakeUp() async { }
|
||||
Future<void> wakeUp() async {}
|
||||
|
||||
@override
|
||||
Future<void> awaitDevice() async {}
|
||||
@@ -1287,7 +1317,7 @@ class WindowsDevice extends Device {
|
||||
|
||||
/// Fuchsia device.
|
||||
class FuchsiaDevice extends Device {
|
||||
const FuchsiaDevice({ required this.deviceId });
|
||||
const FuchsiaDevice({required this.deviceId});
|
||||
|
||||
@override
|
||||
final String deviceId;
|
||||
@@ -1344,13 +1374,14 @@ class FuchsiaDevice extends Device {
|
||||
|
||||
/// Path to the `adb` executable.
|
||||
String get adbPath {
|
||||
final String? androidHome = Platform.environment['ANDROID_HOME'] ?? Platform.environment['ANDROID_SDK_ROOT'];
|
||||
final String? androidHome =
|
||||
Platform.environment['ANDROID_HOME'] ?? Platform.environment['ANDROID_SDK_ROOT'];
|
||||
|
||||
if (androidHome == null) {
|
||||
throw const DeviceException(
|
||||
'The ANDROID_HOME environment variable is '
|
||||
'missing. The variable must point to the Android '
|
||||
'SDK directory containing platform-tools.'
|
||||
'SDK directory containing platform-tools.',
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1364,7 +1395,7 @@ String get adbPath {
|
||||
}
|
||||
|
||||
class FakeDevice extends Device {
|
||||
const FakeDevice({ required this.deviceId });
|
||||
const FakeDevice({required this.deviceId});
|
||||
|
||||
@override
|
||||
final String deviceId;
|
||||
@@ -1461,8 +1492,8 @@ class FakeDeviceDiscovery implements DeviceDiscovery {
|
||||
}
|
||||
throw DeviceException(
|
||||
'Device with ID $deviceId is not found for operating system: '
|
||||
'$deviceOperatingSystem'
|
||||
);
|
||||
'$deviceOperatingSystem',
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
@@ -1480,5 +1511,5 @@ class FakeDeviceDiscovery implements DeviceDiscovery {
|
||||
}
|
||||
|
||||
@override
|
||||
Future<void> performPreflightTasks() async { }
|
||||
Future<void> performPreflightTasks() async {}
|
||||
}
|
||||
|
||||
@@ -45,7 +45,7 @@ bool _isTaskRegistered = false;
|
||||
///
|
||||
/// If no `processManager` is provided, a default [LocalProcessManager] is created
|
||||
/// for the task.
|
||||
Future<TaskResult> task(TaskFunction task, { ProcessManager? processManager }) async {
|
||||
Future<TaskResult> task(TaskFunction task, {ProcessManager? processManager}) async {
|
||||
if (_isTaskRegistered) {
|
||||
throw StateError('A task is already registered');
|
||||
}
|
||||
@@ -66,18 +66,16 @@ Future<TaskResult> task(TaskFunction task, { ProcessManager? processManager }) a
|
||||
|
||||
class _TaskRunner {
|
||||
_TaskRunner(this.task, this.processManager) {
|
||||
final String successResponse = json.encode(
|
||||
const <String, String>{
|
||||
'result': 'success',
|
||||
},
|
||||
);
|
||||
final String successResponse = json.encode(const <String, String>{'result': 'success'});
|
||||
|
||||
registerExtension('ext.cocoonRunTask',
|
||||
(String method, Map<String, String> parameters) async {
|
||||
final Duration? taskTimeout = parameters.containsKey('timeoutInMinutes')
|
||||
? Duration(minutes: int.parse(parameters['timeoutInMinutes']!))
|
||||
: null;
|
||||
final bool runFlutterConfig = parameters['runFlutterConfig'] != 'false'; // used by tests to avoid changing the configuration
|
||||
registerExtension('ext.cocoonRunTask', (String method, Map<String, String> parameters) async {
|
||||
final Duration? taskTimeout =
|
||||
parameters.containsKey('timeoutInMinutes')
|
||||
? Duration(minutes: int.parse(parameters['timeoutInMinutes']!))
|
||||
: null;
|
||||
final bool runFlutterConfig =
|
||||
parameters['runFlutterConfig'] !=
|
||||
'false'; // used by tests to avoid changing the configuration
|
||||
final bool runProcessCleanup = parameters['runProcessCleanup'] != 'false';
|
||||
final String? localEngine = parameters['localEngine'];
|
||||
final String? localEngineHost = parameters['localEngineHost'];
|
||||
@@ -89,22 +87,25 @@ class _TaskRunner {
|
||||
localEngineHost: localEngineHost,
|
||||
);
|
||||
const Duration taskResultReceivedTimeout = Duration(seconds: 30);
|
||||
_taskResultReceivedTimeout = Timer(
|
||||
taskResultReceivedTimeout,
|
||||
() {
|
||||
logger.severe('Task runner did not acknowledge task results in $taskResultReceivedTimeout.');
|
||||
_closeKeepAlivePort();
|
||||
exitCode = 1;
|
||||
}
|
||||
);
|
||||
_taskResultReceivedTimeout = Timer(taskResultReceivedTimeout, () {
|
||||
logger.severe(
|
||||
'Task runner did not acknowledge task results in $taskResultReceivedTimeout.',
|
||||
);
|
||||
_closeKeepAlivePort();
|
||||
exitCode = 1;
|
||||
});
|
||||
return ServiceExtensionResponse.result(json.encode(result.toJson()));
|
||||
});
|
||||
registerExtension('ext.cocoonRunnerReady',
|
||||
(String method, Map<String, String> parameters) async {
|
||||
registerExtension('ext.cocoonRunnerReady', (
|
||||
String method,
|
||||
Map<String, String> parameters,
|
||||
) async {
|
||||
return ServiceExtensionResponse.result(successResponse);
|
||||
});
|
||||
registerExtension('ext.cocoonTaskResultReceived',
|
||||
(String method, Map<String, String> parameters) async {
|
||||
registerExtension('ext.cocoonTaskResultReceived', (
|
||||
String method,
|
||||
Map<String, String> parameters,
|
||||
) async {
|
||||
_closeKeepAlivePort();
|
||||
return ServiceExtensionResponse.result(successResponse);
|
||||
});
|
||||
@@ -134,7 +135,8 @@ class _TaskRunner {
|
||||
/// Signals that this task runner finished running the task.
|
||||
Future<TaskResult> get whenDone => _completer.future;
|
||||
|
||||
Future<TaskResult> run(Duration? taskTimeout, {
|
||||
Future<TaskResult> run(
|
||||
Duration? taskTimeout, {
|
||||
bool runFlutterConfig = true,
|
||||
bool runProcessCleanup = true,
|
||||
required String? localEngine,
|
||||
@@ -151,7 +153,9 @@ class _TaskRunner {
|
||||
processName: 'dart$exe',
|
||||
processManager: processManager,
|
||||
);
|
||||
final Set<RunningProcessInfo> allProcesses = await getRunningProcesses(processManager: processManager);
|
||||
final Set<RunningProcessInfo> allProcesses = await getRunningProcesses(
|
||||
processManager: processManager,
|
||||
);
|
||||
beforeRunningDartInstances.forEach(print);
|
||||
for (final RunningProcessInfo info in allProcesses) {
|
||||
if (info.commandLine.contains('iproxy')) {
|
||||
@@ -162,14 +166,18 @@ class _TaskRunner {
|
||||
|
||||
if (runFlutterConfig) {
|
||||
print('Enabling configs for macOS and Linux...');
|
||||
final int configResult = await exec(path.join(flutterDirectory.path, 'bin', 'flutter'), <String>[
|
||||
'config',
|
||||
'-v',
|
||||
'--enable-macos-desktop',
|
||||
'--enable-linux-desktop',
|
||||
if (localEngine != null) ...<String>['--local-engine', localEngine],
|
||||
if (localEngineHost != null) ...<String>['--local-engine-host', localEngineHost],
|
||||
], canFail: true);
|
||||
final int configResult = await exec(
|
||||
path.join(flutterDirectory.path, 'bin', 'flutter'),
|
||||
<String>[
|
||||
'config',
|
||||
'-v',
|
||||
'--enable-macos-desktop',
|
||||
'--enable-linux-desktop',
|
||||
if (localEngine != null) ...<String>['--local-engine', localEngine],
|
||||
if (localEngineHost != null) ...<String>['--local-engine-host', localEngineHost],
|
||||
],
|
||||
canFail: true,
|
||||
);
|
||||
if (configResult != 0) {
|
||||
print('Failed to enable configuration, tasks may not run.');
|
||||
}
|
||||
@@ -184,7 +192,8 @@ class _TaskRunner {
|
||||
IOSink? sink;
|
||||
try {
|
||||
if (device != null && device.canStreamLogs && hostAgent.dumpDirectory != null) {
|
||||
sink = File(path.join(hostAgent.dumpDirectory!.path, '${device.deviceId}.log')).openWrite();
|
||||
sink =
|
||||
File(path.join(hostAgent.dumpDirectory!.path, '${device.deviceId}.log')).openWrite();
|
||||
await device.startLoggingToSink(sink);
|
||||
}
|
||||
|
||||
@@ -295,23 +304,26 @@ class _TaskRunner {
|
||||
|
||||
Future<TaskResult> _performTask() {
|
||||
final Completer<TaskResult> completer = Completer<TaskResult>();
|
||||
Chain.capture(() async {
|
||||
completer.complete(await task());
|
||||
}, onError: (dynamic taskError, Chain taskErrorStack) {
|
||||
final String message = 'Task failed: $taskError';
|
||||
stderr
|
||||
..writeln(message)
|
||||
..writeln('\nStack trace:')
|
||||
..writeln(taskErrorStack.terse);
|
||||
// IMPORTANT: We're completing the future _successfully_ but with a value
|
||||
// that indicates a task failure. This is intentional. At this point we
|
||||
// are catching errors coming from arbitrary (and untrustworthy) task
|
||||
// code. Our goal is to convert the failure into a readable message.
|
||||
// Propagating it further is not useful.
|
||||
if (!completer.isCompleted) {
|
||||
completer.complete(TaskResult.failure(message));
|
||||
}
|
||||
});
|
||||
Chain.capture(
|
||||
() async {
|
||||
completer.complete(await task());
|
||||
},
|
||||
onError: (dynamic taskError, Chain taskErrorStack) {
|
||||
final String message = 'Task failed: $taskError';
|
||||
stderr
|
||||
..writeln(message)
|
||||
..writeln('\nStack trace:')
|
||||
..writeln(taskErrorStack.terse);
|
||||
// IMPORTANT: We're completing the future _successfully_ but with a value
|
||||
// that indicates a task failure. This is intentional. At this point we
|
||||
// are catching errors coming from arbitrary (and untrustworthy) task
|
||||
// code. Our goal is to convert the failure into a readable message.
|
||||
// Propagating it further is not useful.
|
||||
if (!completer.isCompleted) {
|
||||
completer.complete(TaskResult.failure(message));
|
||||
}
|
||||
},
|
||||
);
|
||||
return completer.future;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,13 +8,14 @@ import 'package:meta/meta.dart';
|
||||
import 'package:platform/platform.dart';
|
||||
|
||||
/// The current host machine running the tests.
|
||||
HostAgent get hostAgent => HostAgent(platform: const LocalPlatform(), fileSystem: const LocalFileSystem());
|
||||
HostAgent get hostAgent =>
|
||||
HostAgent(platform: const LocalPlatform(), fileSystem: const LocalFileSystem());
|
||||
|
||||
/// Host machine running the tests.
|
||||
class HostAgent {
|
||||
HostAgent({required Platform platform, required FileSystem fileSystem})
|
||||
: _platform = platform,
|
||||
_fileSystem = fileSystem;
|
||||
: _platform = platform,
|
||||
_fileSystem = fileSystem;
|
||||
|
||||
final Platform _platform;
|
||||
final FileSystem _fileSystem;
|
||||
|
||||
@@ -17,12 +17,7 @@ Future<String> fileType(String pathToBinary) {
|
||||
}
|
||||
|
||||
Future<String?> minPhoneOSVersion(String pathToBinary) async {
|
||||
final String loadCommands = await eval('otool', <String>[
|
||||
'-l',
|
||||
'-arch',
|
||||
'arm64',
|
||||
pathToBinary,
|
||||
]);
|
||||
final String loadCommands = await eval('otool', <String>['-l', '-arch', 'arm64', pathToBinary]);
|
||||
if (!loadCommands.contains('LC_VERSION_MIN_IPHONEOS')) {
|
||||
return null;
|
||||
}
|
||||
@@ -37,9 +32,7 @@ Future<String?> minPhoneOSVersion(String pathToBinary) async {
|
||||
final List<String> lines = LineSplitter.split(loadCommands).toList();
|
||||
lines.asMap().forEach((int index, String line) {
|
||||
if (line.contains('LC_VERSION_MIN_IPHONEOS') && lines.length - index - 1 > 3) {
|
||||
final String versionLine = lines
|
||||
.skip(index - 1)
|
||||
.take(4).last;
|
||||
final String versionLine = lines.skip(index - 1).take(4).last;
|
||||
final RegExp versionRegex = RegExp(r'\s*version\s*(\S*)');
|
||||
minVersion = versionRegex.firstMatch(versionLine)?.group(1);
|
||||
}
|
||||
@@ -56,35 +49,27 @@ Future<void> testWithNewIOSSimulator(
|
||||
SimulatorFunction testFunction, {
|
||||
String deviceTypeId = 'com.apple.CoreSimulator.SimDeviceType.iPhone-11',
|
||||
}) async {
|
||||
final String availableRuntimes = await eval(
|
||||
'xcrun',
|
||||
<String>[
|
||||
'simctl',
|
||||
'list',
|
||||
'runtimes',
|
||||
],
|
||||
workingDirectory: flutterDirectory.path,
|
||||
);
|
||||
final String availableRuntimes = await eval('xcrun', <String>[
|
||||
'simctl',
|
||||
'list',
|
||||
'runtimes',
|
||||
], workingDirectory: flutterDirectory.path);
|
||||
|
||||
final String runtimesForSelectedXcode = await eval(
|
||||
'xcrun',
|
||||
<String>[
|
||||
'simctl',
|
||||
'runtime',
|
||||
'match',
|
||||
'list',
|
||||
'--json',
|
||||
],
|
||||
workingDirectory: flutterDirectory.path,
|
||||
);
|
||||
final String runtimesForSelectedXcode = await eval('xcrun', <String>[
|
||||
'simctl',
|
||||
'runtime',
|
||||
'match',
|
||||
'list',
|
||||
'--json',
|
||||
], workingDirectory: flutterDirectory.path);
|
||||
|
||||
// Get the preferred runtime build for the selected Xcode version. Preferred
|
||||
// means the runtime was either bundled with Xcode, exactly matched your SDK
|
||||
// version, or it's indicated a better match for your SDK.
|
||||
final Map<String, Object?> decodeResult = json.decode(runtimesForSelectedXcode) as Map<String, Object?>;
|
||||
final String? iosKey = decodeResult.keys
|
||||
.where((String key) => key.contains('iphoneos'))
|
||||
.firstOrNull;
|
||||
final Map<String, Object?> decodeResult =
|
||||
json.decode(runtimesForSelectedXcode) as Map<String, Object?>;
|
||||
final String? iosKey =
|
||||
decodeResult.keys.where((String key) => key.contains('iphoneos')).firstOrNull;
|
||||
final String? runtimeBuildForSelectedXcode = switch (decodeResult[iosKey]) {
|
||||
{'preferredBuild': final String build} => build,
|
||||
_ => null,
|
||||
@@ -100,8 +85,7 @@ Future<void> testWithNewIOSSimulator(
|
||||
// For example, iOS 17 (released with Xcode 15) may be available even if the
|
||||
// selected Xcode version is 14.
|
||||
for (final String runtime in LineSplitter.split(availableRuntimes)) {
|
||||
if (runtimeBuildForSelectedXcode != null &&
|
||||
!runtime.contains(runtimeBuildForSelectedXcode)) {
|
||||
if (runtimeBuildForSelectedXcode != null && !runtime.contains(runtimeBuildForSelectedXcode)) {
|
||||
continue;
|
||||
}
|
||||
// These seem to be in order, so allow matching multiple lines so it grabs
|
||||
@@ -120,26 +104,18 @@ Future<void> testWithNewIOSSimulator(
|
||||
}
|
||||
}
|
||||
|
||||
final String deviceId = await eval(
|
||||
'xcrun',
|
||||
<String>[
|
||||
'simctl',
|
||||
'create',
|
||||
deviceName,
|
||||
deviceTypeId,
|
||||
iOSSimRuntime,
|
||||
],
|
||||
workingDirectory: flutterDirectory.path,
|
||||
);
|
||||
await eval(
|
||||
'xcrun',
|
||||
<String>[
|
||||
'simctl',
|
||||
'boot',
|
||||
deviceId,
|
||||
],
|
||||
workingDirectory: flutterDirectory.path,
|
||||
);
|
||||
final String deviceId = await eval('xcrun', <String>[
|
||||
'simctl',
|
||||
'create',
|
||||
deviceName,
|
||||
deviceTypeId,
|
||||
iOSSimRuntime,
|
||||
], workingDirectory: flutterDirectory.path);
|
||||
await eval('xcrun', <String>[
|
||||
'simctl',
|
||||
'boot',
|
||||
deviceId,
|
||||
], workingDirectory: flutterDirectory.path);
|
||||
|
||||
await testFunction(deviceId);
|
||||
}
|
||||
@@ -149,21 +125,13 @@ Future<void> removeIOSSimulator(String? deviceId) async {
|
||||
if (deviceId != null && deviceId != '') {
|
||||
await eval(
|
||||
'xcrun',
|
||||
<String>[
|
||||
'simctl',
|
||||
'shutdown',
|
||||
deviceId,
|
||||
],
|
||||
<String>['simctl', 'shutdown', deviceId],
|
||||
canFail: true,
|
||||
workingDirectory: flutterDirectory.path,
|
||||
);
|
||||
await eval(
|
||||
'xcrun',
|
||||
<String>[
|
||||
'simctl',
|
||||
'delete',
|
||||
deviceId,
|
||||
],
|
||||
<String>['simctl', 'delete', deviceId],
|
||||
canFail: true,
|
||||
workingDirectory: flutterDirectory.path,
|
||||
);
|
||||
@@ -211,12 +179,9 @@ Future<bool> runXcodeTests({
|
||||
resultBundlePath,
|
||||
'test',
|
||||
'COMPILER_INDEX_STORE_ENABLE=NO',
|
||||
if (developmentTeam != null)
|
||||
'DEVELOPMENT_TEAM=$developmentTeam',
|
||||
if (codeSignStyle != null)
|
||||
'CODE_SIGN_STYLE=$codeSignStyle',
|
||||
if (provisioningProfile != null)
|
||||
'PROVISIONING_PROFILE_SPECIFIER=$provisioningProfile',
|
||||
if (developmentTeam != null) 'DEVELOPMENT_TEAM=$developmentTeam',
|
||||
if (codeSignStyle != null) 'CODE_SIGN_STYLE=$codeSignStyle',
|
||||
if (provisioningProfile != null) 'PROVISIONING_PROFILE_SPECIFIER=$provisioningProfile',
|
||||
if (disabledSandboxEntitlementFile != null)
|
||||
'CODE_SIGN_ENTITLEMENTS=${disabledSandboxEntitlementFile.path}',
|
||||
],
|
||||
@@ -230,17 +195,13 @@ Future<bool> runXcodeTests({
|
||||
if (dumpDirectory != null) {
|
||||
if (xcresultBundle.existsSync()) {
|
||||
// Zip the test results to the artifacts directory for upload.
|
||||
final String zipPath = path.join(dumpDirectory.path,
|
||||
'$testName-${DateTime.now().toLocal().toIso8601String()}.zip');
|
||||
final String zipPath = path.join(
|
||||
dumpDirectory.path,
|
||||
'$testName-${DateTime.now().toLocal().toIso8601String()}.zip',
|
||||
);
|
||||
await exec(
|
||||
'zip',
|
||||
<String>[
|
||||
'-r',
|
||||
'-9',
|
||||
'-q',
|
||||
zipPath,
|
||||
path.basename(xcresultBundle.path),
|
||||
],
|
||||
<String>['-r', '-9', '-q', zipPath, path.basename(xcresultBundle.path)],
|
||||
workingDirectory: resultBundleTemp,
|
||||
canFail: true, // Best effort to get the logs.
|
||||
);
|
||||
@@ -260,10 +221,7 @@ Future<bool> runXcodeTests({
|
||||
/// access to the app. To workaround this in CI, we create and use a entitlements
|
||||
/// file with sandboxing disabled. See
|
||||
/// https://developer.apple.com/documentation/security/app_sandbox/accessing_files_from_the_macos_app_sandbox.
|
||||
File? _createDisabledSandboxEntitlementFile(
|
||||
String platformDirectory,
|
||||
String configuration,
|
||||
) {
|
||||
File? _createDisabledSandboxEntitlementFile(String platformDirectory, String configuration) {
|
||||
String entitlementDefaultFileName;
|
||||
if (configuration == 'Release') {
|
||||
entitlementDefaultFileName = 'Release';
|
||||
@@ -283,15 +241,15 @@ File? _createDisabledSandboxEntitlementFile(
|
||||
return null;
|
||||
}
|
||||
|
||||
final String originalEntitlementFileContents =
|
||||
entitlementFile.readAsStringSync();
|
||||
final String tempEntitlementPath = Directory.systemTemp
|
||||
.createTempSync('flutter_disable_sandbox_entitlement.')
|
||||
.path;
|
||||
final File disabledSandboxEntitlementFile = File(path.join(
|
||||
tempEntitlementPath,
|
||||
'${entitlementDefaultFileName}WithDisabledSandboxing.entitlements',
|
||||
));
|
||||
final String originalEntitlementFileContents = entitlementFile.readAsStringSync();
|
||||
final String tempEntitlementPath =
|
||||
Directory.systemTemp.createTempSync('flutter_disable_sandbox_entitlement.').path;
|
||||
final File disabledSandboxEntitlementFile = File(
|
||||
path.join(
|
||||
tempEntitlementPath,
|
||||
'${entitlementDefaultFileName}WithDisabledSandboxing.entitlements',
|
||||
),
|
||||
);
|
||||
disabledSandboxEntitlementFile.createSync(recursive: true);
|
||||
disabledSandboxEntitlementFile.writeAsStringSync(
|
||||
originalEntitlementFileContents.replaceAll(
|
||||
@@ -307,14 +265,5 @@ File? _createDisabledSandboxEntitlementFile(
|
||||
|
||||
/// Returns global (external) symbol table entries, delimited by new lines.
|
||||
Future<String> dumpSymbolTable(String filePath) {
|
||||
return eval(
|
||||
'nm',
|
||||
<String>[
|
||||
'--extern-only',
|
||||
'--just-symbol-name',
|
||||
filePath,
|
||||
'-arch',
|
||||
'arm64',
|
||||
],
|
||||
);
|
||||
return eval('nm', <String>['--extern-only', '--just-symbol-name', filePath, '-arch', 'arm64']);
|
||||
}
|
||||
|
||||
@@ -52,7 +52,11 @@ Future<FlutterDestination> connectFlutterDestination() async {
|
||||
/// "host_type": "linux",
|
||||
/// "host_version": "debian-10.11"
|
||||
/// }
|
||||
List<MetricPoint> parse(Map<String, dynamic> resultsJson, Map<String, dynamic> benchmarkTags, String taskName) {
|
||||
List<MetricPoint> parse(
|
||||
Map<String, dynamic> resultsJson,
|
||||
Map<String, dynamic> benchmarkTags,
|
||||
String taskName,
|
||||
) {
|
||||
print('Results to upload to skia perf: $resultsJson');
|
||||
print('Benchmark tags to upload to skia perf: $benchmarkTags');
|
||||
final List<String> scoreKeys =
|
||||
@@ -72,13 +76,12 @@ List<MetricPoint> parse(Map<String, dynamic> resultsJson, Map<String, dynamic> b
|
||||
};
|
||||
// Append additional benchmark tags, which will surface in Skia Perf dashboards.
|
||||
tags = mergeMaps<String, String>(
|
||||
tags, benchmarkTags.map((String key, dynamic value) => MapEntry<String, String>(key, value.toString())));
|
||||
metricPoints.add(
|
||||
MetricPoint(
|
||||
(resultData[scoreKey] as num).toDouble(),
|
||||
tags,
|
||||
tags,
|
||||
benchmarkTags.map(
|
||||
(String key, dynamic value) => MapEntry<String, String>(key, value.toString()),
|
||||
),
|
||||
);
|
||||
metricPoints.add(MetricPoint((resultData[scoreKey] as num).toDouble(), tags));
|
||||
}
|
||||
return metricPoints;
|
||||
}
|
||||
@@ -100,10 +103,7 @@ Future<void> upload(
|
||||
) async {
|
||||
await metricsDestination.update(
|
||||
metricPoints,
|
||||
DateTime.fromMillisecondsSinceEpoch(
|
||||
commitTimeSinceEpoch,
|
||||
isUtc: true,
|
||||
),
|
||||
DateTime.fromMillisecondsSinceEpoch(commitTimeSinceEpoch, isUtc: true),
|
||||
taskName,
|
||||
);
|
||||
}
|
||||
@@ -114,7 +114,12 @@ Future<void> upload(
|
||||
/// 1. Run DeviceLab test, writing results to a known path
|
||||
/// 2. Request service account token from luci auth (valid for at least 3 minutes)
|
||||
/// 3. Upload results from (1) to skia perf.
|
||||
Future<void> uploadToSkiaPerf(String? resultsPath, String? commitTime, String? taskName, String? benchmarkTags) async {
|
||||
Future<void> uploadToSkiaPerf(
|
||||
String? resultsPath,
|
||||
String? commitTime,
|
||||
String? taskName,
|
||||
String? benchmarkTags,
|
||||
) async {
|
||||
int commitTimeSinceEpoch;
|
||||
if (resultsPath == null) {
|
||||
return;
|
||||
@@ -125,7 +130,8 @@ Future<void> uploadToSkiaPerf(String? resultsPath, String? commitTime, String? t
|
||||
commitTimeSinceEpoch = DateTime.now().millisecondsSinceEpoch;
|
||||
}
|
||||
taskName = taskName ?? 'default';
|
||||
final Map<String, dynamic> benchmarkTagsMap = jsonDecode(benchmarkTags ?? '{}') as Map<String, dynamic>;
|
||||
final Map<String, dynamic> benchmarkTagsMap =
|
||||
jsonDecode(benchmarkTags ?? '{}') as Map<String, dynamic>;
|
||||
final File resultFile = File(resultsPath);
|
||||
Map<String, dynamic> resultsJson = <String, dynamic>{};
|
||||
resultsJson = json.decode(await resultFile.readAsString()) as Map<String, dynamic>;
|
||||
@@ -150,10 +156,7 @@ Future<void> uploadToSkiaPerf(String? resultsPath, String? commitTime, String? t
|
||||
/// For example:
|
||||
/// Old file name: `backdrop_filter_perf__timeline_summary`
|
||||
/// New file name: `backdrop_filter_perf__timeline_summary_intel_linux_motoG4`
|
||||
String metricFileName(
|
||||
String taskName,
|
||||
Map<String, dynamic> benchmarkTagsMap,
|
||||
) {
|
||||
String metricFileName(String taskName, Map<String, dynamic> benchmarkTagsMap) {
|
||||
final StringBuffer fileName = StringBuffer(taskName);
|
||||
if (benchmarkTagsMap.containsKey('arch')) {
|
||||
fileName
|
||||
|
||||
@@ -74,7 +74,9 @@ Future<void> runTasks(
|
||||
} else {
|
||||
section('Flaky status for "$taskName"');
|
||||
if (failureCount > 0) {
|
||||
print('Total ${failureCount+1} executions: $failureCount failures and 1 false positive.');
|
||||
print(
|
||||
'Total ${failureCount + 1} executions: $failureCount failures and 1 false positive.',
|
||||
);
|
||||
print('flaky: true');
|
||||
// TODO(ianh): stop ignoring this failure. We should set exitCode=1, and quit
|
||||
// if exitOnFirstTestFailure is true.
|
||||
@@ -197,17 +199,16 @@ Future<TaskResult> runTask(
|
||||
taskExecutable,
|
||||
...?taskArgs,
|
||||
],
|
||||
environment: <String, String>{
|
||||
if (deviceId != null)
|
||||
DeviceIdEnvName: deviceId,
|
||||
},
|
||||
environment: <String, String>{if (deviceId != null) DeviceIdEnvName: deviceId},
|
||||
);
|
||||
|
||||
bool runnerFinished = false;
|
||||
|
||||
unawaited(runner.exitCode.whenComplete(() {
|
||||
runnerFinished = true;
|
||||
}));
|
||||
unawaited(
|
||||
runner.exitCode.whenComplete(() {
|
||||
runnerFinished = true;
|
||||
}),
|
||||
);
|
||||
|
||||
final Completer<Uri> uri = Completer<Uri>();
|
||||
|
||||
@@ -215,42 +216,44 @@ Future<TaskResult> runTask(
|
||||
.transform<String>(const Utf8Decoder())
|
||||
.transform<String>(const LineSplitter())
|
||||
.listen((String line) {
|
||||
if (!uri.isCompleted) {
|
||||
final Uri? serviceUri = parseServiceUri(line, prefix: RegExp('The Dart VM service is listening on '));
|
||||
if (serviceUri != null) {
|
||||
uri.complete(serviceUri);
|
||||
}
|
||||
}
|
||||
if (!silent) {
|
||||
stdout.writeln('[${DateTime.now()}] [STDOUT] $line');
|
||||
}
|
||||
});
|
||||
if (!uri.isCompleted) {
|
||||
final Uri? serviceUri = parseServiceUri(
|
||||
line,
|
||||
prefix: RegExp('The Dart VM service is listening on '),
|
||||
);
|
||||
if (serviceUri != null) {
|
||||
uri.complete(serviceUri);
|
||||
}
|
||||
}
|
||||
if (!silent) {
|
||||
stdout.writeln('[${DateTime.now()}] [STDOUT] $line');
|
||||
}
|
||||
});
|
||||
|
||||
final StreamSubscription<String> stderrSub = runner.stderr
|
||||
.transform<String>(const Utf8Decoder())
|
||||
.transform<String>(const LineSplitter())
|
||||
.listen((String line) {
|
||||
stderr.writeln('[${DateTime.now()}] [STDERR] $line');
|
||||
});
|
||||
stderr.writeln('[${DateTime.now()}] [STDERR] $line');
|
||||
});
|
||||
|
||||
try {
|
||||
final ConnectionResult result = await _connectToRunnerIsolate(await uri.future);
|
||||
print('[$taskName] Connected to VM server.');
|
||||
isolateParams = isolateParams == null ? <String, String>{} : Map<String, String>.of(isolateParams);
|
||||
isolateParams =
|
||||
isolateParams == null ? <String, String>{} : Map<String, String>.of(isolateParams);
|
||||
isolateParams['runProcessCleanup'] = terminateStrayDartProcesses.toString();
|
||||
final VmService service = result.vmService;
|
||||
final String isolateId = result.isolate.id!;
|
||||
final Map<String, dynamic> taskResultJson = (await service.callServiceExtension(
|
||||
'ext.cocoonRunTask',
|
||||
args: isolateParams,
|
||||
isolateId: isolateId,
|
||||
)).json!;
|
||||
final Map<String, dynamic> taskResultJson =
|
||||
(await service.callServiceExtension(
|
||||
'ext.cocoonRunTask',
|
||||
args: isolateParams,
|
||||
isolateId: isolateId,
|
||||
)).json!;
|
||||
// Notify the task process that the task result has been received and it
|
||||
// can proceed to shutdown.
|
||||
await _acknowledgeTaskResultReceived(
|
||||
service: service,
|
||||
isolateId: isolateId,
|
||||
);
|
||||
await _acknowledgeTaskResultReceived(service: service, isolateId: isolateId);
|
||||
final TaskResult taskResult = TaskResult.fromJson(taskResultJson);
|
||||
final int exitCode = await runner.exitCode;
|
||||
print('[$taskName] Process terminated with exit code $exitCode.');
|
||||
@@ -288,7 +291,10 @@ Future<ConnectionResult> _connectToRunnerIsolate(Uri vmServiceUri) async {
|
||||
}
|
||||
final IsolateRef isolate = vm.isolates!.first;
|
||||
// Sanity check to ensure we're talking with the main isolate.
|
||||
final Response response = await client.callServiceExtension('ext.cocoonRunnerReady', isolateId: isolate.id);
|
||||
final Response response = await client.callServiceExtension(
|
||||
'ext.cocoonRunnerReady',
|
||||
isolateId: isolate.id,
|
||||
);
|
||||
if (response.json!['result'] != 'success') {
|
||||
throw 'not ready yet';
|
||||
}
|
||||
@@ -309,14 +315,11 @@ Future<ConnectionResult> _connectToRunnerIsolate(Uri vmServiceUri) async {
|
||||
}
|
||||
|
||||
Future<void> _acknowledgeTaskResultReceived({
|
||||
required VmService service,
|
||||
required String isolateId,
|
||||
}) async {
|
||||
required VmService service,
|
||||
required String isolateId,
|
||||
}) async {
|
||||
try {
|
||||
await service.callServiceExtension(
|
||||
'ext.cocoonTaskResultReceived',
|
||||
isolateId: isolateId,
|
||||
);
|
||||
await service.callServiceExtension('ext.cocoonTaskResultReceived', isolateId: isolateId);
|
||||
} on RPCError {
|
||||
// The target VM may shutdown before the response is received.
|
||||
}
|
||||
|
||||
@@ -17,10 +17,10 @@ class RunningProcessInfo {
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
return other is RunningProcessInfo
|
||||
&& other.pid == pid
|
||||
&& other.commandLine == commandLine
|
||||
&& other.creationDate == creationDate;
|
||||
return other is RunningProcessInfo &&
|
||||
other.pid == pid &&
|
||||
other.commandLine == commandLine &&
|
||||
other.creationDate == creationDate;
|
||||
}
|
||||
|
||||
Future<bool> terminate({required ProcessManager processManager}) async {
|
||||
@@ -30,7 +30,7 @@ class RunningProcessInfo {
|
||||
// TODO(ianh): Move Windows to killPid once we can.
|
||||
// - killPid on Windows has not-useful return code: https://github.com/dart-lang/sdk/issues/47675
|
||||
final ProcessResult result = await processManager.run(<String>[
|
||||
'taskkill.exe',
|
||||
'taskkill.exe',
|
||||
'/pid',
|
||||
'$pid',
|
||||
'/f',
|
||||
@@ -66,15 +66,13 @@ Future<Set<RunningProcessInfo>> windowsRunningProcesses(
|
||||
) async {
|
||||
// PowerShell script to get the command line arguments and create time of a process.
|
||||
// See: https://docs.microsoft.com/en-us/windows/desktop/cimwin32prov/win32-process
|
||||
final String script = processName != null
|
||||
? '"Get-CimInstance Win32_Process -Filter \\"name=\'$processName\'\\" | Select-Object ProcessId,CreationDate,CommandLine | Format-Table -AutoSize | Out-String -Width 4096"'
|
||||
: '"Get-CimInstance Win32_Process | Select-Object ProcessId,CreationDate,CommandLine | Format-Table -AutoSize | Out-String -Width 4096"';
|
||||
final String script =
|
||||
processName != null
|
||||
? '"Get-CimInstance Win32_Process -Filter \\"name=\'$processName\'\\" | Select-Object ProcessId,CreationDate,CommandLine | Format-Table -AutoSize | Out-String -Width 4096"'
|
||||
: '"Get-CimInstance Win32_Process | Select-Object ProcessId,CreationDate,CommandLine | Format-Table -AutoSize | Out-String -Width 4096"';
|
||||
// TODO(ianh): Unfortunately, there doesn't seem to be a good way to get
|
||||
// ProcessManager to run this.
|
||||
final ProcessResult result = await Process.run(
|
||||
'powershell -command $script',
|
||||
<String>[],
|
||||
);
|
||||
final ProcessResult result = await Process.run('powershell -command $script', <String>[]);
|
||||
if (result.exitCode != 0) {
|
||||
print('Could not list processes!');
|
||||
print(result.stderr);
|
||||
@@ -115,10 +113,7 @@ Iterable<RunningProcessInfo> processPowershellOutput(String output) sync* {
|
||||
|
||||
// 3/11/2019 11:01:54 AM
|
||||
// 12/11/2019 11:01:54 AM
|
||||
String rawTime = line.substring(
|
||||
creationDateHeaderStart,
|
||||
creationDateHeaderEnd,
|
||||
).trim();
|
||||
String rawTime = line.substring(creationDateHeaderStart, creationDateHeaderEnd).trim();
|
||||
|
||||
if (rawTime[1] == '/') {
|
||||
rawTime = '0$rawTime';
|
||||
@@ -177,10 +172,7 @@ Future<Set<RunningProcessInfo>> posixRunningProcesses(
|
||||
/// Sat Mar 9 20:12:47 2019 1 /sbin/launchd
|
||||
/// Sat Mar 9 20:13:00 2019 49 /usr/sbin/syslogd
|
||||
@visibleForTesting
|
||||
Iterable<RunningProcessInfo> processPsOutput(
|
||||
String output,
|
||||
String? processName,
|
||||
) sync* {
|
||||
Iterable<RunningProcessInfo> processPsOutput(String output, String? processName) sync* {
|
||||
bool inTableBody = false;
|
||||
for (String line in output.split('\n')) {
|
||||
if (line.trim().startsWith('STARTED')) {
|
||||
|
||||
@@ -8,7 +8,8 @@ import 'package:path/path.dart' as path;
|
||||
import 'package:pub_semver/pub_semver.dart';
|
||||
|
||||
String adbPath() {
|
||||
final String? androidHome = io.Platform.environment['ANDROID_HOME'] ?? io.Platform.environment['ANDROID_SDK_ROOT'];
|
||||
final String? androidHome =
|
||||
io.Platform.environment['ANDROID_HOME'] ?? io.Platform.environment['ANDROID_SDK_ROOT'];
|
||||
if (androidHome == null) {
|
||||
return 'adb';
|
||||
} else {
|
||||
@@ -24,7 +25,9 @@ Future<Version> getTalkbackVersion() async {
|
||||
'com.google.android.marvin.talkback',
|
||||
]);
|
||||
if (result.exitCode != 0) {
|
||||
throw Exception('Failed to get TalkBack version: ${result.stdout as String}\n${result.stderr as String}');
|
||||
throw Exception(
|
||||
'Failed to get TalkBack version: ${result.stdout as String}\n${result.stderr as String}',
|
||||
);
|
||||
}
|
||||
final List<String> lines = (result.stdout as String).split('\n');
|
||||
String? version;
|
||||
@@ -39,7 +42,9 @@ Future<Version> getTalkbackVersion() async {
|
||||
}
|
||||
|
||||
// Android doesn't quite use semver, so convert the version string to semver form.
|
||||
final RegExp startVersion = RegExp(r'(?<major>\d+)\.(?<minor>\d+)\.(?<patch>\d+)(\.(?<build>\d+))?');
|
||||
final RegExp startVersion = RegExp(
|
||||
r'(?<major>\d+)\.(?<minor>\d+)\.(?<patch>\d+)(\.(?<build>\d+))?',
|
||||
);
|
||||
final RegExpMatch? match = startVersion.firstMatch(version);
|
||||
if (match == null) {
|
||||
return Version(0, 0, 0);
|
||||
|
||||
@@ -8,19 +8,19 @@ import 'dart:io';
|
||||
/// A result of running a single task.
|
||||
class TaskResult {
|
||||
TaskResult.buildOnly()
|
||||
: succeeded = true,
|
||||
data = null,
|
||||
detailFiles = null,
|
||||
benchmarkScoreKeys = null,
|
||||
message = 'No tests run';
|
||||
: succeeded = true,
|
||||
data = null,
|
||||
detailFiles = null,
|
||||
benchmarkScoreKeys = null,
|
||||
message = 'No tests run';
|
||||
|
||||
/// Constructs a successful result.
|
||||
TaskResult.success(this.data, {
|
||||
TaskResult.success(
|
||||
this.data, {
|
||||
this.benchmarkScoreKeys = const <String>[],
|
||||
this.detailFiles = const <String>[],
|
||||
this.message = 'success',
|
||||
})
|
||||
: succeeded = true {
|
||||
}) : succeeded = true {
|
||||
const JsonEncoder prettyJson = JsonEncoder.withIndent(' ');
|
||||
if (benchmarkScoreKeys != null) {
|
||||
for (final String key in benchmarkScoreKeys!) {
|
||||
@@ -36,7 +36,8 @@ class TaskResult {
|
||||
}
|
||||
|
||||
/// Constructs a successful result using JSON data stored in a file.
|
||||
factory TaskResult.successFromFile(File file, {
|
||||
factory TaskResult.successFromFile(
|
||||
File file, {
|
||||
List<String> benchmarkScoreKeys = const <String>[],
|
||||
List<String> detailFiles = const <String>[],
|
||||
}) {
|
||||
@@ -51,9 +52,12 @@ class TaskResult {
|
||||
factory TaskResult.fromJson(Map<String, dynamic> json) {
|
||||
final bool success = json['success'] as bool;
|
||||
if (success) {
|
||||
final List<String> benchmarkScoreKeys = (json['benchmarkScoreKeys'] as List<dynamic>? ?? <String>[]).cast<String>();
|
||||
final List<String> detailFiles = (json['detailFiles'] as List<dynamic>? ?? <String>[]).cast<String>();
|
||||
return TaskResult.success(json['data'] as Map<String, dynamic>?,
|
||||
final List<String> benchmarkScoreKeys =
|
||||
(json['benchmarkScoreKeys'] as List<dynamic>? ?? <String>[]).cast<String>();
|
||||
final List<String> detailFiles =
|
||||
(json['detailFiles'] as List<dynamic>? ?? <String>[]).cast<String>();
|
||||
return TaskResult.success(
|
||||
json['data'] as Map<String, dynamic>?,
|
||||
benchmarkScoreKeys: benchmarkScoreKeys,
|
||||
detailFiles: detailFiles,
|
||||
message: json['reason'] as String?,
|
||||
@@ -65,10 +69,10 @@ class TaskResult {
|
||||
|
||||
/// Constructs an unsuccessful result.
|
||||
TaskResult.failure(this.message)
|
||||
: succeeded = false,
|
||||
data = null,
|
||||
detailFiles = null,
|
||||
benchmarkScoreKeys = null;
|
||||
: succeeded = false,
|
||||
data = null,
|
||||
detailFiles = null,
|
||||
benchmarkScoreKeys = null;
|
||||
|
||||
/// Whether the task succeeded.
|
||||
final bool succeeded;
|
||||
@@ -106,9 +110,7 @@ class TaskResult {
|
||||
/// "reason": failure reason string valid only for unsuccessful results
|
||||
/// }
|
||||
Map<String, dynamic> toJson() {
|
||||
final Map<String, dynamic> json = <String, dynamic>{
|
||||
'success': succeeded,
|
||||
};
|
||||
final Map<String, dynamic> json = <String, dynamic>{'success': succeeded};
|
||||
|
||||
if (succeeded) {
|
||||
json['data'] = data;
|
||||
|
||||
@@ -67,8 +67,7 @@ class ProcessInfo {
|
||||
command: $command
|
||||
started: $startTime
|
||||
pid : ${process.pid}
|
||||
'''
|
||||
.trim();
|
||||
'''.trim();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -77,8 +76,8 @@ class HealthCheckResult {
|
||||
HealthCheckResult.success([this.details]) : succeeded = true;
|
||||
HealthCheckResult.failure(this.details) : succeeded = false;
|
||||
HealthCheckResult.error(dynamic error, dynamic stackTrace)
|
||||
: succeeded = false,
|
||||
details = 'ERROR: $error${stackTrace != null ? '\n$stackTrace' : ''}';
|
||||
: succeeded = false,
|
||||
details = 'ERROR: $error${stackTrace != null ? '\n$stackTrace' : ''}';
|
||||
|
||||
final bool succeeded;
|
||||
final String? details;
|
||||
@@ -111,7 +110,7 @@ void fail(String message) {
|
||||
}
|
||||
|
||||
// Remove the given file or directory.
|
||||
void rm(FileSystemEntity entity, { bool recursive = false}) {
|
||||
void rm(FileSystemEntity entity, {bool recursive = false}) {
|
||||
if (entity.existsSync()) {
|
||||
// This should not be necessary, but it turns out that
|
||||
// on Windows it's common for deletions to fail due to
|
||||
@@ -136,8 +135,7 @@ Directory dir(String path) => Directory(path);
|
||||
File file(String path) => File(path);
|
||||
|
||||
void copy(File sourceFile, Directory targetDirectory, {String? name}) {
|
||||
final File target = file(
|
||||
path.join(targetDirectory.path, name ?? path.basename(sourceFile.path)));
|
||||
final File target = file(path.join(targetDirectory.path, name ?? path.basename(sourceFile.path)));
|
||||
target.writeAsBytesSync(sourceFile.readAsBytesSync());
|
||||
}
|
||||
|
||||
@@ -162,10 +160,8 @@ void recursiveCopy(Directory source, Directory target) {
|
||||
}
|
||||
}
|
||||
|
||||
FileSystemEntity move(FileSystemEntity whatToMove,
|
||||
{required Directory to, String? name}) {
|
||||
return whatToMove
|
||||
.renameSync(path.join(to.path, name ?? path.basename(whatToMove.path)));
|
||||
FileSystemEntity move(FileSystemEntity whatToMove, {required Directory to, String? name}) {
|
||||
return whatToMove.renameSync(path.join(to.path, name ?? path.basename(whatToMove.path)));
|
||||
}
|
||||
|
||||
/// Equivalent of `chmod a+x file`
|
||||
@@ -174,11 +170,7 @@ void makeExecutable(File file) {
|
||||
if (Platform.isWindows) {
|
||||
return;
|
||||
}
|
||||
final ProcessResult result = _processManager.runSync(<String>[
|
||||
'chmod',
|
||||
'a+x',
|
||||
file.path,
|
||||
]);
|
||||
final ProcessResult result = _processManager.runSync(<String>['chmod', 'a+x', file.path]);
|
||||
|
||||
if (result.exitCode != 0) {
|
||||
throw FileSystemException(
|
||||
@@ -250,12 +242,7 @@ Future<String?> getCurrentFlutterRepoCommit() {
|
||||
Future<DateTime> getFlutterRepoCommitTimestamp(String commit) {
|
||||
// git show -s --format=%at 4b546df7f0b3858aaaa56c4079e5be1ba91fbb65
|
||||
return inDirectory<DateTime>(flutterDirectory, () async {
|
||||
final String unixTimestamp = await eval('git', <String>[
|
||||
'show',
|
||||
'-s',
|
||||
'--format=%at',
|
||||
commit,
|
||||
]);
|
||||
final String unixTimestamp = await eval('git', <String>['show', '-s', '--format=%at', commit]);
|
||||
final int secondsSinceEpoch = int.parse(unixTimestamp);
|
||||
return DateTime.fromMillisecondsSinceEpoch(secondsSinceEpoch * 1000);
|
||||
});
|
||||
@@ -289,12 +276,15 @@ Future<Process> startProcess(
|
||||
String executable,
|
||||
List<String>? arguments, {
|
||||
Map<String, String>? environment,
|
||||
bool isBot = true, // set to false to pretend not to be on a bot (e.g. to test user-facing outputs)
|
||||
bool isBot =
|
||||
true, // set to false to pretend not to be on a bot (e.g. to test user-facing outputs)
|
||||
String? workingDirectory,
|
||||
}) async {
|
||||
final String command = '$executable ${arguments?.join(" ") ?? ""}';
|
||||
final String finalWorkingDirectory = workingDirectory ?? cwd;
|
||||
final Map<String, String> newEnvironment = Map<String, String>.from(environment ?? <String, String>{});
|
||||
final Map<String, String> newEnvironment = Map<String, String>.from(
|
||||
environment ?? <String, String>{},
|
||||
);
|
||||
newEnvironment['BOT'] = isBot ? 'true' : 'false';
|
||||
newEnvironment['LANG'] = 'en_US.UTF-8';
|
||||
print('Executing "$command" in "$finalWorkingDirectory" with environment $newEnvironment');
|
||||
@@ -307,9 +297,11 @@ Future<Process> startProcess(
|
||||
final ProcessInfo processInfo = ProcessInfo(command, process);
|
||||
_runningProcesses.add(processInfo);
|
||||
|
||||
unawaited(process.exitCode.then<void>((int exitCode) {
|
||||
_runningProcesses.remove(processInfo);
|
||||
}));
|
||||
unawaited(
|
||||
process.exitCode.then<void>((int exitCode) {
|
||||
_runningProcesses.remove(processInfo);
|
||||
}),
|
||||
);
|
||||
|
||||
return process;
|
||||
}
|
||||
@@ -346,7 +338,7 @@ Future<int> exec(
|
||||
executable,
|
||||
arguments,
|
||||
environment: environment,
|
||||
canFail : canFail,
|
||||
canFail: canFail,
|
||||
workingDirectory: workingDirectory,
|
||||
output: output,
|
||||
stderr: stderr,
|
||||
@@ -397,32 +389,39 @@ Future<void> forwardStandardStreams(
|
||||
StringBuffer? stderr,
|
||||
bool printStdout = true,
|
||||
bool printStderr = true,
|
||||
}) {
|
||||
}) {
|
||||
final Completer<void> stdoutDone = Completer<void>();
|
||||
final Completer<void> stderrDone = Completer<void>();
|
||||
process.stdout
|
||||
.transform<String>(utf8.decoder)
|
||||
.transform<String>(const LineSplitter())
|
||||
.listen((String line) {
|
||||
if (printStdout) {
|
||||
print('stdout: $line');
|
||||
}
|
||||
output?.writeln(line);
|
||||
}, onDone: () { stdoutDone.complete(); });
|
||||
.transform<String>(utf8.decoder)
|
||||
.transform<String>(const LineSplitter())
|
||||
.listen(
|
||||
(String line) {
|
||||
if (printStdout) {
|
||||
print('stdout: $line');
|
||||
}
|
||||
output?.writeln(line);
|
||||
},
|
||||
onDone: () {
|
||||
stdoutDone.complete();
|
||||
},
|
||||
);
|
||||
process.stderr
|
||||
.transform<String>(utf8.decoder)
|
||||
.transform<String>(const LineSplitter())
|
||||
.listen((String line) {
|
||||
if (printStderr) {
|
||||
print('stderr: $line');
|
||||
}
|
||||
stderr?.writeln(line);
|
||||
}, onDone: () { stderrDone.complete(); });
|
||||
.transform<String>(utf8.decoder)
|
||||
.transform<String>(const LineSplitter())
|
||||
.listen(
|
||||
(String line) {
|
||||
if (printStderr) {
|
||||
print('stderr: $line');
|
||||
}
|
||||
stderr?.writeln(line);
|
||||
},
|
||||
onDone: () {
|
||||
stderrDone.complete();
|
||||
},
|
||||
);
|
||||
|
||||
return Future.wait<void>(<Future<void>>[
|
||||
stdoutDone.future,
|
||||
stderrDone.future,
|
||||
]);
|
||||
return Future.wait<void>(<Future<void>>[stdoutDone.future, stderrDone.future]);
|
||||
}
|
||||
|
||||
/// Executes a command and returns its standard output as a String.
|
||||
@@ -476,11 +475,8 @@ List<String> _flutterCommandArgs(
|
||||
final bool pubOrPackagesCommand = command.startsWith('packages') || command.startsWith('pub');
|
||||
return <String>[
|
||||
command,
|
||||
if (deviceOperatingSystem == DeviceOperatingSystem.ios && supportedDeviceTimeoutCommands.contains(command))
|
||||
...<String>[
|
||||
'--device-timeout',
|
||||
'5',
|
||||
],
|
||||
if (deviceOperatingSystem == DeviceOperatingSystem.ios &&
|
||||
supportedDeviceTimeoutCommands.contains(command)) ...<String>['--device-timeout', '5'],
|
||||
|
||||
// DDS should generally be disabled for flutter drive in CI.
|
||||
// See https://github.com/flutter/flutter/issues/152684.
|
||||
@@ -500,34 +496,33 @@ List<String> _flutterCommandArgs(
|
||||
// the same allowed args.
|
||||
if (!pubOrPackagesCommand) '--ci',
|
||||
if (!pubOrPackagesCommand && hostAgent.dumpDirectory != null)
|
||||
'--debug-logs-dir=${hostAgent.dumpDirectory!.path}'
|
||||
'--debug-logs-dir=${hostAgent.dumpDirectory!.path}',
|
||||
];
|
||||
}
|
||||
|
||||
/// Runs the flutter `command`, and returns the exit code.
|
||||
/// If `canFail` is `false`, the future completes with an error.
|
||||
Future<int> flutter(String command, {
|
||||
Future<int> flutter(
|
||||
String command, {
|
||||
List<String> options = const <String>[],
|
||||
bool canFail = false, // as in, whether failures are ok. False means that they are fatal.
|
||||
bool driveWithDds = false, // `flutter drive` tests should generally have dds disabled.
|
||||
// The exception is tests that also exercise DevTools, such as
|
||||
// DevToolsMemoryTest in perf_tests.dart.
|
||||
bool driveWithDds = false, // `flutter drive` tests should generally have dds disabled.
|
||||
// The exception is tests that also exercise DevTools, such as
|
||||
// DevToolsMemoryTest in perf_tests.dart.
|
||||
Map<String, String>? environment,
|
||||
String? workingDirectory,
|
||||
StringBuffer? output, // if not null, the stdout will be written here
|
||||
StringBuffer? stderr, // if not null, the stderr will be written here
|
||||
}) async {
|
||||
final List<String> args = _flutterCommandArgs(
|
||||
command, options, driveWithDds: driveWithDds,
|
||||
);
|
||||
final List<String> args = _flutterCommandArgs(command, options, driveWithDds: driveWithDds);
|
||||
final int exitCode = await exec(
|
||||
path.join(flutterDirectory.path, 'bin', 'flutter'),
|
||||
args,
|
||||
canFail: canFail,
|
||||
environment: environment,
|
||||
workingDirectory: workingDirectory,
|
||||
output: output,
|
||||
stderr: stderr,
|
||||
path.join(flutterDirectory.path, 'bin', 'flutter'),
|
||||
args,
|
||||
canFail: canFail,
|
||||
environment: environment,
|
||||
workingDirectory: workingDirectory,
|
||||
output: output,
|
||||
stderr: stderr,
|
||||
);
|
||||
|
||||
if (exitCode != 0 && !canFail) {
|
||||
@@ -558,10 +553,12 @@ Future<int> flutter(String command, {
|
||||
///
|
||||
/// The actual process executes asynchronously. A handle to the subprocess is
|
||||
/// returned in the form of a [Future] that completes to a [Process] object.
|
||||
Future<Process> startFlutter(String command, {
|
||||
Future<Process> startFlutter(
|
||||
String command, {
|
||||
List<String> options = const <String>[],
|
||||
Map<String, String> environment = const <String, String>{},
|
||||
bool isBot = true, // set to false to pretend not to be on a bot (e.g. to test user-facing outputs)
|
||||
bool isBot =
|
||||
true, // set to false to pretend not to be on a bot (e.g. to test user-facing outputs)
|
||||
String? workingDirectory,
|
||||
}) async {
|
||||
final List<String> args = _flutterCommandArgs(command, options);
|
||||
@@ -573,16 +570,19 @@ Future<Process> startFlutter(String command, {
|
||||
workingDirectory: workingDirectory,
|
||||
);
|
||||
|
||||
unawaited(process.exitCode.then<void>((int exitCode) async {
|
||||
if (exitCode != 0) {
|
||||
await _flutterScreenshot(workingDirectory: workingDirectory);
|
||||
}
|
||||
}));
|
||||
unawaited(
|
||||
process.exitCode.then<void>((int exitCode) async {
|
||||
if (exitCode != 0) {
|
||||
await _flutterScreenshot(workingDirectory: workingDirectory);
|
||||
}
|
||||
}),
|
||||
);
|
||||
return process;
|
||||
}
|
||||
|
||||
/// Runs a `flutter` command and returns the standard output as a string.
|
||||
Future<String> evalFlutter(String command, {
|
||||
Future<String> evalFlutter(
|
||||
String command, {
|
||||
List<String> options = const <String>[],
|
||||
bool canFail = false, // as in, whether failures are ok. False means that they are fatal.
|
||||
Map<String, String>? environment,
|
||||
@@ -590,19 +590,26 @@ Future<String> evalFlutter(String command, {
|
||||
String? workingDirectory,
|
||||
}) {
|
||||
final List<String> args = _flutterCommandArgs(command, options);
|
||||
return eval(path.join(flutterDirectory.path, 'bin', 'flutter'), args,
|
||||
canFail: canFail, environment: environment, stderr: stderr, workingDirectory: workingDirectory);
|
||||
return eval(
|
||||
path.join(flutterDirectory.path, 'bin', 'flutter'),
|
||||
args,
|
||||
canFail: canFail,
|
||||
environment: environment,
|
||||
stderr: stderr,
|
||||
workingDirectory: workingDirectory,
|
||||
);
|
||||
}
|
||||
|
||||
Future<ProcessResult> executeFlutter(String command, {
|
||||
Future<ProcessResult> executeFlutter(
|
||||
String command, {
|
||||
List<String> options = const <String>[],
|
||||
bool canFail = false, // as in, whether failures are ok. False means that they are fatal.
|
||||
}) async {
|
||||
final List<String> args = _flutterCommandArgs(command, options);
|
||||
final ProcessResult processResult = await _processManager.run(
|
||||
<String>[path.join(flutterDirectory.path, 'bin', 'flutter'), ...args],
|
||||
workingDirectory: cwd,
|
||||
);
|
||||
final ProcessResult processResult = await _processManager.run(<String>[
|
||||
path.join(flutterDirectory.path, 'bin', 'flutter'),
|
||||
...args,
|
||||
], workingDirectory: cwd);
|
||||
|
||||
if (processResult.exitCode != 0 && !canFail) {
|
||||
await _flutterScreenshot();
|
||||
@@ -610,7 +617,7 @@ Future<ProcessResult> executeFlutter(String command, {
|
||||
return processResult;
|
||||
}
|
||||
|
||||
Future<void> _flutterScreenshot({ String? workingDirectory }) async {
|
||||
Future<void> _flutterScreenshot({String? workingDirectory}) async {
|
||||
try {
|
||||
final Directory? dumpDirectory = hostAgent.dumpDirectory;
|
||||
if (dumpDirectory == null) {
|
||||
@@ -624,18 +631,16 @@ Future<void> _flutterScreenshot({ String? workingDirectory }) async {
|
||||
|
||||
final String deviceId = (await devices.workingDevice).deviceId;
|
||||
print('Taking screenshot of working device $deviceId at $screenshotPath');
|
||||
final List<String> args = _flutterCommandArgs(
|
||||
'screenshot',
|
||||
<String>[
|
||||
'--out',
|
||||
screenshotPath,
|
||||
'-d', deviceId,
|
||||
],
|
||||
);
|
||||
final ProcessResult screenshot = await _processManager.run(
|
||||
<String>[path.join(flutterDirectory.path, 'bin', 'flutter'), ...args],
|
||||
workingDirectory: workingDirectory ?? cwd,
|
||||
);
|
||||
final List<String> args = _flutterCommandArgs('screenshot', <String>[
|
||||
'--out',
|
||||
screenshotPath,
|
||||
'-d',
|
||||
deviceId,
|
||||
]);
|
||||
final ProcessResult screenshot = await _processManager.run(<String>[
|
||||
path.join(flutterDirectory.path, 'bin', 'flutter'),
|
||||
...args,
|
||||
], workingDirectory: workingDirectory ?? cwd);
|
||||
|
||||
if (screenshot.exitCode != 0) {
|
||||
print('Failed to take screenshot. Continuing.');
|
||||
@@ -645,11 +650,9 @@ Future<void> _flutterScreenshot({ String? workingDirectory }) async {
|
||||
}
|
||||
}
|
||||
|
||||
String get dartBin =>
|
||||
path.join(flutterDirectory.path, 'bin', 'cache', 'dart-sdk', 'bin', 'dart');
|
||||
String get dartBin => path.join(flutterDirectory.path, 'bin', 'cache', 'dart-sdk', 'bin', 'dart');
|
||||
|
||||
String get pubBin =>
|
||||
path.join(flutterDirectory.path, 'bin', 'cache', 'dart-sdk', 'bin', 'pub');
|
||||
String get pubBin => path.join(flutterDirectory.path, 'bin', 'cache', 'dart-sdk', 'bin', 'pub');
|
||||
|
||||
Future<int> dart(List<String> args) => exec(dartBin, args);
|
||||
|
||||
@@ -664,14 +667,13 @@ Future<String?> findJavaHome() async {
|
||||
if (hits.isEmpty) {
|
||||
return null;
|
||||
}
|
||||
final String javaBinary = hits.first
|
||||
.split(': ')
|
||||
.last;
|
||||
final String javaBinary = hits.first.split(': ').last;
|
||||
// javaBinary == /some/path/to/java/home/bin/java
|
||||
_javaHome = path.dirname(path.dirname(javaBinary));
|
||||
}
|
||||
return _javaHome;
|
||||
}
|
||||
|
||||
String? _javaHome;
|
||||
|
||||
Future<T> inDirectory<T>(dynamic directory, Future<T> Function() action) async {
|
||||
@@ -693,7 +695,10 @@ void cd(dynamic directory) {
|
||||
cwd = directory.path;
|
||||
d = directory;
|
||||
} else {
|
||||
throw FileSystemException('Unsupported directory type ${directory.runtimeType}', directory.toString());
|
||||
throw FileSystemException(
|
||||
'Unsupported directory type ${directory.runtimeType}',
|
||||
directory.toString(),
|
||||
);
|
||||
}
|
||||
|
||||
if (!d.existsSync()) {
|
||||
@@ -758,8 +763,7 @@ Future<void> runAndCaptureAsyncStacks(Future<void> Function() callback) {
|
||||
|
||||
bool canRun(String path) => _processManager.canRun(path);
|
||||
|
||||
final RegExp _obsRegExp =
|
||||
RegExp('A Dart VM Service .* is available at: ');
|
||||
final RegExp _obsRegExp = RegExp('A Dart VM Service .* is available at: ');
|
||||
final RegExp _obsPortRegExp = RegExp(r'(\S+:(\d+)/\S*)$');
|
||||
final RegExp _obsUriRegExp = RegExp(r'((http|//)[a-zA-Z0-9:/=_\-\.\[\]]+)');
|
||||
|
||||
@@ -767,17 +771,14 @@ final RegExp _obsUriRegExp = RegExp(r'((http|//)[a-zA-Z0-9:/=_\-\.\[\]]+)');
|
||||
///
|
||||
/// The `prefix`, if specified, is a regular expression pattern and must not contain groups.
|
||||
/// `prefix` defaults to the RegExp: `A Dart VM Service .* is available at: `.
|
||||
int? parseServicePort(String line, {
|
||||
Pattern? prefix,
|
||||
}) {
|
||||
int? parseServicePort(String line, {Pattern? prefix}) {
|
||||
prefix ??= _obsRegExp;
|
||||
final Iterable<Match> matchesIter = prefix.allMatches(line);
|
||||
if (matchesIter.isEmpty) {
|
||||
return null;
|
||||
}
|
||||
final Match prefixMatch = matchesIter.first;
|
||||
final List<Match> matches =
|
||||
_obsPortRegExp.allMatches(line, prefixMatch.end).toList();
|
||||
final List<Match> matches = _obsPortRegExp.allMatches(line, prefixMatch.end).toList();
|
||||
return matches.isEmpty ? null : int.parse(matches[0].group(2)!);
|
||||
}
|
||||
|
||||
@@ -785,17 +786,14 @@ int? parseServicePort(String line, {
|
||||
///
|
||||
/// The `prefix`, if specified, is a regular expression pattern and must not contain groups.
|
||||
/// `prefix` defaults to the RegExp: `A Dart VM Service .* is available at: `.
|
||||
Uri? parseServiceUri(String line, {
|
||||
Pattern? prefix,
|
||||
}) {
|
||||
Uri? parseServiceUri(String line, {Pattern? prefix}) {
|
||||
prefix ??= _obsRegExp;
|
||||
final Iterable<Match> matchesIter = prefix.allMatches(line);
|
||||
if (matchesIter.isEmpty) {
|
||||
return null;
|
||||
}
|
||||
final Match prefixMatch = matchesIter.first;
|
||||
final List<Match> matches =
|
||||
_obsUriRegExp.allMatches(line, prefixMatch.end).toList();
|
||||
final List<Match> matches = _obsUriRegExp.allMatches(line, prefixMatch.end).toList();
|
||||
return matches.isEmpty ? null : Uri.parse(matches[0].group(0)!);
|
||||
}
|
||||
|
||||
@@ -860,7 +858,7 @@ void checkFileContains(List<Pattern> patterns, String filePath) {
|
||||
if (!fileContent.contains(pattern)) {
|
||||
throw TaskResult.failure(
|
||||
'Expected to find `$pattern` in `$filePath` '
|
||||
'instead it found:\n$fileContent'
|
||||
'instead it found:\n$fileContent',
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -875,10 +873,7 @@ Future<int> gitClone({required String path, required String repo}) async {
|
||||
|
||||
await Directory(path).create(recursive: true);
|
||||
|
||||
return inDirectory<int>(
|
||||
path,
|
||||
() => exec('git', <String>['clone', repo]),
|
||||
);
|
||||
return inDirectory<int>(path, () => exec('git', <String>['clone', repo]));
|
||||
}
|
||||
|
||||
/// Call [fn] retrying so long as [retryIf] return `true` for the exception
|
||||
@@ -901,8 +896,7 @@ Future<T> retry<T>(
|
||||
try {
|
||||
return await fn();
|
||||
} on Exception catch (e) {
|
||||
if (attempt >= maxAttempts ||
|
||||
(retryIf != null && !(await retryIf(e)))) {
|
||||
if (attempt >= maxAttempts || (retryIf != null && !(await retryIf(e)))) {
|
||||
rethrow;
|
||||
}
|
||||
}
|
||||
@@ -924,12 +918,8 @@ Future<void> createFfiPackage(String name, Directory parent) async {
|
||||
name,
|
||||
],
|
||||
);
|
||||
await _pinDependencies(
|
||||
File(path.join(parent.path, name, 'pubspec.yaml')),
|
||||
);
|
||||
await _pinDependencies(
|
||||
File(path.join(parent.path, name, 'example', 'pubspec.yaml')),
|
||||
);
|
||||
await _pinDependencies(File(path.join(parent.path, name, 'pubspec.yaml')));
|
||||
await _pinDependencies(File(path.join(parent.path, name, 'example', 'pubspec.yaml')));
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -37,57 +37,53 @@ Future<Map<String, double>> readJsonResults(Process process) {
|
||||
.transform<String>(const Utf8Decoder())
|
||||
.transform<String>(const LineSplitter())
|
||||
.listen((String line) async {
|
||||
print('[STDOUT] $line');
|
||||
print('[STDOUT] $line');
|
||||
|
||||
if (line.contains(jsonStart)) {
|
||||
jsonStarted = true;
|
||||
return;
|
||||
}
|
||||
if (line.contains(jsonStart)) {
|
||||
jsonStarted = true;
|
||||
return;
|
||||
}
|
||||
|
||||
if (line.contains(testComplete)) {
|
||||
processWasKilledIntentionally = true;
|
||||
// Sending a SIGINT/SIGTERM to the process here isn't reliable because [process] is
|
||||
// the shell (flutter is a shell script) and doesn't pass the signal on.
|
||||
// Sending a `q` is an instruction to quit using the console runner.
|
||||
// See https://github.com/flutter/flutter/issues/19208
|
||||
process.stdin.write('q');
|
||||
await process.stdin.flush();
|
||||
// Give the process a couple of seconds to exit and run shutdown hooks
|
||||
// before sending kill signal.
|
||||
// TODO(fujino): https://github.com/flutter/flutter/issues/134566
|
||||
await Future<void>.delayed(const Duration(seconds: 2));
|
||||
// Also send a kill signal in case the `q` above didn't work.
|
||||
process.kill(ProcessSignal.sigint);
|
||||
try {
|
||||
final Map<String, double> results =
|
||||
Map<String, double>.from(<String, dynamic>{
|
||||
for (final String data in collectedJson)
|
||||
...json.decode(data) as Map<String, dynamic>
|
||||
});
|
||||
completer.complete(results);
|
||||
} catch (ex) {
|
||||
completer.completeError(
|
||||
'Decoding JSON failed ($ex). JSON strings where: $collectedJson');
|
||||
}
|
||||
return;
|
||||
}
|
||||
if (line.contains(testComplete)) {
|
||||
processWasKilledIntentionally = true;
|
||||
// Sending a SIGINT/SIGTERM to the process here isn't reliable because [process] is
|
||||
// the shell (flutter is a shell script) and doesn't pass the signal on.
|
||||
// Sending a `q` is an instruction to quit using the console runner.
|
||||
// See https://github.com/flutter/flutter/issues/19208
|
||||
process.stdin.write('q');
|
||||
await process.stdin.flush();
|
||||
// Give the process a couple of seconds to exit and run shutdown hooks
|
||||
// before sending kill signal.
|
||||
// TODO(fujino): https://github.com/flutter/flutter/issues/134566
|
||||
await Future<void>.delayed(const Duration(seconds: 2));
|
||||
// Also send a kill signal in case the `q` above didn't work.
|
||||
process.kill(ProcessSignal.sigint);
|
||||
try {
|
||||
final Map<String, double> results = Map<String, double>.from(<String, dynamic>{
|
||||
for (final String data in collectedJson) ...json.decode(data) as Map<String, dynamic>,
|
||||
});
|
||||
completer.complete(results);
|
||||
} catch (ex) {
|
||||
completer.completeError(
|
||||
'Decoding JSON failed ($ex). JSON strings where: $collectedJson',
|
||||
);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if (jsonStarted && line.contains(jsonEnd)) {
|
||||
collectedJson.add(jsonBuf.toString().trim());
|
||||
jsonBuf.clear();
|
||||
jsonStarted = false;
|
||||
}
|
||||
if (jsonStarted && line.contains(jsonEnd)) {
|
||||
collectedJson.add(jsonBuf.toString().trim());
|
||||
jsonBuf.clear();
|
||||
jsonStarted = false;
|
||||
}
|
||||
|
||||
if (jsonStarted && line.contains(jsonPrefix)) {
|
||||
jsonBuf.writeln(line.substring(line.indexOf(jsonPrefix) + jsonPrefix.length));
|
||||
}
|
||||
});
|
||||
if (jsonStarted && line.contains(jsonPrefix)) {
|
||||
jsonBuf.writeln(line.substring(line.indexOf(jsonPrefix) + jsonPrefix.length));
|
||||
}
|
||||
});
|
||||
|
||||
process.exitCode.then<void>((int code) async {
|
||||
await Future.wait<void>(<Future<void>>[
|
||||
stdoutSub.cancel(),
|
||||
stderrSub.cancel(),
|
||||
]);
|
||||
await Future.wait<void>(<Future<void>>[stdoutSub.cancel(), stderrSub.cancel()]);
|
||||
if (!processWasKilledIntentionally && code != 0) {
|
||||
completer.completeError('flutter run failed: exit code=$code');
|
||||
}
|
||||
|
||||
@@ -65,10 +65,7 @@ abstract class _Benchmark {
|
||||
|
||||
Directory get directory;
|
||||
|
||||
List<String> get options => <String>[
|
||||
'--benchmark',
|
||||
if (watch) '--watch',
|
||||
];
|
||||
List<String> get options => <String>['--benchmark', if (watch) '--watch'];
|
||||
|
||||
Future<double> execute(int iteration, int targetIterations) async {
|
||||
section('Analyze $title ${watch ? 'with watcher' : ''} - ${iteration + 1} / $targetIterations');
|
||||
|
||||
@@ -22,32 +22,22 @@ const List<String> kSentinelStr = <String>[
|
||||
/// This test fails if the application hangs during this period.
|
||||
/// https://ui.perfetto.dev/#!/?s=da6628c3a92456ae8fa3f345d0186e781da77e90fc8a64d073e9fee11d1e65
|
||||
/// Regression test for https://github.com/flutter/flutter/issues/98973
|
||||
TaskFunction androidChoreographerDoFrameTest({
|
||||
Map<String, String>? environment,
|
||||
}) {
|
||||
final Directory tempDir = Directory.systemTemp
|
||||
.createTempSync('flutter_devicelab_android_surface_recreation.');
|
||||
TaskFunction androidChoreographerDoFrameTest({Map<String, String>? environment}) {
|
||||
final Directory tempDir = Directory.systemTemp.createTempSync(
|
||||
'flutter_devicelab_android_surface_recreation.',
|
||||
);
|
||||
return () async {
|
||||
try {
|
||||
section('Create app');
|
||||
await inDirectory(tempDir, () async {
|
||||
await flutter(
|
||||
'create',
|
||||
options: <String>[
|
||||
'--platforms',
|
||||
'android',
|
||||
'app',
|
||||
],
|
||||
options: <String>['--platforms', 'android', 'app'],
|
||||
environment: environment,
|
||||
);
|
||||
});
|
||||
|
||||
final File mainDart = File(path.join(
|
||||
tempDir.absolute.path,
|
||||
'app',
|
||||
'lib',
|
||||
'main.dart',
|
||||
));
|
||||
final File mainDart = File(path.join(tempDir.absolute.path, 'app', 'lib', 'main.dart'));
|
||||
if (!mainDart.existsSync()) {
|
||||
return TaskResult.failure('${mainDart.path} does not exist');
|
||||
}
|
||||
@@ -88,59 +78,51 @@ Future<void> main() async {
|
||||
section('Flutter run (mode: $mode)');
|
||||
late Process run;
|
||||
await inDirectory(path.join(tempDir.path, 'app'), () async {
|
||||
run = await startFlutter(
|
||||
'run',
|
||||
options: <String>['--$mode', '--verbose'],
|
||||
);
|
||||
run = await startFlutter('run', options: <String>['--$mode', '--verbose']);
|
||||
});
|
||||
|
||||
int currSentinelIdx = 0;
|
||||
final StreamSubscription<void> stdout = run.stdout
|
||||
.transform<String>(utf8.decoder)
|
||||
.transform<String>(const LineSplitter())
|
||||
.listen((String line) {
|
||||
if (currSentinelIdx < sentinelCompleters.keys.length &&
|
||||
line.contains(sentinelCompleters.keys.elementAt(currSentinelIdx))) {
|
||||
sentinelCompleters.values.elementAt(currSentinelIdx).complete();
|
||||
currSentinelIdx++;
|
||||
print('stdout(MATCHED): $line');
|
||||
} else {
|
||||
print('stdout: $line');
|
||||
}
|
||||
});
|
||||
.transform<String>(utf8.decoder)
|
||||
.transform<String>(const LineSplitter())
|
||||
.listen((String line) {
|
||||
if (currSentinelIdx < sentinelCompleters.keys.length &&
|
||||
line.contains(sentinelCompleters.keys.elementAt(currSentinelIdx))) {
|
||||
sentinelCompleters.values.elementAt(currSentinelIdx).complete();
|
||||
currSentinelIdx++;
|
||||
print('stdout(MATCHED): $line');
|
||||
} else {
|
||||
print('stdout: $line');
|
||||
}
|
||||
});
|
||||
|
||||
final StreamSubscription<void> stderr = run.stderr
|
||||
.transform<String>(utf8.decoder)
|
||||
.transform<String>(const LineSplitter())
|
||||
.listen((String line) {
|
||||
print('stderr: $line');
|
||||
});
|
||||
.transform<String>(utf8.decoder)
|
||||
.transform<String>(const LineSplitter())
|
||||
.listen((String line) {
|
||||
print('stderr: $line');
|
||||
});
|
||||
|
||||
final Completer<void> exitCompleter = Completer<void>();
|
||||
|
||||
unawaited(run.exitCode.then((int exitCode) {
|
||||
exitCompleter.complete();
|
||||
}));
|
||||
unawaited(
|
||||
run.exitCode.then((int exitCode) {
|
||||
exitCompleter.complete();
|
||||
}),
|
||||
);
|
||||
|
||||
section('Wait for sentinels (mode: $mode)');
|
||||
for (final Completer<void> completer in sentinelCompleters.values) {
|
||||
if (nextCompleterIdx == 0) {
|
||||
// Don't time out because we don't know how long it would take to get the first log.
|
||||
await Future.any<dynamic>(
|
||||
<Future<dynamic>>[
|
||||
completer.future,
|
||||
exitCompleter.future,
|
||||
],
|
||||
);
|
||||
await Future.any<dynamic>(<Future<dynamic>>[completer.future, exitCompleter.future]);
|
||||
} else {
|
||||
try {
|
||||
// Time out since this should not take 1s after the first log was received.
|
||||
await Future.any<dynamic>(
|
||||
<Future<dynamic>>[
|
||||
completer.future.timeout(const Duration(seconds: 1)),
|
||||
exitCompleter.future,
|
||||
],
|
||||
);
|
||||
await Future.any<dynamic>(<Future<dynamic>>[
|
||||
completer.future.timeout(const Duration(seconds: 1)),
|
||||
exitCompleter.future,
|
||||
]);
|
||||
} on TimeoutException {
|
||||
break;
|
||||
}
|
||||
@@ -179,7 +161,7 @@ Future<void> main() async {
|
||||
}
|
||||
|
||||
final TaskResult releaseResult = await runTestFor('release');
|
||||
if (releaseResult.failed) {
|
||||
if (releaseResult.failed) {
|
||||
return releaseResult;
|
||||
}
|
||||
|
||||
|
||||
@@ -19,34 +19,22 @@ final RegExp _lifecycleSentinelRegExp = RegExp(r'==== lifecycle\: (.+) ====');
|
||||
|
||||
/// Tests the following Android lifecycles: Activity#onStop(), Activity#onResume(), Activity#onPause(),
|
||||
/// and Activity#onDestroy() from Dart perspective in debug, profile, and release modes.
|
||||
TaskFunction androidLifecyclesTest({
|
||||
Map<String, String>? environment,
|
||||
}) {
|
||||
final Directory tempDir = Directory.systemTemp
|
||||
.createTempSync('flutter_devicelab_activity_destroy.');
|
||||
TaskFunction androidLifecyclesTest({Map<String, String>? environment}) {
|
||||
final Directory tempDir = Directory.systemTemp.createTempSync(
|
||||
'flutter_devicelab_activity_destroy.',
|
||||
);
|
||||
return () async {
|
||||
try {
|
||||
section('Create app');
|
||||
await inDirectory(tempDir, () async {
|
||||
await flutter(
|
||||
'create',
|
||||
options: <String>[
|
||||
'--platforms',
|
||||
'android',
|
||||
'--org',
|
||||
_kOrgName,
|
||||
'app',
|
||||
],
|
||||
options: <String>['--platforms', 'android', '--org', _kOrgName, 'app'],
|
||||
environment: environment,
|
||||
);
|
||||
});
|
||||
|
||||
final File mainDart = File(path.join(
|
||||
tempDir.absolute.path,
|
||||
'app',
|
||||
'lib',
|
||||
'main.dart',
|
||||
));
|
||||
final File mainDart = File(path.join(tempDir.absolute.path, 'app', 'lib', 'main.dart'));
|
||||
if (!mainDart.existsSync()) {
|
||||
return TaskResult.failure('${mainDart.path} does not exist');
|
||||
}
|
||||
@@ -77,20 +65,17 @@ void main() {
|
||||
|
||||
late Process run;
|
||||
await inDirectory(path.join(tempDir.path, 'app'), () async {
|
||||
run = await startFlutter(
|
||||
'run',
|
||||
options: <String>['--$mode'],
|
||||
);
|
||||
run = await startFlutter('run', options: <String>['--$mode']);
|
||||
});
|
||||
|
||||
final StreamController<String> lifecycles = StreamController<String>();
|
||||
final StreamIterator<String> lifecycleItr = StreamIterator<String>(lifecycles.stream);
|
||||
|
||||
final StreamSubscription<void> stdout = run.stdout
|
||||
.transform<String>(utf8.decoder)
|
||||
.transform<String>(const LineSplitter())
|
||||
.listen((String log) {
|
||||
final RegExpMatch? match = _lifecycleSentinelRegExp.firstMatch(log);
|
||||
.transform<String>(utf8.decoder)
|
||||
.transform<String>(const LineSplitter())
|
||||
.listen((String log) {
|
||||
final RegExpMatch? match = _lifecycleSentinelRegExp.firstMatch(log);
|
||||
print('stdout: $log');
|
||||
if (match == null) {
|
||||
return;
|
||||
@@ -98,14 +83,14 @@ void main() {
|
||||
final String lifecycle = match[1]!;
|
||||
print('stdout: Found app lifecycle: $lifecycle');
|
||||
lifecycles.add(lifecycle);
|
||||
});
|
||||
});
|
||||
|
||||
final StreamSubscription<void> stderr = run.stderr
|
||||
.transform<String>(utf8.decoder)
|
||||
.transform<String>(const LineSplitter())
|
||||
.listen((String log) {
|
||||
print('stderr: $log');
|
||||
});
|
||||
.transform<String>(utf8.decoder)
|
||||
.transform<String>(const LineSplitter())
|
||||
.listen((String log) {
|
||||
print('stderr: $log');
|
||||
});
|
||||
|
||||
Future<void> expectedLifecycle(String expected) async {
|
||||
section('Wait for lifecycle: $expected (mode: $mode)');
|
||||
@@ -122,7 +107,8 @@ void main() {
|
||||
await device.shellExec('input', <String>['keyevent', 'KEYCODE_APP_SWITCH']);
|
||||
|
||||
await expectedLifecycle('AppLifecycleState.inactive');
|
||||
if (device.apiLevel == 28) { // Device lab currently runs 28.
|
||||
if (device.apiLevel == 28) {
|
||||
// Device lab currently runs 28.
|
||||
await expectedLifecycle('AppLifecycleState.paused');
|
||||
await expectedLifecycle('AppLifecycleState.detached');
|
||||
}
|
||||
@@ -136,7 +122,8 @@ void main() {
|
||||
await device.shellExec('am', <String>['start', '-a', 'android.settings.SETTINGS']);
|
||||
|
||||
await expectedLifecycle('AppLifecycleState.inactive');
|
||||
if (device.apiLevel == 28) { // Device lab currently runs 28.
|
||||
if (device.apiLevel == 28) {
|
||||
// Device lab currently runs 28.
|
||||
await expectedLifecycle('AppLifecycleState.paused');
|
||||
await expectedLifecycle('AppLifecycleState.detached');
|
||||
}
|
||||
@@ -168,7 +155,7 @@ void main() {
|
||||
}
|
||||
|
||||
final TaskResult releaseResult = await runTestFor('release');
|
||||
if (releaseResult.failed) {
|
||||
if (releaseResult.failed) {
|
||||
return releaseResult;
|
||||
}
|
||||
|
||||
|
||||
@@ -19,11 +19,10 @@ class DriverTest {
|
||||
DriverTest(
|
||||
this.testDirectory,
|
||||
this.testTarget, {
|
||||
this.extraOptions = const <String>[],
|
||||
this.deviceIdOverride,
|
||||
this.environment,
|
||||
}
|
||||
);
|
||||
this.extraOptions = const <String>[],
|
||||
this.deviceIdOverride,
|
||||
this.environment,
|
||||
});
|
||||
|
||||
final String testDirectory;
|
||||
final String testTarget;
|
||||
|
||||
@@ -6,51 +6,46 @@ import '../framework/framework.dart';
|
||||
import '../framework/task_result.dart';
|
||||
import '../framework/utils.dart';
|
||||
|
||||
|
||||
/// Tests the following Android lifecycles: Activity#onStop(), Activity#onResume(), Activity#onPause(),
|
||||
/// and Activity#onDestroy() from Dart perspective in debug, profile, and release modes.
|
||||
TaskFunction androidViewsTest({
|
||||
Map<String, String>? environment,
|
||||
}){
|
||||
return () async {
|
||||
section('Build APK');
|
||||
await flutter(
|
||||
'build',
|
||||
options: <String>[
|
||||
'apk',
|
||||
'--config-only',
|
||||
],
|
||||
environment: environment,
|
||||
workingDirectory: '${flutterDirectory.path}/dev/integration_tests/android_views'
|
||||
);
|
||||
TaskFunction androidViewsTest({Map<String, String>? environment}) {
|
||||
return () async {
|
||||
section('Build APK');
|
||||
await flutter(
|
||||
'build',
|
||||
options: <String>['apk', '--config-only'],
|
||||
environment: environment,
|
||||
workingDirectory: '${flutterDirectory.path}/dev/integration_tests/android_views',
|
||||
);
|
||||
|
||||
/// Any gradle command downloads gradle if not already present in the cache.
|
||||
/// ./gradlew dependencies downloads any gradle defined dependencies to the cache.
|
||||
/// https://docs.gradle.org/current/userguide/viewing_debugging_dependencies.html
|
||||
/// Downloading gradle and downloading dependencies are a common source of flakes
|
||||
/// and moving those to an infra step that can be retried shifts the blame
|
||||
/// individual tests to the infra itself.
|
||||
section('Download android dependencies');
|
||||
final int exitCode = await exec(
|
||||
'./gradlew',
|
||||
<String>['-q', 'dependencies'],
|
||||
workingDirectory:
|
||||
'${flutterDirectory.path}/dev/integration_tests/android_views/android'
|
||||
);
|
||||
if (exitCode != 0) {
|
||||
return TaskResult.failure('Failed to download gradle dependencies');
|
||||
}
|
||||
section('Run flutter drive on android views');
|
||||
await flutter(
|
||||
'drive',
|
||||
options: <String>[
|
||||
'--browser-name=android-chrome',
|
||||
'--android-emulator', '--no-start-paused',
|
||||
'--purge-persistent-cache', '--device-timeout=30',
|
||||
],
|
||||
environment: environment,
|
||||
workingDirectory: '${flutterDirectory.path}/dev/integration_tests/android_views'
|
||||
);
|
||||
return TaskResult.success(null);
|
||||
};
|
||||
/// Any gradle command downloads gradle if not already present in the cache.
|
||||
/// ./gradlew dependencies downloads any gradle defined dependencies to the cache.
|
||||
/// https://docs.gradle.org/current/userguide/viewing_debugging_dependencies.html
|
||||
/// Downloading gradle and downloading dependencies are a common source of flakes
|
||||
/// and moving those to an infra step that can be retried shifts the blame
|
||||
/// individual tests to the infra itself.
|
||||
section('Download android dependencies');
|
||||
final int exitCode = await exec(
|
||||
'./gradlew',
|
||||
<String>['-q', 'dependencies'],
|
||||
workingDirectory: '${flutterDirectory.path}/dev/integration_tests/android_views/android',
|
||||
);
|
||||
if (exitCode != 0) {
|
||||
return TaskResult.failure('Failed to download gradle dependencies');
|
||||
}
|
||||
section('Run flutter drive on android views');
|
||||
await flutter(
|
||||
'drive',
|
||||
options: <String>[
|
||||
'--browser-name=android-chrome',
|
||||
'--android-emulator',
|
||||
'--no-start-paused',
|
||||
'--purge-persistent-cache',
|
||||
'--device-timeout=30',
|
||||
],
|
||||
environment: environment,
|
||||
workingDirectory: '${flutterDirectory.path}/dev/integration_tests/android_views',
|
||||
);
|
||||
return TaskResult.success(null);
|
||||
};
|
||||
}
|
||||
|
||||
@@ -14,7 +14,7 @@ import '../framework/utils.dart';
|
||||
///
|
||||
/// Using this [Task] allows DeviceLab capacity to only be spent on the [test].
|
||||
abstract class BuildTestTask {
|
||||
BuildTestTask(this.args, {this.workingDirectory, this.runFlutterClean = true,}) {
|
||||
BuildTestTask(this.args, {this.workingDirectory, this.runFlutterClean = true}) {
|
||||
final ArgResults argResults = argParser.parse(args);
|
||||
applicationBinaryPath = argResults[kApplicationBinaryPathOption] as String?;
|
||||
buildOnly = argResults[kBuildOnlyFlag] as bool;
|
||||
@@ -25,10 +25,11 @@ abstract class BuildTestTask {
|
||||
static const String kBuildOnlyFlag = 'build';
|
||||
static const String kTestOnlyFlag = 'test';
|
||||
|
||||
final ArgParser argParser = ArgParser()
|
||||
..addOption(kApplicationBinaryPathOption)
|
||||
..addFlag(kBuildOnlyFlag)
|
||||
..addFlag(kTestOnlyFlag);
|
||||
final ArgParser argParser =
|
||||
ArgParser()
|
||||
..addOption(kApplicationBinaryPathOption)
|
||||
..addFlag(kBuildOnlyFlag)
|
||||
..addFlag(kTestOnlyFlag);
|
||||
|
||||
/// Args passed from the test runner via "--task-arg".
|
||||
final List<String> args;
|
||||
@@ -61,7 +62,6 @@ abstract class BuildTestTask {
|
||||
await flutter('build', options: getBuildArgs(deviceOperatingSystem));
|
||||
copyArtifacts();
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
/// Run Flutter drive test from [getTestArgs] against the application under test on the device.
|
||||
@@ -79,10 +79,12 @@ abstract class BuildTestTask {
|
||||
}
|
||||
|
||||
/// Args passed to flutter build to build the application under test.
|
||||
List<String> getBuildArgs(DeviceOperatingSystem deviceOperatingSystem) => throw UnimplementedError('getBuildArgs is not implemented');
|
||||
List<String> getBuildArgs(DeviceOperatingSystem deviceOperatingSystem) =>
|
||||
throw UnimplementedError('getBuildArgs is not implemented');
|
||||
|
||||
/// Args passed to flutter drive to test the built application.
|
||||
List<String> getTestArgs(DeviceOperatingSystem deviceOperatingSystem, String deviceId) => throw UnimplementedError('getTestArgs is not implemented');
|
||||
List<String> getTestArgs(DeviceOperatingSystem deviceOperatingSystem, String deviceId) =>
|
||||
throw UnimplementedError('getTestArgs is not implemented');
|
||||
|
||||
/// Copy artifacts to [applicationBinaryPath] if specified.
|
||||
///
|
||||
@@ -90,7 +92,8 @@ abstract class BuildTestTask {
|
||||
void copyArtifacts() => throw UnimplementedError('copyArtifacts is not implemented');
|
||||
|
||||
/// Logic to construct [TaskResult] from this test's results.
|
||||
Future<TaskResult> parseTaskResult() => throw UnimplementedError('parseTaskResult is not implemented');
|
||||
Future<TaskResult> parseTaskResult() =>
|
||||
throw UnimplementedError('parseTaskResult is not implemented');
|
||||
|
||||
/// Path to the built application under test.
|
||||
///
|
||||
|
||||
@@ -12,12 +12,10 @@ import '../framework/framework.dart';
|
||||
import '../framework/task_result.dart';
|
||||
import '../framework/utils.dart';
|
||||
|
||||
TaskFunction dartPluginRegistryTest({
|
||||
String? deviceIdOverride,
|
||||
Map<String, String>? environment,
|
||||
}) {
|
||||
final Directory tempDir = Directory.systemTemp
|
||||
.createTempSync('flutter_devicelab_dart_plugin_test.');
|
||||
TaskFunction dartPluginRegistryTest({String? deviceIdOverride, Map<String, String>? environment}) {
|
||||
final Directory tempDir = Directory.systemTemp.createTempSync(
|
||||
'flutter_devicelab_dart_plugin_test.',
|
||||
);
|
||||
return () async {
|
||||
try {
|
||||
section('Create implementation plugin');
|
||||
@@ -36,12 +34,14 @@ TaskFunction dartPluginRegistryTest({
|
||||
);
|
||||
});
|
||||
|
||||
final File pluginMain = File(path.join(
|
||||
tempDir.absolute.path,
|
||||
'aplugin_platform_implementation',
|
||||
'lib',
|
||||
'aplugin_platform_implementation.dart',
|
||||
));
|
||||
final File pluginMain = File(
|
||||
path.join(
|
||||
tempDir.absolute.path,
|
||||
'aplugin_platform_implementation',
|
||||
'lib',
|
||||
'aplugin_platform_implementation.dart',
|
||||
),
|
||||
);
|
||||
if (!pluginMain.existsSync()) {
|
||||
return TaskResult.failure('${pluginMain.path} does not exist');
|
||||
}
|
||||
@@ -56,11 +56,9 @@ class ApluginPlatformInterfaceMacOS {
|
||||
''', flush: true);
|
||||
|
||||
// Patch plugin main pubspec file.
|
||||
final File pluginImplPubspec = File(path.join(
|
||||
tempDir.absolute.path,
|
||||
'aplugin_platform_implementation',
|
||||
'pubspec.yaml',
|
||||
));
|
||||
final File pluginImplPubspec = File(
|
||||
path.join(tempDir.absolute.path, 'aplugin_platform_implementation', 'pubspec.yaml'),
|
||||
);
|
||||
String pluginImplPubspecContent = await pluginImplPubspec.readAsString();
|
||||
pluginImplPubspecContent = pluginImplPubspecContent.replaceFirst(
|
||||
' pluginClass: ApluginPlatformImplementationPlugin',
|
||||
@@ -68,11 +66,11 @@ class ApluginPlatformInterfaceMacOS {
|
||||
' dartPluginClass: ApluginPlatformInterfaceMacOS\n',
|
||||
);
|
||||
pluginImplPubspecContent = pluginImplPubspecContent.replaceFirst(
|
||||
' platforms:\n',
|
||||
' implements: aplugin_platform_interface\n'
|
||||
' platforms:\n');
|
||||
await pluginImplPubspec.writeAsString(pluginImplPubspecContent,
|
||||
flush: true);
|
||||
' platforms:\n',
|
||||
' implements: aplugin_platform_interface\n'
|
||||
' platforms:\n',
|
||||
);
|
||||
await pluginImplPubspec.writeAsString(pluginImplPubspecContent, flush: true);
|
||||
|
||||
section('Create interface plugin');
|
||||
await inDirectory(tempDir, () async {
|
||||
@@ -89,25 +87,21 @@ class ApluginPlatformInterfaceMacOS {
|
||||
environment: environment,
|
||||
);
|
||||
});
|
||||
final File pluginInterfacePubspec = File(path.join(
|
||||
tempDir.absolute.path,
|
||||
'aplugin_platform_interface',
|
||||
'pubspec.yaml',
|
||||
));
|
||||
String pluginInterfacePubspecContent =
|
||||
await pluginInterfacePubspec.readAsString();
|
||||
pluginInterfacePubspecContent =
|
||||
pluginInterfacePubspecContent.replaceFirst(
|
||||
' pluginClass: ApluginPlatformInterfacePlugin',
|
||||
' default_package: aplugin_platform_implementation\n');
|
||||
pluginInterfacePubspecContent =
|
||||
pluginInterfacePubspecContent.replaceFirst(
|
||||
'dependencies:',
|
||||
'dependencies:\n'
|
||||
' aplugin_platform_implementation:\n'
|
||||
' path: ../aplugin_platform_implementation\n');
|
||||
await pluginInterfacePubspec.writeAsString(pluginInterfacePubspecContent,
|
||||
flush: true);
|
||||
final File pluginInterfacePubspec = File(
|
||||
path.join(tempDir.absolute.path, 'aplugin_platform_interface', 'pubspec.yaml'),
|
||||
);
|
||||
String pluginInterfacePubspecContent = await pluginInterfacePubspec.readAsString();
|
||||
pluginInterfacePubspecContent = pluginInterfacePubspecContent.replaceFirst(
|
||||
' pluginClass: ApluginPlatformInterfacePlugin',
|
||||
' default_package: aplugin_platform_implementation\n',
|
||||
);
|
||||
pluginInterfacePubspecContent = pluginInterfacePubspecContent.replaceFirst(
|
||||
'dependencies:',
|
||||
'dependencies:\n'
|
||||
' aplugin_platform_implementation:\n'
|
||||
' path: ../aplugin_platform_implementation\n',
|
||||
);
|
||||
await pluginInterfacePubspec.writeAsString(pluginInterfacePubspecContent, flush: true);
|
||||
|
||||
section('Create app');
|
||||
|
||||
@@ -126,46 +120,40 @@ class ApluginPlatformInterfaceMacOS {
|
||||
);
|
||||
});
|
||||
|
||||
final File appPubspec = File(path.join(
|
||||
tempDir.absolute.path,
|
||||
'app',
|
||||
'pubspec.yaml',
|
||||
));
|
||||
final File appPubspec = File(path.join(tempDir.absolute.path, 'app', 'pubspec.yaml'));
|
||||
String appPubspecContent = await appPubspec.readAsString();
|
||||
appPubspecContent = appPubspecContent.replaceFirst(
|
||||
'dependencies:',
|
||||
'dependencies:\n'
|
||||
' aplugin_platform_interface:\n'
|
||||
' path: ../aplugin_platform_interface\n');
|
||||
'dependencies:',
|
||||
'dependencies:\n'
|
||||
' aplugin_platform_interface:\n'
|
||||
' path: ../aplugin_platform_interface\n',
|
||||
);
|
||||
await appPubspec.writeAsString(appPubspecContent, flush: true);
|
||||
|
||||
section('Flutter run for macos');
|
||||
|
||||
late Process run;
|
||||
await inDirectory(path.join(tempDir.path, 'app'), () async {
|
||||
run = await startFlutter(
|
||||
'run',
|
||||
options: <String>['-d', 'macos', '-v'],
|
||||
);
|
||||
run = await startFlutter('run', options: <String>['-d', 'macos', '-v']);
|
||||
});
|
||||
|
||||
Completer<void> registryExecutedCompleter = Completer<void>();
|
||||
final StreamSubscription<void> stdoutSub = run.stdout
|
||||
.transform<String>(utf8.decoder)
|
||||
.transform<String>(const LineSplitter())
|
||||
.listen((String line) {
|
||||
if (line.contains('ApluginPlatformInterfaceMacOS.registerWith() was called')) {
|
||||
registryExecutedCompleter.complete();
|
||||
}
|
||||
print('stdout: $line');
|
||||
});
|
||||
.transform<String>(utf8.decoder)
|
||||
.transform<String>(const LineSplitter())
|
||||
.listen((String line) {
|
||||
if (line.contains('ApluginPlatformInterfaceMacOS.registerWith() was called')) {
|
||||
registryExecutedCompleter.complete();
|
||||
}
|
||||
print('stdout: $line');
|
||||
});
|
||||
|
||||
final StreamSubscription<void> stderrSub = run.stderr
|
||||
.transform<String>(utf8.decoder)
|
||||
.transform<String>(const LineSplitter())
|
||||
.listen((String line) {
|
||||
print('stderr: $line');
|
||||
});
|
||||
.transform<String>(utf8.decoder)
|
||||
.transform<String>(const LineSplitter())
|
||||
.listen((String line) {
|
||||
print('stderr: $line');
|
||||
});
|
||||
|
||||
final Future<void> stdoutDone = stdoutSub.asFuture<void>();
|
||||
final Future<void> stderrDone = stderrSub.asFuture<void>();
|
||||
@@ -175,12 +163,7 @@ class ApluginPlatformInterfaceMacOS {
|
||||
}
|
||||
|
||||
Future<void> waitOrExit(Future<void> future) async {
|
||||
final dynamic result = await Future.any<dynamic>(
|
||||
<Future<dynamic>>[
|
||||
future,
|
||||
run.exitCode,
|
||||
],
|
||||
);
|
||||
final dynamic result = await Future.any<dynamic>(<Future<dynamic>>[future, run.exitCode]);
|
||||
if (result is int) {
|
||||
await waitForStreams();
|
||||
throw 'process exited with code $result';
|
||||
|
||||
@@ -46,11 +46,7 @@ Future<TaskResult> _runWithTempDir(Directory tempDir) async {
|
||||
const String testDirName = 'entrypoint_dart_registrant';
|
||||
final String testPath = '${tempDir.path}/$testDirName';
|
||||
await inDirectory(tempDir, () async {
|
||||
await flutter('create', options: <String>[
|
||||
'--platforms',
|
||||
'android',
|
||||
testDirName,
|
||||
]);
|
||||
await flutter('create', options: <String>['--platforms', 'android', testDirName]);
|
||||
});
|
||||
final String mainPath = '${tempDir.path}/$testDirName/lib/main.dart';
|
||||
print(mainPath);
|
||||
@@ -65,18 +61,17 @@ Future<TaskResult> _runWithTempDir(Directory tempDir) async {
|
||||
// (which path_provider has).
|
||||
await flutter('pub', options: <String>['add', 'path_provider:2.0.9']);
|
||||
// The problem only manifested on release builds, so we test release.
|
||||
final Process process =
|
||||
await startFlutter('run', options: <String>['--release']);
|
||||
final Process process = await startFlutter('run', options: <String>['--release']);
|
||||
final Completer<String> completer = Completer<String>();
|
||||
final StreamSubscription<String> stdoutSub = process.stdout
|
||||
.transform<String>(const Utf8Decoder())
|
||||
.transform<String>(const LineSplitter())
|
||||
.listen((String line) async {
|
||||
print(line);
|
||||
if (line.contains(_messagePrefix)) {
|
||||
completer.complete(line);
|
||||
}
|
||||
});
|
||||
print(line);
|
||||
if (line.contains(_messagePrefix)) {
|
||||
completer.complete(line);
|
||||
}
|
||||
});
|
||||
final String entrypoint = await completer.future;
|
||||
await stdoutSub.cancel();
|
||||
process.stdin.write('q');
|
||||
@@ -95,8 +90,7 @@ Future<TaskResult> _runWithTempDir(Directory tempDir) async {
|
||||
/// registrant.
|
||||
TaskFunction entrypointDartRegistrant() {
|
||||
return () async {
|
||||
final Directory tempDir =
|
||||
Directory.systemTemp.createTempSync('entrypoint_dart_registrant.');
|
||||
final Directory tempDir = Directory.systemTemp.createTempSync('entrypoint_dart_registrant.');
|
||||
try {
|
||||
return await _runWithTempDir(tempDir);
|
||||
} finally {
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user