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:
Michael Goderbauer
2024-12-19 12:06:21 -08:00
committed by GitHub
parent 8e0993eda8
commit 5491c8c146
4411 changed files with 455108 additions and 415991 deletions

View File

@@ -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)?');
}
},
);

View File

@@ -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.',
);

View File

@@ -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,
);
});
}

View File

@@ -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,
);
});
}

View File

@@ -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;
}

View File

@@ -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());
}
});
}

View File

@@ -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));
}

View File

@@ -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));
}

View File

@@ -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,
);
}

View File

@@ -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) {

View File

@@ -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,
]),
);
}

View File

@@ -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,
]),
);
}

View File

@@ -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');
}

View File

@@ -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,
);
}

View File

@@ -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,
);
}

View File

@@ -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'],
);
});
}

View File

@@ -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);
}

View File

@@ -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);

View File

@@ -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;

View File

@@ -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?;

View File

@@ -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?;

View File

@@ -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');

View File

@@ -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);
}

View File

@@ -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;
});

View File

@@ -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');

View File

@@ -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');

View File

@@ -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,
);
}

View File

@@ -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,
);
}

View File

@@ -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) {

View File

@@ -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;
}

View File

@@ -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/',

View File

@@ -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>{

View File

@@ -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");
}

View File

@@ -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) {

View File

@@ -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(

View File

@@ -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,

View File

@@ -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);
}
});

View File

@@ -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));

View File

@@ -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);

View File

@@ -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']));
}

View File

@@ -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,
);
}

View File

@@ -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,
);
}

View File

@@ -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,
);

View File

@@ -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,
);
}

View File

@@ -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,
);
}

View File

@@ -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');

View File

@@ -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},
);
});

View File

@@ -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);

View File

@@ -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);
}

View File

@@ -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');

View File

@@ -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');

View File

@@ -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,
);
}

View File

@@ -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,
);
}

View File

@@ -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,
);
}

View File

@@ -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));
}

View File

@@ -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));

View File

@@ -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.

View File

@@ -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.

View File

@@ -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]);
}

View File

@@ -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,
]),
);
}

View File

@@ -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,
]),
);
}

View File

@@ -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,
]),
);
}

View File

@@ -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,
]),
);
}

View File

@@ -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,
]),
);
}

View File

@@ -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).';
}

View File

@@ -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>;

View File

@@ -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');
}

View File

@@ -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'],
);
});
}

View File

@@ -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;
}

View File

@@ -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));
});
}

View File

@@ -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));
});
}

View File

@@ -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));
});
}

View File

@@ -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());
}

View File

@@ -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.
}),
);
}