Auto-format Framework (#160545)
This auto-formats all *.dart files in the repository outside of the `engine` subdirectory and enforces that these files stay formatted with a presubmit check. **Reviewers:** Please carefully review all the commits except for the one titled "formatted". The "formatted" commit was auto-generated by running `dev/tools/format.sh -a -f`. The other commits were hand-crafted to prepare the repo for the formatting change. I recommend reviewing the commits one-by-one via the "Commits" tab and avoiding Github's "Files changed" tab as it will likely slow down your browser because of the size of this PR. --------- Co-authored-by: Kate Lovett <katelovett@google.com> Co-authored-by: LongCatIsLooong <31859944+LongCatIsLooong@users.noreply.github.com>
This commit is contained in:
committed by
GitHub
parent
8e0993eda8
commit
5491c8c146
@@ -65,10 +65,7 @@ abstract class _Benchmark {
|
||||
|
||||
Directory get directory;
|
||||
|
||||
List<String> get options => <String>[
|
||||
'--benchmark',
|
||||
if (watch) '--watch',
|
||||
];
|
||||
List<String> get options => <String>['--benchmark', if (watch) '--watch'];
|
||||
|
||||
Future<double> execute(int iteration, int targetIterations) async {
|
||||
section('Analyze $title ${watch ? 'with watcher' : ''} - ${iteration + 1} / $targetIterations');
|
||||
|
||||
@@ -22,32 +22,22 @@ const List<String> kSentinelStr = <String>[
|
||||
/// This test fails if the application hangs during this period.
|
||||
/// https://ui.perfetto.dev/#!/?s=da6628c3a92456ae8fa3f345d0186e781da77e90fc8a64d073e9fee11d1e65
|
||||
/// Regression test for https://github.com/flutter/flutter/issues/98973
|
||||
TaskFunction androidChoreographerDoFrameTest({
|
||||
Map<String, String>? environment,
|
||||
}) {
|
||||
final Directory tempDir = Directory.systemTemp
|
||||
.createTempSync('flutter_devicelab_android_surface_recreation.');
|
||||
TaskFunction androidChoreographerDoFrameTest({Map<String, String>? environment}) {
|
||||
final Directory tempDir = Directory.systemTemp.createTempSync(
|
||||
'flutter_devicelab_android_surface_recreation.',
|
||||
);
|
||||
return () async {
|
||||
try {
|
||||
section('Create app');
|
||||
await inDirectory(tempDir, () async {
|
||||
await flutter(
|
||||
'create',
|
||||
options: <String>[
|
||||
'--platforms',
|
||||
'android',
|
||||
'app',
|
||||
],
|
||||
options: <String>['--platforms', 'android', 'app'],
|
||||
environment: environment,
|
||||
);
|
||||
});
|
||||
|
||||
final File mainDart = File(path.join(
|
||||
tempDir.absolute.path,
|
||||
'app',
|
||||
'lib',
|
||||
'main.dart',
|
||||
));
|
||||
final File mainDart = File(path.join(tempDir.absolute.path, 'app', 'lib', 'main.dart'));
|
||||
if (!mainDart.existsSync()) {
|
||||
return TaskResult.failure('${mainDart.path} does not exist');
|
||||
}
|
||||
@@ -88,59 +78,51 @@ Future<void> main() async {
|
||||
section('Flutter run (mode: $mode)');
|
||||
late Process run;
|
||||
await inDirectory(path.join(tempDir.path, 'app'), () async {
|
||||
run = await startFlutter(
|
||||
'run',
|
||||
options: <String>['--$mode', '--verbose'],
|
||||
);
|
||||
run = await startFlutter('run', options: <String>['--$mode', '--verbose']);
|
||||
});
|
||||
|
||||
int currSentinelIdx = 0;
|
||||
final StreamSubscription<void> stdout = run.stdout
|
||||
.transform<String>(utf8.decoder)
|
||||
.transform<String>(const LineSplitter())
|
||||
.listen((String line) {
|
||||
if (currSentinelIdx < sentinelCompleters.keys.length &&
|
||||
line.contains(sentinelCompleters.keys.elementAt(currSentinelIdx))) {
|
||||
sentinelCompleters.values.elementAt(currSentinelIdx).complete();
|
||||
currSentinelIdx++;
|
||||
print('stdout(MATCHED): $line');
|
||||
} else {
|
||||
print('stdout: $line');
|
||||
}
|
||||
});
|
||||
.transform<String>(utf8.decoder)
|
||||
.transform<String>(const LineSplitter())
|
||||
.listen((String line) {
|
||||
if (currSentinelIdx < sentinelCompleters.keys.length &&
|
||||
line.contains(sentinelCompleters.keys.elementAt(currSentinelIdx))) {
|
||||
sentinelCompleters.values.elementAt(currSentinelIdx).complete();
|
||||
currSentinelIdx++;
|
||||
print('stdout(MATCHED): $line');
|
||||
} else {
|
||||
print('stdout: $line');
|
||||
}
|
||||
});
|
||||
|
||||
final StreamSubscription<void> stderr = run.stderr
|
||||
.transform<String>(utf8.decoder)
|
||||
.transform<String>(const LineSplitter())
|
||||
.listen((String line) {
|
||||
print('stderr: $line');
|
||||
});
|
||||
.transform<String>(utf8.decoder)
|
||||
.transform<String>(const LineSplitter())
|
||||
.listen((String line) {
|
||||
print('stderr: $line');
|
||||
});
|
||||
|
||||
final Completer<void> exitCompleter = Completer<void>();
|
||||
|
||||
unawaited(run.exitCode.then((int exitCode) {
|
||||
exitCompleter.complete();
|
||||
}));
|
||||
unawaited(
|
||||
run.exitCode.then((int exitCode) {
|
||||
exitCompleter.complete();
|
||||
}),
|
||||
);
|
||||
|
||||
section('Wait for sentinels (mode: $mode)');
|
||||
for (final Completer<void> completer in sentinelCompleters.values) {
|
||||
if (nextCompleterIdx == 0) {
|
||||
// Don't time out because we don't know how long it would take to get the first log.
|
||||
await Future.any<dynamic>(
|
||||
<Future<dynamic>>[
|
||||
completer.future,
|
||||
exitCompleter.future,
|
||||
],
|
||||
);
|
||||
await Future.any<dynamic>(<Future<dynamic>>[completer.future, exitCompleter.future]);
|
||||
} else {
|
||||
try {
|
||||
// Time out since this should not take 1s after the first log was received.
|
||||
await Future.any<dynamic>(
|
||||
<Future<dynamic>>[
|
||||
completer.future.timeout(const Duration(seconds: 1)),
|
||||
exitCompleter.future,
|
||||
],
|
||||
);
|
||||
await Future.any<dynamic>(<Future<dynamic>>[
|
||||
completer.future.timeout(const Duration(seconds: 1)),
|
||||
exitCompleter.future,
|
||||
]);
|
||||
} on TimeoutException {
|
||||
break;
|
||||
}
|
||||
@@ -179,7 +161,7 @@ Future<void> main() async {
|
||||
}
|
||||
|
||||
final TaskResult releaseResult = await runTestFor('release');
|
||||
if (releaseResult.failed) {
|
||||
if (releaseResult.failed) {
|
||||
return releaseResult;
|
||||
}
|
||||
|
||||
|
||||
@@ -19,34 +19,22 @@ final RegExp _lifecycleSentinelRegExp = RegExp(r'==== lifecycle\: (.+) ====');
|
||||
|
||||
/// Tests the following Android lifecycles: Activity#onStop(), Activity#onResume(), Activity#onPause(),
|
||||
/// and Activity#onDestroy() from Dart perspective in debug, profile, and release modes.
|
||||
TaskFunction androidLifecyclesTest({
|
||||
Map<String, String>? environment,
|
||||
}) {
|
||||
final Directory tempDir = Directory.systemTemp
|
||||
.createTempSync('flutter_devicelab_activity_destroy.');
|
||||
TaskFunction androidLifecyclesTest({Map<String, String>? environment}) {
|
||||
final Directory tempDir = Directory.systemTemp.createTempSync(
|
||||
'flutter_devicelab_activity_destroy.',
|
||||
);
|
||||
return () async {
|
||||
try {
|
||||
section('Create app');
|
||||
await inDirectory(tempDir, () async {
|
||||
await flutter(
|
||||
'create',
|
||||
options: <String>[
|
||||
'--platforms',
|
||||
'android',
|
||||
'--org',
|
||||
_kOrgName,
|
||||
'app',
|
||||
],
|
||||
options: <String>['--platforms', 'android', '--org', _kOrgName, 'app'],
|
||||
environment: environment,
|
||||
);
|
||||
});
|
||||
|
||||
final File mainDart = File(path.join(
|
||||
tempDir.absolute.path,
|
||||
'app',
|
||||
'lib',
|
||||
'main.dart',
|
||||
));
|
||||
final File mainDart = File(path.join(tempDir.absolute.path, 'app', 'lib', 'main.dart'));
|
||||
if (!mainDart.existsSync()) {
|
||||
return TaskResult.failure('${mainDart.path} does not exist');
|
||||
}
|
||||
@@ -77,20 +65,17 @@ void main() {
|
||||
|
||||
late Process run;
|
||||
await inDirectory(path.join(tempDir.path, 'app'), () async {
|
||||
run = await startFlutter(
|
||||
'run',
|
||||
options: <String>['--$mode'],
|
||||
);
|
||||
run = await startFlutter('run', options: <String>['--$mode']);
|
||||
});
|
||||
|
||||
final StreamController<String> lifecycles = StreamController<String>();
|
||||
final StreamIterator<String> lifecycleItr = StreamIterator<String>(lifecycles.stream);
|
||||
|
||||
final StreamSubscription<void> stdout = run.stdout
|
||||
.transform<String>(utf8.decoder)
|
||||
.transform<String>(const LineSplitter())
|
||||
.listen((String log) {
|
||||
final RegExpMatch? match = _lifecycleSentinelRegExp.firstMatch(log);
|
||||
.transform<String>(utf8.decoder)
|
||||
.transform<String>(const LineSplitter())
|
||||
.listen((String log) {
|
||||
final RegExpMatch? match = _lifecycleSentinelRegExp.firstMatch(log);
|
||||
print('stdout: $log');
|
||||
if (match == null) {
|
||||
return;
|
||||
@@ -98,14 +83,14 @@ void main() {
|
||||
final String lifecycle = match[1]!;
|
||||
print('stdout: Found app lifecycle: $lifecycle');
|
||||
lifecycles.add(lifecycle);
|
||||
});
|
||||
});
|
||||
|
||||
final StreamSubscription<void> stderr = run.stderr
|
||||
.transform<String>(utf8.decoder)
|
||||
.transform<String>(const LineSplitter())
|
||||
.listen((String log) {
|
||||
print('stderr: $log');
|
||||
});
|
||||
.transform<String>(utf8.decoder)
|
||||
.transform<String>(const LineSplitter())
|
||||
.listen((String log) {
|
||||
print('stderr: $log');
|
||||
});
|
||||
|
||||
Future<void> expectedLifecycle(String expected) async {
|
||||
section('Wait for lifecycle: $expected (mode: $mode)');
|
||||
@@ -122,7 +107,8 @@ void main() {
|
||||
await device.shellExec('input', <String>['keyevent', 'KEYCODE_APP_SWITCH']);
|
||||
|
||||
await expectedLifecycle('AppLifecycleState.inactive');
|
||||
if (device.apiLevel == 28) { // Device lab currently runs 28.
|
||||
if (device.apiLevel == 28) {
|
||||
// Device lab currently runs 28.
|
||||
await expectedLifecycle('AppLifecycleState.paused');
|
||||
await expectedLifecycle('AppLifecycleState.detached');
|
||||
}
|
||||
@@ -136,7 +122,8 @@ void main() {
|
||||
await device.shellExec('am', <String>['start', '-a', 'android.settings.SETTINGS']);
|
||||
|
||||
await expectedLifecycle('AppLifecycleState.inactive');
|
||||
if (device.apiLevel == 28) { // Device lab currently runs 28.
|
||||
if (device.apiLevel == 28) {
|
||||
// Device lab currently runs 28.
|
||||
await expectedLifecycle('AppLifecycleState.paused');
|
||||
await expectedLifecycle('AppLifecycleState.detached');
|
||||
}
|
||||
@@ -168,7 +155,7 @@ void main() {
|
||||
}
|
||||
|
||||
final TaskResult releaseResult = await runTestFor('release');
|
||||
if (releaseResult.failed) {
|
||||
if (releaseResult.failed) {
|
||||
return releaseResult;
|
||||
}
|
||||
|
||||
|
||||
@@ -19,11 +19,10 @@ class DriverTest {
|
||||
DriverTest(
|
||||
this.testDirectory,
|
||||
this.testTarget, {
|
||||
this.extraOptions = const <String>[],
|
||||
this.deviceIdOverride,
|
||||
this.environment,
|
||||
}
|
||||
);
|
||||
this.extraOptions = const <String>[],
|
||||
this.deviceIdOverride,
|
||||
this.environment,
|
||||
});
|
||||
|
||||
final String testDirectory;
|
||||
final String testTarget;
|
||||
|
||||
@@ -6,51 +6,46 @@ import '../framework/framework.dart';
|
||||
import '../framework/task_result.dart';
|
||||
import '../framework/utils.dart';
|
||||
|
||||
|
||||
/// Tests the following Android lifecycles: Activity#onStop(), Activity#onResume(), Activity#onPause(),
|
||||
/// and Activity#onDestroy() from Dart perspective in debug, profile, and release modes.
|
||||
TaskFunction androidViewsTest({
|
||||
Map<String, String>? environment,
|
||||
}){
|
||||
return () async {
|
||||
section('Build APK');
|
||||
await flutter(
|
||||
'build',
|
||||
options: <String>[
|
||||
'apk',
|
||||
'--config-only',
|
||||
],
|
||||
environment: environment,
|
||||
workingDirectory: '${flutterDirectory.path}/dev/integration_tests/android_views'
|
||||
);
|
||||
TaskFunction androidViewsTest({Map<String, String>? environment}) {
|
||||
return () async {
|
||||
section('Build APK');
|
||||
await flutter(
|
||||
'build',
|
||||
options: <String>['apk', '--config-only'],
|
||||
environment: environment,
|
||||
workingDirectory: '${flutterDirectory.path}/dev/integration_tests/android_views',
|
||||
);
|
||||
|
||||
/// Any gradle command downloads gradle if not already present in the cache.
|
||||
/// ./gradlew dependencies downloads any gradle defined dependencies to the cache.
|
||||
/// https://docs.gradle.org/current/userguide/viewing_debugging_dependencies.html
|
||||
/// Downloading gradle and downloading dependencies are a common source of flakes
|
||||
/// and moving those to an infra step that can be retried shifts the blame
|
||||
/// individual tests to the infra itself.
|
||||
section('Download android dependencies');
|
||||
final int exitCode = await exec(
|
||||
'./gradlew',
|
||||
<String>['-q', 'dependencies'],
|
||||
workingDirectory:
|
||||
'${flutterDirectory.path}/dev/integration_tests/android_views/android'
|
||||
);
|
||||
if (exitCode != 0) {
|
||||
return TaskResult.failure('Failed to download gradle dependencies');
|
||||
}
|
||||
section('Run flutter drive on android views');
|
||||
await flutter(
|
||||
'drive',
|
||||
options: <String>[
|
||||
'--browser-name=android-chrome',
|
||||
'--android-emulator', '--no-start-paused',
|
||||
'--purge-persistent-cache', '--device-timeout=30',
|
||||
],
|
||||
environment: environment,
|
||||
workingDirectory: '${flutterDirectory.path}/dev/integration_tests/android_views'
|
||||
);
|
||||
return TaskResult.success(null);
|
||||
};
|
||||
/// Any gradle command downloads gradle if not already present in the cache.
|
||||
/// ./gradlew dependencies downloads any gradle defined dependencies to the cache.
|
||||
/// https://docs.gradle.org/current/userguide/viewing_debugging_dependencies.html
|
||||
/// Downloading gradle and downloading dependencies are a common source of flakes
|
||||
/// and moving those to an infra step that can be retried shifts the blame
|
||||
/// individual tests to the infra itself.
|
||||
section('Download android dependencies');
|
||||
final int exitCode = await exec(
|
||||
'./gradlew',
|
||||
<String>['-q', 'dependencies'],
|
||||
workingDirectory: '${flutterDirectory.path}/dev/integration_tests/android_views/android',
|
||||
);
|
||||
if (exitCode != 0) {
|
||||
return TaskResult.failure('Failed to download gradle dependencies');
|
||||
}
|
||||
section('Run flutter drive on android views');
|
||||
await flutter(
|
||||
'drive',
|
||||
options: <String>[
|
||||
'--browser-name=android-chrome',
|
||||
'--android-emulator',
|
||||
'--no-start-paused',
|
||||
'--purge-persistent-cache',
|
||||
'--device-timeout=30',
|
||||
],
|
||||
environment: environment,
|
||||
workingDirectory: '${flutterDirectory.path}/dev/integration_tests/android_views',
|
||||
);
|
||||
return TaskResult.success(null);
|
||||
};
|
||||
}
|
||||
|
||||
@@ -14,7 +14,7 @@ import '../framework/utils.dart';
|
||||
///
|
||||
/// Using this [Task] allows DeviceLab capacity to only be spent on the [test].
|
||||
abstract class BuildTestTask {
|
||||
BuildTestTask(this.args, {this.workingDirectory, this.runFlutterClean = true,}) {
|
||||
BuildTestTask(this.args, {this.workingDirectory, this.runFlutterClean = true}) {
|
||||
final ArgResults argResults = argParser.parse(args);
|
||||
applicationBinaryPath = argResults[kApplicationBinaryPathOption] as String?;
|
||||
buildOnly = argResults[kBuildOnlyFlag] as bool;
|
||||
@@ -25,10 +25,11 @@ abstract class BuildTestTask {
|
||||
static const String kBuildOnlyFlag = 'build';
|
||||
static const String kTestOnlyFlag = 'test';
|
||||
|
||||
final ArgParser argParser = ArgParser()
|
||||
..addOption(kApplicationBinaryPathOption)
|
||||
..addFlag(kBuildOnlyFlag)
|
||||
..addFlag(kTestOnlyFlag);
|
||||
final ArgParser argParser =
|
||||
ArgParser()
|
||||
..addOption(kApplicationBinaryPathOption)
|
||||
..addFlag(kBuildOnlyFlag)
|
||||
..addFlag(kTestOnlyFlag);
|
||||
|
||||
/// Args passed from the test runner via "--task-arg".
|
||||
final List<String> args;
|
||||
@@ -61,7 +62,6 @@ abstract class BuildTestTask {
|
||||
await flutter('build', options: getBuildArgs(deviceOperatingSystem));
|
||||
copyArtifacts();
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
/// Run Flutter drive test from [getTestArgs] against the application under test on the device.
|
||||
@@ -79,10 +79,12 @@ abstract class BuildTestTask {
|
||||
}
|
||||
|
||||
/// Args passed to flutter build to build the application under test.
|
||||
List<String> getBuildArgs(DeviceOperatingSystem deviceOperatingSystem) => throw UnimplementedError('getBuildArgs is not implemented');
|
||||
List<String> getBuildArgs(DeviceOperatingSystem deviceOperatingSystem) =>
|
||||
throw UnimplementedError('getBuildArgs is not implemented');
|
||||
|
||||
/// Args passed to flutter drive to test the built application.
|
||||
List<String> getTestArgs(DeviceOperatingSystem deviceOperatingSystem, String deviceId) => throw UnimplementedError('getTestArgs is not implemented');
|
||||
List<String> getTestArgs(DeviceOperatingSystem deviceOperatingSystem, String deviceId) =>
|
||||
throw UnimplementedError('getTestArgs is not implemented');
|
||||
|
||||
/// Copy artifacts to [applicationBinaryPath] if specified.
|
||||
///
|
||||
@@ -90,7 +92,8 @@ abstract class BuildTestTask {
|
||||
void copyArtifacts() => throw UnimplementedError('copyArtifacts is not implemented');
|
||||
|
||||
/// Logic to construct [TaskResult] from this test's results.
|
||||
Future<TaskResult> parseTaskResult() => throw UnimplementedError('parseTaskResult is not implemented');
|
||||
Future<TaskResult> parseTaskResult() =>
|
||||
throw UnimplementedError('parseTaskResult is not implemented');
|
||||
|
||||
/// Path to the built application under test.
|
||||
///
|
||||
|
||||
@@ -12,12 +12,10 @@ import '../framework/framework.dart';
|
||||
import '../framework/task_result.dart';
|
||||
import '../framework/utils.dart';
|
||||
|
||||
TaskFunction dartPluginRegistryTest({
|
||||
String? deviceIdOverride,
|
||||
Map<String, String>? environment,
|
||||
}) {
|
||||
final Directory tempDir = Directory.systemTemp
|
||||
.createTempSync('flutter_devicelab_dart_plugin_test.');
|
||||
TaskFunction dartPluginRegistryTest({String? deviceIdOverride, Map<String, String>? environment}) {
|
||||
final Directory tempDir = Directory.systemTemp.createTempSync(
|
||||
'flutter_devicelab_dart_plugin_test.',
|
||||
);
|
||||
return () async {
|
||||
try {
|
||||
section('Create implementation plugin');
|
||||
@@ -36,12 +34,14 @@ TaskFunction dartPluginRegistryTest({
|
||||
);
|
||||
});
|
||||
|
||||
final File pluginMain = File(path.join(
|
||||
tempDir.absolute.path,
|
||||
'aplugin_platform_implementation',
|
||||
'lib',
|
||||
'aplugin_platform_implementation.dart',
|
||||
));
|
||||
final File pluginMain = File(
|
||||
path.join(
|
||||
tempDir.absolute.path,
|
||||
'aplugin_platform_implementation',
|
||||
'lib',
|
||||
'aplugin_platform_implementation.dart',
|
||||
),
|
||||
);
|
||||
if (!pluginMain.existsSync()) {
|
||||
return TaskResult.failure('${pluginMain.path} does not exist');
|
||||
}
|
||||
@@ -56,11 +56,9 @@ class ApluginPlatformInterfaceMacOS {
|
||||
''', flush: true);
|
||||
|
||||
// Patch plugin main pubspec file.
|
||||
final File pluginImplPubspec = File(path.join(
|
||||
tempDir.absolute.path,
|
||||
'aplugin_platform_implementation',
|
||||
'pubspec.yaml',
|
||||
));
|
||||
final File pluginImplPubspec = File(
|
||||
path.join(tempDir.absolute.path, 'aplugin_platform_implementation', 'pubspec.yaml'),
|
||||
);
|
||||
String pluginImplPubspecContent = await pluginImplPubspec.readAsString();
|
||||
pluginImplPubspecContent = pluginImplPubspecContent.replaceFirst(
|
||||
' pluginClass: ApluginPlatformImplementationPlugin',
|
||||
@@ -68,11 +66,11 @@ class ApluginPlatformInterfaceMacOS {
|
||||
' dartPluginClass: ApluginPlatformInterfaceMacOS\n',
|
||||
);
|
||||
pluginImplPubspecContent = pluginImplPubspecContent.replaceFirst(
|
||||
' platforms:\n',
|
||||
' implements: aplugin_platform_interface\n'
|
||||
' platforms:\n');
|
||||
await pluginImplPubspec.writeAsString(pluginImplPubspecContent,
|
||||
flush: true);
|
||||
' platforms:\n',
|
||||
' implements: aplugin_platform_interface\n'
|
||||
' platforms:\n',
|
||||
);
|
||||
await pluginImplPubspec.writeAsString(pluginImplPubspecContent, flush: true);
|
||||
|
||||
section('Create interface plugin');
|
||||
await inDirectory(tempDir, () async {
|
||||
@@ -89,25 +87,21 @@ class ApluginPlatformInterfaceMacOS {
|
||||
environment: environment,
|
||||
);
|
||||
});
|
||||
final File pluginInterfacePubspec = File(path.join(
|
||||
tempDir.absolute.path,
|
||||
'aplugin_platform_interface',
|
||||
'pubspec.yaml',
|
||||
));
|
||||
String pluginInterfacePubspecContent =
|
||||
await pluginInterfacePubspec.readAsString();
|
||||
pluginInterfacePubspecContent =
|
||||
pluginInterfacePubspecContent.replaceFirst(
|
||||
' pluginClass: ApluginPlatformInterfacePlugin',
|
||||
' default_package: aplugin_platform_implementation\n');
|
||||
pluginInterfacePubspecContent =
|
||||
pluginInterfacePubspecContent.replaceFirst(
|
||||
'dependencies:',
|
||||
'dependencies:\n'
|
||||
' aplugin_platform_implementation:\n'
|
||||
' path: ../aplugin_platform_implementation\n');
|
||||
await pluginInterfacePubspec.writeAsString(pluginInterfacePubspecContent,
|
||||
flush: true);
|
||||
final File pluginInterfacePubspec = File(
|
||||
path.join(tempDir.absolute.path, 'aplugin_platform_interface', 'pubspec.yaml'),
|
||||
);
|
||||
String pluginInterfacePubspecContent = await pluginInterfacePubspec.readAsString();
|
||||
pluginInterfacePubspecContent = pluginInterfacePubspecContent.replaceFirst(
|
||||
' pluginClass: ApluginPlatformInterfacePlugin',
|
||||
' default_package: aplugin_platform_implementation\n',
|
||||
);
|
||||
pluginInterfacePubspecContent = pluginInterfacePubspecContent.replaceFirst(
|
||||
'dependencies:',
|
||||
'dependencies:\n'
|
||||
' aplugin_platform_implementation:\n'
|
||||
' path: ../aplugin_platform_implementation\n',
|
||||
);
|
||||
await pluginInterfacePubspec.writeAsString(pluginInterfacePubspecContent, flush: true);
|
||||
|
||||
section('Create app');
|
||||
|
||||
@@ -126,46 +120,40 @@ class ApluginPlatformInterfaceMacOS {
|
||||
);
|
||||
});
|
||||
|
||||
final File appPubspec = File(path.join(
|
||||
tempDir.absolute.path,
|
||||
'app',
|
||||
'pubspec.yaml',
|
||||
));
|
||||
final File appPubspec = File(path.join(tempDir.absolute.path, 'app', 'pubspec.yaml'));
|
||||
String appPubspecContent = await appPubspec.readAsString();
|
||||
appPubspecContent = appPubspecContent.replaceFirst(
|
||||
'dependencies:',
|
||||
'dependencies:\n'
|
||||
' aplugin_platform_interface:\n'
|
||||
' path: ../aplugin_platform_interface\n');
|
||||
'dependencies:',
|
||||
'dependencies:\n'
|
||||
' aplugin_platform_interface:\n'
|
||||
' path: ../aplugin_platform_interface\n',
|
||||
);
|
||||
await appPubspec.writeAsString(appPubspecContent, flush: true);
|
||||
|
||||
section('Flutter run for macos');
|
||||
|
||||
late Process run;
|
||||
await inDirectory(path.join(tempDir.path, 'app'), () async {
|
||||
run = await startFlutter(
|
||||
'run',
|
||||
options: <String>['-d', 'macos', '-v'],
|
||||
);
|
||||
run = await startFlutter('run', options: <String>['-d', 'macos', '-v']);
|
||||
});
|
||||
|
||||
Completer<void> registryExecutedCompleter = Completer<void>();
|
||||
final StreamSubscription<void> stdoutSub = run.stdout
|
||||
.transform<String>(utf8.decoder)
|
||||
.transform<String>(const LineSplitter())
|
||||
.listen((String line) {
|
||||
if (line.contains('ApluginPlatformInterfaceMacOS.registerWith() was called')) {
|
||||
registryExecutedCompleter.complete();
|
||||
}
|
||||
print('stdout: $line');
|
||||
});
|
||||
.transform<String>(utf8.decoder)
|
||||
.transform<String>(const LineSplitter())
|
||||
.listen((String line) {
|
||||
if (line.contains('ApluginPlatformInterfaceMacOS.registerWith() was called')) {
|
||||
registryExecutedCompleter.complete();
|
||||
}
|
||||
print('stdout: $line');
|
||||
});
|
||||
|
||||
final StreamSubscription<void> stderrSub = run.stderr
|
||||
.transform<String>(utf8.decoder)
|
||||
.transform<String>(const LineSplitter())
|
||||
.listen((String line) {
|
||||
print('stderr: $line');
|
||||
});
|
||||
.transform<String>(utf8.decoder)
|
||||
.transform<String>(const LineSplitter())
|
||||
.listen((String line) {
|
||||
print('stderr: $line');
|
||||
});
|
||||
|
||||
final Future<void> stdoutDone = stdoutSub.asFuture<void>();
|
||||
final Future<void> stderrDone = stderrSub.asFuture<void>();
|
||||
@@ -175,12 +163,7 @@ class ApluginPlatformInterfaceMacOS {
|
||||
}
|
||||
|
||||
Future<void> waitOrExit(Future<void> future) async {
|
||||
final dynamic result = await Future.any<dynamic>(
|
||||
<Future<dynamic>>[
|
||||
future,
|
||||
run.exitCode,
|
||||
],
|
||||
);
|
||||
final dynamic result = await Future.any<dynamic>(<Future<dynamic>>[future, run.exitCode]);
|
||||
if (result is int) {
|
||||
await waitForStreams();
|
||||
throw 'process exited with code $result';
|
||||
|
||||
@@ -46,11 +46,7 @@ Future<TaskResult> _runWithTempDir(Directory tempDir) async {
|
||||
const String testDirName = 'entrypoint_dart_registrant';
|
||||
final String testPath = '${tempDir.path}/$testDirName';
|
||||
await inDirectory(tempDir, () async {
|
||||
await flutter('create', options: <String>[
|
||||
'--platforms',
|
||||
'android',
|
||||
testDirName,
|
||||
]);
|
||||
await flutter('create', options: <String>['--platforms', 'android', testDirName]);
|
||||
});
|
||||
final String mainPath = '${tempDir.path}/$testDirName/lib/main.dart';
|
||||
print(mainPath);
|
||||
@@ -65,18 +61,17 @@ Future<TaskResult> _runWithTempDir(Directory tempDir) async {
|
||||
// (which path_provider has).
|
||||
await flutter('pub', options: <String>['add', 'path_provider:2.0.9']);
|
||||
// The problem only manifested on release builds, so we test release.
|
||||
final Process process =
|
||||
await startFlutter('run', options: <String>['--release']);
|
||||
final Process process = await startFlutter('run', options: <String>['--release']);
|
||||
final Completer<String> completer = Completer<String>();
|
||||
final StreamSubscription<String> stdoutSub = process.stdout
|
||||
.transform<String>(const Utf8Decoder())
|
||||
.transform<String>(const LineSplitter())
|
||||
.listen((String line) async {
|
||||
print(line);
|
||||
if (line.contains(_messagePrefix)) {
|
||||
completer.complete(line);
|
||||
}
|
||||
});
|
||||
print(line);
|
||||
if (line.contains(_messagePrefix)) {
|
||||
completer.complete(line);
|
||||
}
|
||||
});
|
||||
final String entrypoint = await completer.future;
|
||||
await stdoutSub.cancel();
|
||||
process.stdin.write('q');
|
||||
@@ -95,8 +90,7 @@ Future<TaskResult> _runWithTempDir(Directory tempDir) async {
|
||||
/// registrant.
|
||||
TaskFunction entrypointDartRegistrant() {
|
||||
return () async {
|
||||
final Directory tempDir =
|
||||
Directory.systemTemp.createTempSync('entrypoint_dart_registrant.');
|
||||
final Directory tempDir = Directory.systemTemp.createTempSync('entrypoint_dart_registrant.');
|
||||
try {
|
||||
return await _runWithTempDir(tempDir);
|
||||
} finally {
|
||||
|
||||
@@ -13,10 +13,10 @@ import '../framework/utils.dart';
|
||||
const int _kRunsPerBenchmark = 10;
|
||||
|
||||
Future<TaskResult> flutterToolStartupBenchmarkTask() async {
|
||||
final Directory projectParentDirectory =
|
||||
Directory.systemTemp.createTempSync('flutter_tool_startup_benchmark');
|
||||
final Directory projectDirectory =
|
||||
dir(path.join(projectParentDirectory.path, 'benchmark'));
|
||||
final Directory projectParentDirectory = Directory.systemTemp.createTempSync(
|
||||
'flutter_tool_startup_benchmark',
|
||||
);
|
||||
final Directory projectDirectory = dir(path.join(projectParentDirectory.path, 'benchmark'));
|
||||
await inDirectory<void>(flutterDirectory, () async {
|
||||
await flutter('update-packages');
|
||||
await flutter('create', options: <String>[projectDirectory.path]);
|
||||
@@ -26,43 +26,37 @@ Future<TaskResult> flutterToolStartupBenchmarkTask() async {
|
||||
|
||||
final Map<String, dynamic> data = <String, dynamic>{
|
||||
// `flutter test` in dir with no `test` folder.
|
||||
...(await _Benchmark(
|
||||
projectDirectory,
|
||||
'test startup',
|
||||
'test',
|
||||
).run())
|
||||
.asMap('flutter_tool_startup_test'),
|
||||
...(await _Benchmark(projectDirectory, 'test startup', 'test').run()).asMap(
|
||||
'flutter_tool_startup_test',
|
||||
),
|
||||
|
||||
// `flutter test -d foo_device` in dir with no `test` folder.
|
||||
...(await _Benchmark(
|
||||
projectDirectory,
|
||||
'test startup with specified device',
|
||||
'test',
|
||||
options: <String>['-d', 'foo_device'],
|
||||
).run())
|
||||
projectDirectory,
|
||||
'test startup with specified device',
|
||||
'test',
|
||||
options: <String>['-d', 'foo_device'],
|
||||
).run())
|
||||
.asMap('flutter_tool_startup_test_with_specified_device'),
|
||||
|
||||
// `flutter test -v` where no android sdk will be found (at least currently).
|
||||
...(await _Benchmark(
|
||||
projectDirectory,
|
||||
'test startup no android sdk',
|
||||
'test',
|
||||
options: <String>['-v'],
|
||||
environment: <String, String>{
|
||||
'ANDROID_HOME': 'dummy value',
|
||||
'ANDROID_SDK_ROOT': 'dummy value',
|
||||
'PATH': pathWithoutWhereHits(<String>['adb', 'aapt']),
|
||||
},
|
||||
).run())
|
||||
projectDirectory,
|
||||
'test startup no android sdk',
|
||||
'test',
|
||||
options: <String>['-v'],
|
||||
environment: <String, String>{
|
||||
'ANDROID_HOME': 'dummy value',
|
||||
'ANDROID_SDK_ROOT': 'dummy value',
|
||||
'PATH': pathWithoutWhereHits(<String>['adb', 'aapt']),
|
||||
},
|
||||
).run())
|
||||
.asMap('flutter_tool_startup_test_no_android_sdk'),
|
||||
|
||||
// `flutter -h`.
|
||||
...(await _Benchmark(
|
||||
projectDirectory,
|
||||
'help startup',
|
||||
'-h',
|
||||
).run())
|
||||
.asMap('flutter_tool_startup_help'),
|
||||
...(await _Benchmark(projectDirectory, 'help startup', '-h').run()).asMap(
|
||||
'flutter_tool_startup_help',
|
||||
),
|
||||
};
|
||||
|
||||
// Cleanup.
|
||||
@@ -119,17 +113,18 @@ class _BenchmarkResult {
|
||||
final int max; // Milliseconds
|
||||
|
||||
Map<String, dynamic> asMap(String name) {
|
||||
return <String, dynamic>{
|
||||
name: mean,
|
||||
'${name}_minimum': min,
|
||||
'${name}_maximum': max,
|
||||
};
|
||||
return <String, dynamic>{name: mean, '${name}_minimum': min, '${name}_maximum': max};
|
||||
}
|
||||
}
|
||||
|
||||
class _Benchmark {
|
||||
_Benchmark(this.directory, this.title, this.command,
|
||||
{this.options = const <String>[], this.environment});
|
||||
_Benchmark(
|
||||
this.directory,
|
||||
this.title,
|
||||
this.command, {
|
||||
this.options = const <String>[],
|
||||
this.environment,
|
||||
});
|
||||
|
||||
final Directory directory;
|
||||
|
||||
@@ -148,8 +143,7 @@ class _Benchmark {
|
||||
stopwatch.start();
|
||||
// canFail is set to true, as e.g. `flutter test` in a dir with no `test`
|
||||
// directory sets a non-zero return value.
|
||||
await flutter(command,
|
||||
options: options, canFail: true, environment: environment);
|
||||
await flutter(command, options: options, canFail: true, environment: environment);
|
||||
stopwatch.stop();
|
||||
});
|
||||
return stopwatch.elapsedMilliseconds;
|
||||
|
||||
@@ -12,7 +12,9 @@ import '../framework/task_result.dart';
|
||||
import '../framework/utils.dart';
|
||||
import 'build_test_task.dart';
|
||||
|
||||
final Directory galleryDirectory = dir('${flutterDirectory.path}/dev/integration_tests/flutter_gallery');
|
||||
final Directory galleryDirectory = dir(
|
||||
'${flutterDirectory.path}/dev/integration_tests/flutter_gallery',
|
||||
);
|
||||
|
||||
/// Temp function during gallery tests transition to build+test model.
|
||||
///
|
||||
@@ -42,14 +44,9 @@ TaskFunction createGalleryTransitionE2EBuildTest(
|
||||
).call;
|
||||
}
|
||||
|
||||
TaskFunction createGalleryTransitionE2ETest({
|
||||
bool semanticsEnabled = false,
|
||||
bool? enableImpeller,
|
||||
}) {
|
||||
TaskFunction createGalleryTransitionE2ETest({bool semanticsEnabled = false, bool? enableImpeller}) {
|
||||
return GalleryTransitionTest(
|
||||
testFile: semanticsEnabled
|
||||
? 'transitions_perf_e2e_with_semantics'
|
||||
: 'transitions_perf_e2e',
|
||||
testFile: semanticsEnabled ? 'transitions_perf_e2e_with_semantics' : 'transitions_perf_e2e',
|
||||
needFullTimeline: false,
|
||||
timelineSummaryFile: 'e2e_perf_summary',
|
||||
transitionDurationFile: null,
|
||||
@@ -66,21 +63,24 @@ TaskFunction createGalleryTransitionHybridBuildTest(
|
||||
return GalleryTransitionBuildTest(
|
||||
args,
|
||||
semanticsEnabled: semanticsEnabled,
|
||||
driverFile: semanticsEnabled ? 'transitions_perf_hybrid_with_semantics_test' : 'transitions_perf_hybrid_test',
|
||||
driverFile:
|
||||
semanticsEnabled
|
||||
? 'transitions_perf_hybrid_with_semantics_test'
|
||||
: 'transitions_perf_hybrid_test',
|
||||
).call;
|
||||
}
|
||||
|
||||
TaskFunction createGalleryTransitionHybridTest({bool semanticsEnabled = false}) {
|
||||
return GalleryTransitionTest(
|
||||
semanticsEnabled: semanticsEnabled,
|
||||
driverFile: semanticsEnabled
|
||||
? 'transitions_perf_hybrid_with_semantics_test'
|
||||
: 'transitions_perf_hybrid_test',
|
||||
driverFile:
|
||||
semanticsEnabled
|
||||
? 'transitions_perf_hybrid_with_semantics_test'
|
||||
: 'transitions_perf_hybrid_test',
|
||||
).call;
|
||||
}
|
||||
|
||||
class GalleryTransitionTest {
|
||||
|
||||
GalleryTransitionTest({
|
||||
this.semanticsEnabled = false,
|
||||
this.testFile = 'transitions_perf',
|
||||
@@ -109,7 +109,9 @@ class GalleryTransitionTest {
|
||||
final Device device = await devices.workingDevice;
|
||||
await device.unlock();
|
||||
final String deviceId = device.deviceId;
|
||||
final Directory galleryDirectory = dir('${flutterDirectory.path}/dev/integration_tests/flutter_gallery');
|
||||
final Directory galleryDirectory = dir(
|
||||
'${flutterDirectory.path}/dev/integration_tests/flutter_gallery',
|
||||
);
|
||||
await inDirectory<void>(galleryDirectory, () async {
|
||||
String? applicationBinaryPath;
|
||||
if (deviceOperatingSystem == DeviceOperatingSystem.android) {
|
||||
@@ -129,41 +131,39 @@ class GalleryTransitionTest {
|
||||
applicationBinaryPath = 'build/app/outputs/flutter-apk/app-profile.apk';
|
||||
}
|
||||
|
||||
final String testDriver = driverFile ?? (semanticsEnabled
|
||||
? '${testFile}_with_semantics_test'
|
||||
: '${testFile}_test');
|
||||
final String testDriver =
|
||||
driverFile ?? (semanticsEnabled ? '${testFile}_with_semantics_test' : '${testFile}_test');
|
||||
section('DRIVE START');
|
||||
await flutter('drive', options: <String>[
|
||||
'--profile',
|
||||
if (enableImpeller != null && enableImpeller!) '--enable-impeller',
|
||||
if (enableImpeller != null && !enableImpeller!) '--no-enable-impeller',
|
||||
if (needFullTimeline)
|
||||
'--trace-startup',
|
||||
if (applicationBinaryPath != null)
|
||||
'--use-application-binary=$applicationBinaryPath'
|
||||
else
|
||||
...<String>[
|
||||
'-t',
|
||||
'test_driver/$testFile.dart',
|
||||
],
|
||||
'--driver',
|
||||
'test_driver/$testDriver.dart',
|
||||
'-d',
|
||||
deviceId,
|
||||
'-v',
|
||||
'--verbose-system-logs'
|
||||
]);
|
||||
await flutter(
|
||||
'drive',
|
||||
options: <String>[
|
||||
'--profile',
|
||||
if (enableImpeller != null && enableImpeller!) '--enable-impeller',
|
||||
if (enableImpeller != null && !enableImpeller!) '--no-enable-impeller',
|
||||
if (needFullTimeline) '--trace-startup',
|
||||
if (applicationBinaryPath != null)
|
||||
'--use-application-binary=$applicationBinaryPath'
|
||||
else ...<String>['-t', 'test_driver/$testFile.dart'],
|
||||
'--driver',
|
||||
'test_driver/$testDriver.dart',
|
||||
'-d',
|
||||
deviceId,
|
||||
'-v',
|
||||
'--verbose-system-logs',
|
||||
],
|
||||
);
|
||||
});
|
||||
|
||||
final String testOutputDirectory = Platform.environment['FLUTTER_TEST_OUTPUTS_DIR'] ?? '${galleryDirectory.path}/build';
|
||||
final Map<String, dynamic> summary = json.decode(
|
||||
file('$testOutputDirectory/$timelineSummaryFile.json').readAsStringSync(),
|
||||
) as Map<String, dynamic>;
|
||||
final String testOutputDirectory =
|
||||
Platform.environment['FLUTTER_TEST_OUTPUTS_DIR'] ?? '${galleryDirectory.path}/build';
|
||||
final Map<String, dynamic> summary =
|
||||
json.decode(file('$testOutputDirectory/$timelineSummaryFile.json').readAsStringSync())
|
||||
as Map<String, dynamic>;
|
||||
|
||||
if (transitionDurationFile != null) {
|
||||
final Map<String, dynamic> original = json.decode(
|
||||
file('$testOutputDirectory/$transitionDurationFile.json').readAsStringSync(),
|
||||
) as Map<String, dynamic>;
|
||||
final Map<String, dynamic> original =
|
||||
json.decode(file('$testOutputDirectory/$transitionDurationFile.json').readAsStringSync())
|
||||
as Map<String, dynamic>;
|
||||
final Map<String, List<int>> transitions = <String, List<int>>{};
|
||||
for (final String key in original.keys) {
|
||||
transitions[key] = List<int>.from(original[key] as List<dynamic>);
|
||||
@@ -173,16 +173,14 @@ class GalleryTransitionTest {
|
||||
}
|
||||
|
||||
final bool isAndroid = deviceOperatingSystem == DeviceOperatingSystem.android;
|
||||
return TaskResult.success(summary,
|
||||
return TaskResult.success(
|
||||
summary,
|
||||
detailFiles: <String>[
|
||||
if (transitionDurationFile != null)
|
||||
'$testOutputDirectory/$transitionDurationFile.json',
|
||||
if (timelineTraceFile != null)
|
||||
'$testOutputDirectory/$timelineTraceFile.json',
|
||||
if (transitionDurationFile != null) '$testOutputDirectory/$transitionDurationFile.json',
|
||||
if (timelineTraceFile != null) '$testOutputDirectory/$timelineTraceFile.json',
|
||||
],
|
||||
benchmarkScoreKeys: <String>[
|
||||
if (transitionDurationFile != null)
|
||||
'missed_transition_count',
|
||||
if (transitionDurationFile != null) 'missed_transition_count',
|
||||
'average_frame_build_time_millis',
|
||||
'worst_frame_build_time_millis',
|
||||
'90th_percentile_frame_build_time_millis',
|
||||
@@ -250,7 +248,8 @@ class GalleryTransitionBuildTest extends BuildTestTask {
|
||||
final String? transitionDurationFile;
|
||||
final String? driverFile;
|
||||
|
||||
final String testOutputDirectory = Platform.environment['FLUTTER_TEST_OUTPUTS_DIR'] ?? '${galleryDirectory.path}/build';
|
||||
final String testOutputDirectory =
|
||||
Platform.environment['FLUTTER_TEST_OUTPUTS_DIR'] ?? '${galleryDirectory.path}/build';
|
||||
|
||||
@override
|
||||
void copyArtifacts() {
|
||||
@@ -283,20 +282,15 @@ class GalleryTransitionBuildTest extends BuildTestTask {
|
||||
'android-arm,android-arm64',
|
||||
];
|
||||
} else if (deviceOperatingSystem == DeviceOperatingSystem.ios) {
|
||||
return <String>[
|
||||
'ios',
|
||||
'--codesign',
|
||||
'--profile',
|
||||
'-t',
|
||||
'test_driver/$testFile.dart',
|
||||
];
|
||||
return <String>['ios', '--codesign', '--profile', '-t', 'test_driver/$testFile.dart'];
|
||||
}
|
||||
throw Exception('$deviceOperatingSystem has no build configuration');
|
||||
}
|
||||
|
||||
@override
|
||||
List<String> getTestArgs(DeviceOperatingSystem deviceOperatingSystem, String deviceId) {
|
||||
final String testDriver = driverFile ?? (semanticsEnabled ? '${testFile}_with_semantics_test' : '${testFile}_test');
|
||||
final String testDriver =
|
||||
driverFile ?? (semanticsEnabled ? '${testFile}_with_semantics_test' : '${testFile}_test');
|
||||
return <String>[
|
||||
'--no-dds',
|
||||
'--profile',
|
||||
@@ -315,14 +309,14 @@ class GalleryTransitionBuildTest extends BuildTestTask {
|
||||
|
||||
@override
|
||||
Future<TaskResult> parseTaskResult() async {
|
||||
final Map<String, dynamic> summary = json.decode(
|
||||
file('$testOutputDirectory/$timelineSummaryFile.json').readAsStringSync(),
|
||||
) as Map<String, dynamic>;
|
||||
final Map<String, dynamic> summary =
|
||||
json.decode(file('$testOutputDirectory/$timelineSummaryFile.json').readAsStringSync())
|
||||
as Map<String, dynamic>;
|
||||
|
||||
if (transitionDurationFile != null) {
|
||||
final Map<String, dynamic> original = json.decode(
|
||||
file('$testOutputDirectory/$transitionDurationFile.json').readAsStringSync(),
|
||||
) as Map<String, dynamic>;
|
||||
final Map<String, dynamic> original =
|
||||
json.decode(file('$testOutputDirectory/$transitionDurationFile.json').readAsStringSync())
|
||||
as Map<String, dynamic>;
|
||||
final Map<String, List<int>> transitions = <String, List<int>>{};
|
||||
for (final String key in original.keys) {
|
||||
transitions[key] = List<int>.from(original[key] as List<dynamic>);
|
||||
@@ -397,7 +391,9 @@ int _countMissedTransitions(Map<String, List<int>> transitions) {
|
||||
transitions.forEach((String demoName, List<int> durations) {
|
||||
final int longestDuration = durations.reduce(math.max);
|
||||
if (longestDuration > kTransitionBudget) {
|
||||
print('$demoName missed transition time budget ($longestDuration µs > $kTransitionBudget µs)');
|
||||
print(
|
||||
'$demoName missed transition time budget ($longestDuration µs > $kTransitionBudget µs)',
|
||||
);
|
||||
count++;
|
||||
}
|
||||
});
|
||||
|
||||
@@ -15,8 +15,12 @@ import '../framework/running_processes.dart';
|
||||
import '../framework/task_result.dart';
|
||||
import '../framework/utils.dart';
|
||||
|
||||
final Directory _editedFlutterGalleryDir = dir(path.join(Directory.systemTemp.path, 'edited_flutter_gallery'));
|
||||
final Directory flutterGalleryDir = dir(path.join(flutterDirectory.path, 'dev/integration_tests/flutter_gallery'));
|
||||
final Directory _editedFlutterGalleryDir = dir(
|
||||
path.join(Directory.systemTemp.path, 'edited_flutter_gallery'),
|
||||
);
|
||||
final Directory flutterGalleryDir = dir(
|
||||
path.join(flutterDirectory.path, 'dev/integration_tests/flutter_gallery'),
|
||||
);
|
||||
const String kSourceLine = 'fontSize: (orientation == Orientation.portrait) ? 32.0 : 24.0';
|
||||
const String kReplacementLine = 'fontSize: (orientation == Orientation.portrait) ? 34.0 : 24.0';
|
||||
|
||||
@@ -26,9 +30,9 @@ TaskFunction createHotModeTest({
|
||||
List<String>? additionalOptions,
|
||||
}) {
|
||||
// This file is modified during the test and needs to be restored at the end.
|
||||
final File flutterFrameworkSource = file(path.join(
|
||||
flutterDirectory.path, 'packages/flutter/lib/src/widgets/framework.dart',
|
||||
));
|
||||
final File flutterFrameworkSource = file(
|
||||
path.join(flutterDirectory.path, 'packages/flutter/lib/src/widgets/framework.dart'),
|
||||
);
|
||||
final String oldContents = flutterFrameworkSource.readAsStringSync();
|
||||
return () async {
|
||||
if (deviceIdOverride == null) {
|
||||
@@ -56,7 +60,6 @@ TaskFunction createHotModeTest({
|
||||
late Map<String, dynamic> largeReloadData;
|
||||
late Map<String, dynamic> freshRestartReloadsData;
|
||||
|
||||
|
||||
await inDirectory<void>(flutterDirectory, () async {
|
||||
rmTree(_editedFlutterGalleryDir);
|
||||
mkdirs(_editedFlutterGalleryDir);
|
||||
@@ -73,14 +76,15 @@ TaskFunction createHotModeTest({
|
||||
}
|
||||
if (hotReloadCount == 0) {
|
||||
// Update a file for 2 library invalidation.
|
||||
final File appDartSource = file(path.join(
|
||||
_editedFlutterGalleryDir.path,
|
||||
'lib/gallery/app.dart',
|
||||
));
|
||||
appDartSource.writeAsStringSync(appDartSource.readAsStringSync().replaceFirst(
|
||||
"'Flutter Gallery'",
|
||||
"'Updated Flutter Gallery'",
|
||||
));
|
||||
final File appDartSource = file(
|
||||
path.join(_editedFlutterGalleryDir.path, 'lib/gallery/app.dart'),
|
||||
);
|
||||
appDartSource.writeAsStringSync(
|
||||
appDartSource.readAsStringSync().replaceFirst(
|
||||
"'Flutter Gallery'",
|
||||
"'Updated Flutter Gallery'",
|
||||
),
|
||||
);
|
||||
process.stdin.writeln('r');
|
||||
hotReloadCount += 1;
|
||||
} else {
|
||||
@@ -98,11 +102,11 @@ TaskFunction createHotModeTest({
|
||||
}
|
||||
if (hotReloadCount == 1) {
|
||||
// Update a file for ~50 library invalidation.
|
||||
final File appDartSource = file(path.join(
|
||||
_editedFlutterGalleryDir.path, 'lib/demo/calculator/home.dart',
|
||||
));
|
||||
final File appDartSource = file(
|
||||
path.join(_editedFlutterGalleryDir.path, 'lib/demo/calculator/home.dart'),
|
||||
);
|
||||
appDartSource.writeAsStringSync(
|
||||
appDartSource.readAsStringSync().replaceFirst(kSourceLine, kReplacementLine)
|
||||
appDartSource.readAsStringSync().replaceFirst(kSourceLine, kReplacementLine),
|
||||
);
|
||||
process.stdin.writeln('r');
|
||||
hotReloadCount += 1;
|
||||
@@ -122,7 +126,7 @@ TaskFunction createHotModeTest({
|
||||
if (hotReloadCount == 2) {
|
||||
// Trigger a framework invalidation (370 libraries) without modifying the source
|
||||
flutterFrameworkSource.writeAsStringSync(
|
||||
'${flutterFrameworkSource.readAsStringSync()}\n'
|
||||
'${flutterFrameworkSource.readAsStringSync()}\n',
|
||||
);
|
||||
process.stdin.writeln('r');
|
||||
hotReloadCount += 1;
|
||||
@@ -138,34 +142,36 @@ TaskFunction createHotModeTest({
|
||||
// Start `flutter run` again to make sure it loads from the previous
|
||||
// state. Frontend loads up from previously generated kernel files.
|
||||
{
|
||||
final Process process = await startFlutter(
|
||||
'run',
|
||||
options: options,
|
||||
);
|
||||
final Process process = await startFlutter('run', options: options);
|
||||
final Completer<void> stdoutDone = Completer<void>();
|
||||
final Completer<void> stderrDone = Completer<void>();
|
||||
process.stdout
|
||||
.transform<String>(utf8.decoder)
|
||||
.transform<String>(const LineSplitter())
|
||||
.listen((String line) {
|
||||
if (line.contains('Reloaded ')) {
|
||||
process.stdin.writeln('q');
|
||||
}
|
||||
print('stdout: $line');
|
||||
}, onDone: () {
|
||||
stdoutDone.complete();
|
||||
});
|
||||
.listen(
|
||||
(String line) {
|
||||
if (line.contains('Reloaded ')) {
|
||||
process.stdin.writeln('q');
|
||||
}
|
||||
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();
|
||||
});
|
||||
.listen(
|
||||
(String line) {
|
||||
print('stderr: $line');
|
||||
},
|
||||
onDone: () {
|
||||
stderrDone.complete();
|
||||
},
|
||||
);
|
||||
|
||||
await Future.wait<void>(
|
||||
<Future<void>>[stdoutDone.future, stderrDone.future]);
|
||||
await Future.wait<void>(<Future<void>>[stdoutDone.future, stderrDone.future]);
|
||||
await process.exitCode;
|
||||
|
||||
freshRestartReloadsData =
|
||||
@@ -274,32 +280,26 @@ Future<Map<String, dynamic>> captureReloadData({
|
||||
required File benchmarkFile,
|
||||
required void Function(String, Process) onLine,
|
||||
}) async {
|
||||
final Process process = await startFlutter(
|
||||
'run',
|
||||
options: options,
|
||||
);
|
||||
final Process process = await startFlutter('run', options: options);
|
||||
|
||||
final Completer<void> stdoutDone = Completer<void>();
|
||||
final Completer<void> stderrDone = Completer<void>();
|
||||
process.stdout
|
||||
.transform<String>(utf8.decoder)
|
||||
.transform<String>(const LineSplitter())
|
||||
.listen((String line) {
|
||||
onLine(line, process);
|
||||
print('stdout: $line');
|
||||
}, onDone: stdoutDone.complete);
|
||||
process.stdout.transform<String>(utf8.decoder).transform<String>(const LineSplitter()).listen((
|
||||
String line,
|
||||
) {
|
||||
onLine(line, process);
|
||||
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,
|
||||
);
|
||||
.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;
|
||||
final Map<String, dynamic> result = json.decode(benchmarkFile.readAsStringSync()) as Map<String, dynamic>;
|
||||
final Map<String, dynamic> result =
|
||||
json.decode(benchmarkFile.readAsStringSync()) as Map<String, dynamic>;
|
||||
benchmarkFile.deleteSync();
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -40,7 +40,9 @@ TaskFunction createIntegrationTestFlavorsTest({Map<String, String>? environment}
|
||||
).call;
|
||||
}
|
||||
|
||||
TaskFunction createExternalTexturesFrameRateIntegrationTest({ List<String> extraOptions = const <String>[] }) {
|
||||
TaskFunction createExternalTexturesFrameRateIntegrationTest({
|
||||
List<String> extraOptions = const <String>[],
|
||||
}) {
|
||||
return DriverTest(
|
||||
'${flutterDirectory.path}/dev/integration_tests/external_textures',
|
||||
'lib/frame_rate_main.dart',
|
||||
@@ -89,9 +91,7 @@ TaskFunction createIOSPlatformViewTests() {
|
||||
return DriverTest(
|
||||
'${flutterDirectory.path}/dev/integration_tests/ios_platform_view_tests',
|
||||
'lib/main.dart',
|
||||
extraOptions: <String>[
|
||||
'--dart-define=ENABLE_DRIVER_EXTENSION=true',
|
||||
],
|
||||
extraOptions: <String>['--dart-define=ENABLE_DRIVER_EXTENSION=true'],
|
||||
).call;
|
||||
}
|
||||
|
||||
@@ -135,19 +135,17 @@ TaskFunction createSolidColorTest({required bool enableImpeller}) {
|
||||
return DriverTest(
|
||||
'${flutterDirectory.path}/dev/integration_tests/ui',
|
||||
'lib/solid_color.dart',
|
||||
extraOptions: <String>[
|
||||
if (enableImpeller)
|
||||
'--enable-impeller'
|
||||
]
|
||||
extraOptions: <String>[if (enableImpeller) '--enable-impeller'],
|
||||
).call;
|
||||
}
|
||||
|
||||
TaskFunction dartDefinesTask() {
|
||||
return DriverTest(
|
||||
'${flutterDirectory.path}/dev/integration_tests/ui',
|
||||
'lib/defines.dart', extraOptions: <String>[
|
||||
'--dart-define=test.valueA=Example,A',
|
||||
'--dart-define=test.valueB=Value',
|
||||
'lib/defines.dart',
|
||||
extraOptions: <String>[
|
||||
'--dart-define=test.valueA=Example,A',
|
||||
'--dart-define=test.valueB=Value',
|
||||
],
|
||||
).call;
|
||||
}
|
||||
@@ -186,11 +184,10 @@ class DriverTest {
|
||||
DriverTest(
|
||||
this.testDirectory,
|
||||
this.testTarget, {
|
||||
this.extraOptions = const <String>[],
|
||||
this.deviceIdOverride,
|
||||
this.environment,
|
||||
}
|
||||
);
|
||||
this.extraOptions = const <String>[],
|
||||
this.deviceIdOverride,
|
||||
this.environment,
|
||||
});
|
||||
|
||||
final String testDirectory;
|
||||
final String testTarget;
|
||||
@@ -230,12 +227,11 @@ class IntegrationTest {
|
||||
IntegrationTest(
|
||||
this.testDirectory,
|
||||
this.testTarget, {
|
||||
this.extraOptions = const <String>[],
|
||||
this.createPlatforms = const <String>[],
|
||||
this.withTalkBack = false,
|
||||
this.environment,
|
||||
}
|
||||
);
|
||||
this.extraOptions = const <String>[],
|
||||
this.createPlatforms = const <String>[],
|
||||
this.withTalkBack = false,
|
||||
this.environment,
|
||||
});
|
||||
|
||||
final String testDirectory;
|
||||
final String testTarget;
|
||||
@@ -252,28 +248,22 @@ class IntegrationTest {
|
||||
await flutter('packages', options: <String>['get']);
|
||||
|
||||
if (createPlatforms.isNotEmpty) {
|
||||
await flutter('create', options: <String>[
|
||||
'--platforms',
|
||||
createPlatforms.join(','),
|
||||
'--no-overwrite',
|
||||
'.'
|
||||
]);
|
||||
await flutter(
|
||||
'create',
|
||||
options: <String>['--platforms', createPlatforms.join(','), '--no-overwrite', '.'],
|
||||
);
|
||||
}
|
||||
|
||||
if (withTalkBack) {
|
||||
if (device is! AndroidDevice) {
|
||||
return TaskResult.failure('A test that enables TalkBack can only be run on Android devices');
|
||||
return TaskResult.failure(
|
||||
'A test that enables TalkBack can only be run on Android devices',
|
||||
);
|
||||
}
|
||||
await enableTalkBack();
|
||||
}
|
||||
|
||||
final List<String> options = <String>[
|
||||
'-v',
|
||||
'-d',
|
||||
deviceId,
|
||||
testTarget,
|
||||
...extraOptions,
|
||||
];
|
||||
final List<String> options = <String>['-v', '-d', deviceId, testTarget, ...extraOptions];
|
||||
await flutter('test', options: options, environment: environment);
|
||||
|
||||
if (withTalkBack) {
|
||||
|
||||
@@ -19,7 +19,6 @@ TaskFunction createMicrobenchmarkTask({
|
||||
bool? enableImpeller,
|
||||
Map<String, String> environment = const <String, String>{},
|
||||
}) {
|
||||
|
||||
// Generate a seed for this test stable around the date.
|
||||
final DateTime seedDate = DateTime.now().toUtc().subtract(const Duration(hours: 7));
|
||||
final int seed = DateTime(seedDate.year, seedDate.month, seedDate.day).hashCode;
|
||||
@@ -29,21 +28,14 @@ TaskFunction createMicrobenchmarkTask({
|
||||
await device.unlock();
|
||||
await device.clearLogs();
|
||||
|
||||
final Directory appDir =
|
||||
dir(path.join(flutterDirectory.path, 'dev/benchmarks/microbenchmarks'));
|
||||
final Directory appDir = dir(
|
||||
path.join(flutterDirectory.path, 'dev/benchmarks/microbenchmarks'),
|
||||
);
|
||||
|
||||
// Hard-uninstall any prior apps.
|
||||
await inDirectory(appDir, () async {
|
||||
section('Uninstall previous microbenchmarks app');
|
||||
await flutter(
|
||||
'install',
|
||||
options: <String>[
|
||||
'-v',
|
||||
'--uninstall-only',
|
||||
'-d',
|
||||
device.deviceId,
|
||||
],
|
||||
);
|
||||
await flutter('install', options: <String>['-v', '--uninstall-only', '-d', device.deviceId]);
|
||||
});
|
||||
|
||||
Future<Map<String, double>> runMicrobench(String benchmarkPath) async {
|
||||
@@ -63,11 +55,7 @@ TaskFunction createMicrobenchmarkTask({
|
||||
'--dart-define=seed=$seed',
|
||||
benchmarkPath,
|
||||
];
|
||||
return startFlutter(
|
||||
'run',
|
||||
options: options,
|
||||
environment: environment,
|
||||
);
|
||||
return startFlutter('run', options: options, environment: environment);
|
||||
});
|
||||
return readJsonResults(flutterProcess);
|
||||
}
|
||||
@@ -79,7 +67,6 @@ TaskFunction createMicrobenchmarkTask({
|
||||
...await runMicrobench('lib/benchmark_collection.dart'),
|
||||
};
|
||||
|
||||
return TaskResult.success(allResults,
|
||||
benchmarkScoreKeys: allResults.keys.toList());
|
||||
return TaskResult.success(allResults, benchmarkScoreKeys: allResults.keys.toList());
|
||||
};
|
||||
}
|
||||
|
||||
@@ -15,11 +15,7 @@ import '../framework/utils.dart';
|
||||
|
||||
const String _packageName = 'package_with_native_assets';
|
||||
|
||||
const List<String> _buildModes = <String>[
|
||||
'debug',
|
||||
'profile',
|
||||
'release',
|
||||
];
|
||||
const List<String> _buildModes = <String>['debug', 'profile', 'release'];
|
||||
|
||||
TaskFunction createNativeAssetsTest({
|
||||
String? deviceIdOverride,
|
||||
@@ -41,7 +37,9 @@ TaskFunction createNativeAssetsTest({
|
||||
}
|
||||
final TaskResult buildModeResult = await inTempDir((Directory tempDirectory) async {
|
||||
final Directory packageDirectory = await createTestProject(_packageName, tempDirectory);
|
||||
final Directory exampleDirectory = dir(packageDirectory.uri.resolve('example/').toFilePath());
|
||||
final Directory exampleDirectory = dir(
|
||||
packageDirectory.uri.resolve('example/').toFilePath(),
|
||||
);
|
||||
|
||||
final List<String> options = <String>[
|
||||
'-d',
|
||||
@@ -128,22 +126,21 @@ Future<int> runFlutter({
|
||||
required List<String> options,
|
||||
required void Function(String, Process) onLine,
|
||||
}) async {
|
||||
final Process process = await startFlutter(
|
||||
'run',
|
||||
options: options,
|
||||
);
|
||||
final Process process = await startFlutter('run', options: options);
|
||||
|
||||
final Completer<void> stdoutDone = Completer<void>();
|
||||
final Completer<void> stderrDone = Completer<void>();
|
||||
process.stdout.transform<String>(utf8.decoder).transform<String>(const LineSplitter()).listen((String line) {
|
||||
process.stdout.transform<String>(utf8.decoder).transform<String>(const LineSplitter()).listen((
|
||||
String line,
|
||||
) {
|
||||
onLine(line, process);
|
||||
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,
|
||||
);
|
||||
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]);
|
||||
final int exitCode = await process.exitCode;
|
||||
@@ -154,52 +151,29 @@ final String _flutterBin = path.join(flutterDirectory.path, 'bin', 'flutter');
|
||||
|
||||
Future<void> enableNativeAssets() async {
|
||||
print('Enabling configs for native assets...');
|
||||
final int configResult = await exec(
|
||||
_flutterBin,
|
||||
<String>[
|
||||
'config',
|
||||
'-v',
|
||||
'--enable-native-assets',
|
||||
],
|
||||
canFail: true);
|
||||
final int configResult = await exec(_flutterBin, <String>[
|
||||
'config',
|
||||
'-v',
|
||||
'--enable-native-assets',
|
||||
], canFail: true);
|
||||
if (configResult != 0) {
|
||||
print('Failed to enable configuration, tasks may not run.');
|
||||
}
|
||||
}
|
||||
|
||||
Future<Directory> createTestProject(
|
||||
String packageName,
|
||||
Directory tempDirectory,
|
||||
) async {
|
||||
await exec(
|
||||
_flutterBin,
|
||||
<String>[
|
||||
'create',
|
||||
'--no-pub',
|
||||
'--template=package_ffi',
|
||||
packageName,
|
||||
],
|
||||
workingDirectory: tempDirectory.path,
|
||||
);
|
||||
Future<Directory> createTestProject(String packageName, Directory tempDirectory) async {
|
||||
await exec(_flutterBin, <String>[
|
||||
'create',
|
||||
'--no-pub',
|
||||
'--template=package_ffi',
|
||||
packageName,
|
||||
], workingDirectory: tempDirectory.path);
|
||||
|
||||
final Directory packageDirectory = Directory(
|
||||
path.join(tempDirectory.path, packageName),
|
||||
);
|
||||
await _pinDependencies(
|
||||
File(path.join(packageDirectory.path, 'pubspec.yaml')),
|
||||
);
|
||||
await _pinDependencies(
|
||||
File(path.join(packageDirectory.path, 'example', 'pubspec.yaml')),
|
||||
);
|
||||
final Directory packageDirectory = Directory(path.join(tempDirectory.path, packageName));
|
||||
await _pinDependencies(File(path.join(packageDirectory.path, 'pubspec.yaml')));
|
||||
await _pinDependencies(File(path.join(packageDirectory.path, 'example', 'pubspec.yaml')));
|
||||
|
||||
await exec(
|
||||
_flutterBin,
|
||||
<String>[
|
||||
'pub',
|
||||
'get',
|
||||
],
|
||||
workingDirectory: packageDirectory.path,
|
||||
);
|
||||
await exec(_flutterBin, <String>['pub', 'get'], workingDirectory: packageDirectory.path);
|
||||
|
||||
return packageDirectory;
|
||||
}
|
||||
@@ -210,9 +184,10 @@ Future<void> _pinDependencies(File pubspecFile) async {
|
||||
await pubspecFile.writeAsString(newPubspec);
|
||||
}
|
||||
|
||||
|
||||
Future<T> inTempDir<T>(Future<T> Function(Directory tempDirectory) fun) async {
|
||||
final Directory tempDirectory = dir(Directory.systemTemp.createTempSync().resolveSymbolicLinksSync());
|
||||
final Directory tempDirectory = dir(
|
||||
Directory.systemTemp.createTempSync().resolveSymbolicLinksSync(),
|
||||
);
|
||||
try {
|
||||
return await fun(tempDirectory);
|
||||
} finally {
|
||||
|
||||
@@ -13,11 +13,11 @@ class NewGalleryPerfTest extends PerfTest {
|
||||
super.timeoutSeconds,
|
||||
super.forceOpenGLES,
|
||||
}) : super(
|
||||
'${flutterDirectory.path}/dev/integration_tests/new_gallery',
|
||||
'test_driver/transitions_perf.dart',
|
||||
timelineFileName,
|
||||
dartDefine: dartDefine,
|
||||
createPlatforms: <String>['android', 'ios', 'web'],
|
||||
enableMergedPlatformThread: true,
|
||||
);
|
||||
'${flutterDirectory.path}/dev/integration_tests/new_gallery',
|
||||
'test_driver/transitions_perf.dart',
|
||||
timelineFileName,
|
||||
dartDefine: dartDefine,
|
||||
createPlatforms: <String>['android', 'ios', 'web'],
|
||||
enableMergedPlatformThread: true,
|
||||
);
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -18,8 +18,9 @@ TaskFunction runTask(adb.DeviceOperatingSystem operatingSystem) {
|
||||
final adb.Device device = await adb.devices.workingDevice;
|
||||
await device.unlock();
|
||||
|
||||
final Directory appDir = utils.dir(path.join(utils.flutterDirectory.path,
|
||||
'dev/benchmarks/platform_channels_benchmarks'));
|
||||
final Directory appDir = utils.dir(
|
||||
path.join(utils.flutterDirectory.path, 'dev/benchmarks/platform_channels_benchmarks'),
|
||||
);
|
||||
final Process flutterProcess = await utils.inDirectory(appDir, () async {
|
||||
final List<String> createArgs = <String>[
|
||||
'--platforms',
|
||||
@@ -39,15 +40,10 @@ TaskFunction runTask(adb.DeviceOperatingSystem operatingSystem) {
|
||||
'-d',
|
||||
device.deviceId,
|
||||
];
|
||||
return utils.startFlutter(
|
||||
'run',
|
||||
options: options,
|
||||
);
|
||||
return utils.startFlutter('run', options: options);
|
||||
});
|
||||
|
||||
final Map<String, double> results =
|
||||
await microbenchmarks.readJsonResults(flutterProcess);
|
||||
return TaskResult.success(results,
|
||||
benchmarkScoreKeys: results.keys.toList());
|
||||
final Map<String, double> results = await microbenchmarks.readJsonResults(flutterProcess);
|
||||
return TaskResult.success(results, benchmarkScoreKeys: results.keys.toList());
|
||||
};
|
||||
}
|
||||
|
||||
@@ -49,8 +49,7 @@ class PluginTest {
|
||||
final bool cocoapodsTransitiveFlutterDependency;
|
||||
|
||||
Future<TaskResult> call() async {
|
||||
final Directory tempDir =
|
||||
Directory.systemTemp.createTempSync('flutter_devicelab_plugin_test.');
|
||||
final Directory tempDir = Directory.systemTemp.createTempSync('flutter_devicelab_plugin_test.');
|
||||
// FFI plugins do not have support for `flutter test`.
|
||||
// `flutter test` does not do a native build.
|
||||
// Supporting `flutter test` would require invoking a native build.
|
||||
@@ -58,8 +57,13 @@ class PluginTest {
|
||||
try {
|
||||
section('Create plugin');
|
||||
final _FlutterProject plugin = await _FlutterProject.create(
|
||||
tempDir, options, buildTarget,
|
||||
name: 'plugintest', template: template, environment: pluginCreateEnvironment);
|
||||
tempDir,
|
||||
options,
|
||||
buildTarget,
|
||||
name: 'plugintest',
|
||||
template: template,
|
||||
environment: pluginCreateEnvironment,
|
||||
);
|
||||
if (dartOnlyPlugin) {
|
||||
await plugin.convertDefaultPluginToDartPlugin();
|
||||
}
|
||||
@@ -74,8 +78,14 @@ class PluginTest {
|
||||
}
|
||||
}
|
||||
section('Create Flutter app');
|
||||
final _FlutterProject app = await _FlutterProject.create(tempDir, options, buildTarget,
|
||||
name: 'plugintestapp', template: 'app', environment: appCreateEnvironment);
|
||||
final _FlutterProject app = await _FlutterProject.create(
|
||||
tempDir,
|
||||
options,
|
||||
buildTarget,
|
||||
name: 'plugintestapp',
|
||||
template: 'app',
|
||||
environment: appCreateEnvironment,
|
||||
);
|
||||
try {
|
||||
if (cocoapodsTransitiveFlutterDependency) {
|
||||
section('Disable Swift Package Manager');
|
||||
@@ -83,8 +93,7 @@ class PluginTest {
|
||||
}
|
||||
|
||||
section('Add plugins');
|
||||
await app.addPlugin('plugintest',
|
||||
pluginPath: path.join('..', 'plugintest'));
|
||||
await app.addPlugin('plugintest', pluginPath: path.join('..', 'plugintest'));
|
||||
await app.addPlugin('path_provider');
|
||||
section('Build app');
|
||||
await app.build(buildTarget, validateNativeBuildProject: !dartOnlyPlugin);
|
||||
@@ -115,7 +124,10 @@ class PluginTest {
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> _testLocalEngineConfiguration(_FlutterProject app, String fakeEngineSourcePath) async {
|
||||
Future<void> _testLocalEngineConfiguration(
|
||||
_FlutterProject app,
|
||||
String fakeEngineSourcePath,
|
||||
) async {
|
||||
// The tool requires that a directory that looks like an engine build
|
||||
// actually exists when passing --local-engine, so create a fake skeleton.
|
||||
final Directory buildDir = Directory(path.join(fakeEngineSourcePath, 'out', 'foo'));
|
||||
@@ -157,11 +169,11 @@ class _FlutterProject {
|
||||
String content = await pubspec.readAsString();
|
||||
content = content.replaceFirst(
|
||||
'# The following section is specific to Flutter packages.\n'
|
||||
'flutter:\n',
|
||||
'flutter:\n',
|
||||
'# The following section is specific to Flutter packages.\n'
|
||||
'flutter:\n'
|
||||
'\n'
|
||||
' disable-swift-package-manager: true\n'
|
||||
'flutter:\n'
|
||||
'\n'
|
||||
' disable-swift-package-manager: true\n',
|
||||
);
|
||||
await pubspec.writeAsString(content, flush: true);
|
||||
}
|
||||
@@ -169,12 +181,8 @@ class _FlutterProject {
|
||||
Future<void> addPlugin(String plugin, {String? pluginPath}) async {
|
||||
final File pubspec = pubspecFile;
|
||||
String content = await pubspec.readAsString();
|
||||
final String dependency =
|
||||
pluginPath != null ? '$plugin:\n path: $pluginPath' : '$plugin:';
|
||||
content = content.replaceFirst(
|
||||
'\ndependencies:\n',
|
||||
'\ndependencies:\n $dependency\n',
|
||||
);
|
||||
final String dependency = pluginPath != null ? '$plugin:\n path: $pluginPath' : '$plugin:';
|
||||
content = content.replaceFirst('\ndependencies:\n', '\ndependencies:\n $dependency\n');
|
||||
await pubspec.writeAsString(content, flush: true);
|
||||
}
|
||||
|
||||
@@ -204,13 +212,7 @@ class $dartPluginClass {
|
||||
await dartCode.writeAsString(content, flush: true);
|
||||
|
||||
// Remove any native plugin code.
|
||||
const List<String> platforms = <String>[
|
||||
'android',
|
||||
'ios',
|
||||
'linux',
|
||||
'macos',
|
||||
'windows',
|
||||
];
|
||||
const List<String> platforms = <String>['android', 'ios', 'linux', 'macos', 'windows'];
|
||||
for (final String platform in platforms) {
|
||||
final Directory platformDir = Directory(path.join(rootPath, platform));
|
||||
if (platformDir.existsSync()) {
|
||||
@@ -232,12 +234,12 @@ class $dartPluginClass {
|
||||
throw TaskResult.failure('Missing expected darwin platform plugin keys');
|
||||
}
|
||||
pubspecContent = pubspecContent.replaceAll(
|
||||
originalIOSKey,
|
||||
'$originalIOSKey sharedDarwinSource: true\n'
|
||||
originalIOSKey,
|
||||
'$originalIOSKey sharedDarwinSource: true\n',
|
||||
);
|
||||
pubspecContent = pubspecContent.replaceAll(
|
||||
originalMacOSKey,
|
||||
'$originalMacOSKey sharedDarwinSource: true\n'
|
||||
originalMacOSKey,
|
||||
'$originalMacOSKey sharedDarwinSource: true\n',
|
||||
);
|
||||
await pubspec.writeAsString(pubspecContent, flush: true);
|
||||
|
||||
@@ -258,7 +260,10 @@ class $dartPluginClass {
|
||||
|
||||
// Remove "s.platform = :ios" to work on all platforms, including macOS.
|
||||
podspecContent = podspecContent.replaceFirst(RegExp(r'.*s\.platform.*'), '');
|
||||
podspecContent = podspecContent.replaceFirst("s.dependency 'Flutter'", "s.ios.dependency 'Flutter'\ns.osx.dependency 'FlutterMacOS'");
|
||||
podspecContent = podspecContent.replaceFirst(
|
||||
"s.dependency 'Flutter'",
|
||||
"s.ios.dependency 'Flutter'\ns.osx.dependency 'FlutterMacOS'",
|
||||
);
|
||||
|
||||
await podspec.writeAsString(podspecContent, flush: true);
|
||||
|
||||
@@ -315,11 +320,12 @@ public class $pluginClass: NSObject, FlutterPlugin {
|
||||
switch (buildTarget) {
|
||||
case 'apk':
|
||||
if (await exec(
|
||||
path.join('.', 'gradlew'),
|
||||
<String>['testDebugUnitTest'],
|
||||
workingDirectory: path.join(rootPath, 'android'),
|
||||
canFail: true,
|
||||
) != 0) {
|
||||
path.join('.', 'gradlew'),
|
||||
<String>['testDebugUnitTest'],
|
||||
workingDirectory: path.join(rootPath, 'android'),
|
||||
canFail: true,
|
||||
) !=
|
||||
0) {
|
||||
throw TaskResult.failure('Platform unit tests failed');
|
||||
}
|
||||
case 'ios':
|
||||
@@ -342,10 +348,20 @@ public class $pluginClass: NSObject, FlutterPlugin {
|
||||
}
|
||||
case 'linux':
|
||||
if (await exec(
|
||||
path.join(rootPath, 'build', 'linux', 'x64', 'release', 'plugins', 'plugintest', 'plugintest_test'),
|
||||
<String>[],
|
||||
canFail: true,
|
||||
) != 0) {
|
||||
path.join(
|
||||
rootPath,
|
||||
'build',
|
||||
'linux',
|
||||
'x64',
|
||||
'release',
|
||||
'plugins',
|
||||
'plugintest',
|
||||
'plugintest_test',
|
||||
),
|
||||
<String>[],
|
||||
canFail: true,
|
||||
) !=
|
||||
0) {
|
||||
throw TaskResult.failure('Platform unit tests failed');
|
||||
}
|
||||
case 'macos':
|
||||
@@ -359,26 +375,35 @@ public class $pluginClass: NSObject, FlutterPlugin {
|
||||
throw TaskResult.failure('Platform unit tests failed');
|
||||
}
|
||||
case 'windows':
|
||||
final String arch = Abi.current() == Abi.windowsX64 ? 'x64': 'arm64';
|
||||
final String arch = Abi.current() == Abi.windowsX64 ? 'x64' : 'arm64';
|
||||
if (await exec(
|
||||
path.join(rootPath, 'build', 'windows', arch, 'plugins', 'plugintest', 'Release', 'plugintest_test.exe'),
|
||||
<String>[],
|
||||
canFail: true,
|
||||
) != 0) {
|
||||
path.join(
|
||||
rootPath,
|
||||
'build',
|
||||
'windows',
|
||||
arch,
|
||||
'plugins',
|
||||
'plugintest',
|
||||
'Release',
|
||||
'plugintest_test.exe',
|
||||
),
|
||||
<String>[],
|
||||
canFail: true,
|
||||
) !=
|
||||
0) {
|
||||
throw TaskResult.failure('Platform unit tests failed');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static Future<_FlutterProject> create(
|
||||
Directory directory,
|
||||
List<String> options,
|
||||
String target,
|
||||
{
|
||||
required String name,
|
||||
required String template,
|
||||
Map<String, String>? environment,
|
||||
}) async {
|
||||
Directory directory,
|
||||
List<String> options,
|
||||
String target, {
|
||||
required String name,
|
||||
required String template,
|
||||
Map<String, String>? environment,
|
||||
}) async {
|
||||
await inDirectory(directory, () async {
|
||||
await flutter(
|
||||
'create',
|
||||
@@ -405,11 +430,7 @@ public class $pluginClass: NSObject, FlutterPlugin {
|
||||
Future<void> addCocoapodsTransitiveFlutterDependency() async {
|
||||
final String iosDirectoryPath = path.join(rootPath, 'ios');
|
||||
|
||||
final File nativePod = File(path.join(
|
||||
iosDirectoryPath,
|
||||
'NativePod',
|
||||
'NativePod.podspec',
|
||||
));
|
||||
final File nativePod = File(path.join(iosDirectoryPath, 'NativePod', 'NativePod.podspec'));
|
||||
nativePod.createSync(recursive: true);
|
||||
nativePod.writeAsStringSync('''
|
||||
Pod::Spec.new do |s|
|
||||
@@ -425,12 +446,9 @@ Pod::Spec.new do |s|
|
||||
end
|
||||
''');
|
||||
|
||||
final File nativePodClass = File(path.join(
|
||||
iosDirectoryPath,
|
||||
'NativePod',
|
||||
'Classes',
|
||||
'NativePodTest.m',
|
||||
));
|
||||
final File nativePodClass = File(
|
||||
path.join(iosDirectoryPath, 'NativePod', 'Classes', 'NativePodTest.m'),
|
||||
);
|
||||
nativePodClass.createSync(recursive: true);
|
||||
nativePodClass.writeAsStringSync('''
|
||||
#import <Flutter/Flutter.h>
|
||||
@@ -446,7 +464,9 @@ end
|
||||
|
||||
final File podfileFile = File(path.join(iosDirectoryPath, 'Podfile'));
|
||||
final List<String> podfileContents = podfileFile.readAsLinesSync();
|
||||
final int index = podfileContents.indexWhere((String line) => line.contains('flutter_install_all_ios_pods'));
|
||||
final int index = podfileContents.indexWhere(
|
||||
(String line) => line.contains('flutter_install_all_ios_pods'),
|
||||
);
|
||||
podfileContents.insert(index, "pod 'NativePod', :path => 'NativePod'");
|
||||
podfileFile.writeAsStringSync(podfileContents.join('\n'));
|
||||
}
|
||||
@@ -458,12 +478,13 @@ end
|
||||
if (!podspec.existsSync()) {
|
||||
throw TaskResult.failure('podspec file missing at ${podspec.path}');
|
||||
}
|
||||
final String versionString = target == 'ios'
|
||||
? "s.platform = :ios, '12.0'"
|
||||
: "s.platform = :osx, '10.11'";
|
||||
final String versionString =
|
||||
target == 'ios' ? "s.platform = :ios, '12.0'" : "s.platform = :osx, '10.11'";
|
||||
String podspecContent = podspec.readAsStringSync();
|
||||
if (!podspecContent.contains(versionString)) {
|
||||
throw TaskResult.failure('Update this test to match plugin minimum $target deployment version');
|
||||
throw TaskResult.failure(
|
||||
'Update this test to match plugin minimum $target deployment version',
|
||||
);
|
||||
}
|
||||
// Add transitive dependency on AppAuth 1.6 targeting iOS 8 and macOS 10.9, which no longer builds in Xcode
|
||||
// to test the version is forced higher and builds.
|
||||
@@ -477,7 +498,10 @@ s.platform = :osx, '10.8'
|
||||
s.dependency 'AppAuth', '1.6.0'
|
||||
''';
|
||||
|
||||
podspecContent = podspecContent.replaceFirst(versionString, target == 'ios' ? iosContent : macosContent);
|
||||
podspecContent = podspecContent.replaceFirst(
|
||||
versionString,
|
||||
target == 'ios' ? iosContent : macosContent,
|
||||
);
|
||||
podspec.writeAsStringSync(podspecContent, flush: true);
|
||||
}
|
||||
|
||||
@@ -488,22 +512,23 @@ s.dependency 'AppAuth', '1.6.0'
|
||||
Directory? localEngine,
|
||||
}) async {
|
||||
await inDirectory(Directory(rootPath), () async {
|
||||
final String buildOutput = await evalFlutter('build', options: <String>[
|
||||
target,
|
||||
'-v',
|
||||
if (target == 'ios')
|
||||
'--no-codesign',
|
||||
if (configOnly)
|
||||
'--config-only',
|
||||
if (localEngine != null)
|
||||
final String buildOutput = await evalFlutter(
|
||||
'build',
|
||||
options: <String>[
|
||||
target,
|
||||
'-v',
|
||||
if (target == 'ios') '--no-codesign',
|
||||
if (configOnly) '--config-only',
|
||||
if (localEngine != null)
|
||||
// The engine directory is of the form <fake-source-path>/out/<fakename>,
|
||||
// which has to be broken up into the component flags.
|
||||
...<String>[
|
||||
'--local-engine-src-path=${localEngine.parent.parent.path}',
|
||||
'--local-engine=${path.basename(localEngine.path)}',
|
||||
'--local-engine-host=${path.basename(localEngine.path)}',
|
||||
]
|
||||
]);
|
||||
],
|
||||
],
|
||||
);
|
||||
|
||||
if (target == 'ios' || target == 'macos') {
|
||||
// This warning is confusing and shouldn't be emitted. Plugins often support lower versions than the
|
||||
@@ -512,25 +537,33 @@ s.dependency 'AppAuth', '1.6.0'
|
||||
// but the range of supported deployment target versions is 9.0 to 14.0.99.
|
||||
//
|
||||
// (or "The macOS deployment target 'MACOSX_DEPLOYMENT_TARGET'"...)
|
||||
if (buildOutput.contains('is set to 10.0, but the range of supported deployment target versions') ||
|
||||
buildOutput.contains('is set to 10.8, but the range of supported deployment target versions')) {
|
||||
if (buildOutput.contains(
|
||||
'is set to 10.0, but the range of supported deployment target versions',
|
||||
) ||
|
||||
buildOutput.contains(
|
||||
'is set to 10.8, but the range of supported deployment target versions',
|
||||
)) {
|
||||
throw TaskResult.failure('Minimum plugin version warning present');
|
||||
}
|
||||
|
||||
if (validateNativeBuildProject) {
|
||||
final File generatedSwiftManifest = File(path.join(
|
||||
rootPath,
|
||||
target,
|
||||
'Flutter',
|
||||
'ephemeral',
|
||||
'Packages',
|
||||
'FlutterGeneratedPluginSwiftPackage',
|
||||
'Package.swift'
|
||||
));
|
||||
final File generatedSwiftManifest = File(
|
||||
path.join(
|
||||
rootPath,
|
||||
target,
|
||||
'Flutter',
|
||||
'ephemeral',
|
||||
'Packages',
|
||||
'FlutterGeneratedPluginSwiftPackage',
|
||||
'Package.swift',
|
||||
),
|
||||
);
|
||||
final bool swiftPackageManagerEnabled = generatedSwiftManifest.existsSync();
|
||||
|
||||
if (!swiftPackageManagerEnabled) {
|
||||
final File podsProject = File(path.join(rootPath, target, 'Pods', 'Pods.xcodeproj', 'project.pbxproj'));
|
||||
final File podsProject = File(
|
||||
path.join(rootPath, target, 'Pods', 'Pods.xcodeproj', 'project.pbxproj'),
|
||||
);
|
||||
if (!podsProject.existsSync()) {
|
||||
throw TaskResult.failure('Xcode Pods project file missing at ${podsProject.path}');
|
||||
}
|
||||
@@ -541,31 +574,45 @@ s.dependency 'AppAuth', '1.6.0'
|
||||
// The plugintest plugin target should not have IPHONEOS_DEPLOYMENT_TARGET set since it has been lowered
|
||||
// in _reduceDarwinPluginMinimumVersion to 10, which is below the target version of 11.
|
||||
if (podsProjectContent.contains('IPHONEOS_DEPLOYMENT_TARGET = 10')) {
|
||||
throw TaskResult.failure('Plugin build setting IPHONEOS_DEPLOYMENT_TARGET not removed');
|
||||
throw TaskResult.failure(
|
||||
'Plugin build setting IPHONEOS_DEPLOYMENT_TARGET not removed',
|
||||
);
|
||||
}
|
||||
// Transitive dependency AppAuth targeting too-low 8.0 was not fixed.
|
||||
if (podsProjectContent.contains('IPHONEOS_DEPLOYMENT_TARGET = 8')) {
|
||||
throw TaskResult.failure('Transitive dependency build setting IPHONEOS_DEPLOYMENT_TARGET=8 not removed');
|
||||
throw TaskResult.failure(
|
||||
'Transitive dependency build setting IPHONEOS_DEPLOYMENT_TARGET=8 not removed',
|
||||
);
|
||||
}
|
||||
if (!podsProjectContent.contains(r'"EXCLUDED_ARCHS[sdk=iphonesimulator*]" = "$(inherited) i386";')) {
|
||||
if (!podsProjectContent.contains(
|
||||
r'"EXCLUDED_ARCHS[sdk=iphonesimulator*]" = "$(inherited) i386";',
|
||||
)) {
|
||||
throw TaskResult.failure(r'EXCLUDED_ARCHS is not "$(inherited) i386"');
|
||||
}
|
||||
} else if (target == 'macos') {
|
||||
// Same for macOS deployment target, but 10.8.
|
||||
// The plugintest target should not have MACOSX_DEPLOYMENT_TARGET set.
|
||||
if (podsProjectContent.contains('MACOSX_DEPLOYMENT_TARGET = 10.8')) {
|
||||
throw TaskResult.failure('Plugin build setting MACOSX_DEPLOYMENT_TARGET not removed');
|
||||
throw TaskResult.failure(
|
||||
'Plugin build setting MACOSX_DEPLOYMENT_TARGET not removed',
|
||||
);
|
||||
}
|
||||
// Transitive dependency AppAuth targeting too-low 10.9 was not fixed.
|
||||
if (podsProjectContent.contains('MACOSX_DEPLOYMENT_TARGET = 10.9')) {
|
||||
throw TaskResult.failure('Transitive dependency build setting MACOSX_DEPLOYMENT_TARGET=10.9 not removed');
|
||||
throw TaskResult.failure(
|
||||
'Transitive dependency build setting MACOSX_DEPLOYMENT_TARGET=10.9 not removed',
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
if (localEngine != null) {
|
||||
final RegExp localEngineSearchPath = RegExp('FRAMEWORK_SEARCH_PATHS\\s*=[^;]*${localEngine.path}');
|
||||
final RegExp localEngineSearchPath = RegExp(
|
||||
'FRAMEWORK_SEARCH_PATHS\\s*=[^;]*${localEngine.path}',
|
||||
);
|
||||
if (!localEngineSearchPath.hasMatch(podsProjectContent)) {
|
||||
throw TaskResult.failure('FRAMEWORK_SEARCH_PATHS does not contain the --local-engine path');
|
||||
throw TaskResult.failure(
|
||||
'FRAMEWORK_SEARCH_PATHS does not contain the --local-engine path',
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -578,8 +625,7 @@ s.dependency 'AppAuth', '1.6.0'
|
||||
if (Platform.isWindows) {
|
||||
// A running Gradle daemon might prevent us from deleting the project
|
||||
// folder on Windows.
|
||||
final String wrapperPath =
|
||||
path.absolute(path.join(rootPath, 'android', 'gradlew.bat'));
|
||||
final String wrapperPath = path.absolute(path.join(rootPath, 'android', 'gradlew.bat'));
|
||||
if (File(wrapperPath).existsSync()) {
|
||||
await exec(wrapperPath, <String>['--stop'], canFail: true);
|
||||
}
|
||||
|
||||
@@ -71,10 +71,8 @@ TaskFunction createWindowsRunReleaseTest() {
|
||||
}
|
||||
|
||||
class AndroidRunOutputTest extends RunOutputTask {
|
||||
AndroidRunOutputTest({required super.release}) : super(
|
||||
'${flutterDirectory.path}/dev/integration_tests/ui',
|
||||
'lib/main.dart',
|
||||
);
|
||||
AndroidRunOutputTest({required super.release})
|
||||
: super('${flutterDirectory.path}/dev/integration_tests/ui', 'lib/main.dart');
|
||||
|
||||
@override
|
||||
Future<void> prepare(String deviceId) async {
|
||||
@@ -85,22 +83,20 @@ class AndroidRunOutputTest extends RunOutputTask {
|
||||
'install',
|
||||
// TODO(andrewkolos): consider removing -v after
|
||||
// https://github.com/flutter/flutter/issues/153367 is troubleshot.
|
||||
options: <String>['--suppress-analytics', '--uninstall-only', '-d', deviceId, '-v'],
|
||||
options: <String>['--suppress-analytics', '--uninstall-only', '-d', deviceId, '-v'],
|
||||
isBot: false,
|
||||
);
|
||||
uninstall.stdout
|
||||
.transform<String>(utf8.decoder)
|
||||
.transform<String>(const LineSplitter())
|
||||
.listen((String line) {
|
||||
uninstall.stdout.transform<String>(utf8.decoder).transform<String>(const LineSplitter()).listen(
|
||||
(String line) {
|
||||
print('uninstall:stdout: $line');
|
||||
});
|
||||
uninstall.stderr
|
||||
.transform<String>(utf8.decoder)
|
||||
.transform<String>(const LineSplitter())
|
||||
.listen((String line) {
|
||||
},
|
||||
);
|
||||
uninstall.stderr.transform<String>(utf8.decoder).transform<String>(const LineSplitter()).listen(
|
||||
(String line) {
|
||||
print('uninstall:stderr: $line');
|
||||
stderr.add(line);
|
||||
});
|
||||
},
|
||||
);
|
||||
if (await uninstall.exitCode != 0) {
|
||||
throw 'flutter install --uninstall-only failed.';
|
||||
}
|
||||
@@ -122,8 +118,9 @@ class AndroidRunOutputTest extends RunOutputTask {
|
||||
|
||||
_findNextMatcherInList(
|
||||
stdout,
|
||||
(String line) => line.startsWith('Launching lib/main.dart on ') &&
|
||||
line.endsWith(' in ${release ? 'release' : 'debug'} mode...'),
|
||||
(String line) =>
|
||||
line.startsWith('Launching lib/main.dart on ') &&
|
||||
line.endsWith(' in ${release ? 'release' : 'debug'} mode...'),
|
||||
'Launching lib/main.dart on',
|
||||
);
|
||||
|
||||
@@ -136,8 +133,9 @@ class AndroidRunOutputTest extends RunOutputTask {
|
||||
// Size information is only included in release builds.
|
||||
_findNextMatcherInList(
|
||||
stdout,
|
||||
(String line) => line.contains('Built build/app/outputs/flutter-apk/$apk') &&
|
||||
(!release || line.contains('MB)')),
|
||||
(String line) =>
|
||||
line.contains('Built build/app/outputs/flutter-apk/$apk') &&
|
||||
(!release || line.contains('MB)')),
|
||||
'Built build/app/outputs/flutter-apk/$apk',
|
||||
);
|
||||
|
||||
@@ -167,12 +165,11 @@ class WindowsRunOutputTest extends DesktopRunOutputTest {
|
||||
WindowsRunOutputTest(
|
||||
super.testDirectory,
|
||||
super.testTarget, {
|
||||
required super.release,
|
||||
super.allowStderr = false,
|
||||
}
|
||||
);
|
||||
required super.release,
|
||||
super.allowStderr = false,
|
||||
});
|
||||
|
||||
final String arch = Abi.current() == Abi.windowsX64 ? 'x64': 'arm64';
|
||||
final String arch = Abi.current() == Abi.windowsX64 ? 'x64' : 'arm64';
|
||||
|
||||
static final RegExp _buildOutput = RegExp(
|
||||
r'Building Windows application\.\.\.\s*\d+(\.\d+)?(ms|s)',
|
||||
@@ -184,24 +181,16 @@ class WindowsRunOutputTest extends DesktopRunOutputTest {
|
||||
|
||||
@override
|
||||
void verifyBuildOutput(List<String> stdout) {
|
||||
_findNextMatcherInList(
|
||||
stdout,
|
||||
_buildOutput.hasMatch,
|
||||
'Building Windows application...',
|
||||
);
|
||||
_findNextMatcherInList(stdout, _buildOutput.hasMatch, 'Building Windows application...');
|
||||
|
||||
final String buildMode = release ? 'Release' : 'Debug';
|
||||
_findNextMatcherInList(
|
||||
stdout,
|
||||
(String line) {
|
||||
if (!_builtOutput.hasMatch(line) || !line.contains(buildMode)) {
|
||||
return false;
|
||||
}
|
||||
_findNextMatcherInList(stdout, (String line) {
|
||||
if (!_builtOutput.hasMatch(line) || !line.contains(buildMode)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
},
|
||||
'√ Built build\\windows\\$arch\\runner\\$buildMode\\ui.exe',
|
||||
);
|
||||
return true;
|
||||
}, '√ Built build\\windows\\$arch\\runner\\$buildMode\\ui.exe');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -209,10 +198,9 @@ class DesktopRunOutputTest extends RunOutputTask {
|
||||
DesktopRunOutputTest(
|
||||
super.testDirectory,
|
||||
super.testTarget, {
|
||||
required super.release,
|
||||
this.allowStderr = false,
|
||||
}
|
||||
);
|
||||
required super.release,
|
||||
this.allowStderr = false,
|
||||
});
|
||||
|
||||
/// Whether `flutter run` is expected to produce output on stderr.
|
||||
final bool allowStderr;
|
||||
@@ -224,8 +212,9 @@ class DesktopRunOutputTest extends RunOutputTask {
|
||||
TaskResult verify(List<String> stdout, List<String> stderr) {
|
||||
_findNextMatcherInList(
|
||||
stdout,
|
||||
(String line) => line.startsWith('Launching $testTarget on ') &&
|
||||
line.endsWith(' in ${release ? 'release' : 'debug'} mode...'),
|
||||
(String line) =>
|
||||
line.startsWith('Launching $testTarget on ') &&
|
||||
line.endsWith(' in ${release ? 'release' : 'debug'} mode...'),
|
||||
'Launching $testTarget on',
|
||||
);
|
||||
|
||||
@@ -252,21 +241,16 @@ class DesktopRunOutputTest extends RunOutputTask {
|
||||
|
||||
/// Test that the output of `flutter run` is expected.
|
||||
abstract class RunOutputTask {
|
||||
RunOutputTask(
|
||||
this.testDirectory,
|
||||
this.testTarget, {
|
||||
required this.release,
|
||||
}
|
||||
);
|
||||
RunOutputTask(this.testDirectory, this.testTarget, {required this.release});
|
||||
|
||||
static final RegExp _engineLogRegex = RegExp(
|
||||
r'\[(VERBOSE|INFO|WARNING|ERROR|FATAL):.+\(\d+\)\]',
|
||||
);
|
||||
static final RegExp _engineLogRegex = RegExp(r'\[(VERBOSE|INFO|WARNING|ERROR|FATAL):.+\(\d+\)\]');
|
||||
|
||||
/// The directory where the app under test is defined.
|
||||
final String testDirectory;
|
||||
|
||||
/// The main entry-point file of the application, as run on the device.
|
||||
final String testTarget;
|
||||
|
||||
/// Whether to run the app in release mode.
|
||||
final bool release;
|
||||
|
||||
@@ -282,40 +266,33 @@ abstract class RunOutputTask {
|
||||
|
||||
await prepare(deviceId);
|
||||
|
||||
final List<String> options = <String>[
|
||||
testTarget,
|
||||
'-d',
|
||||
deviceId,
|
||||
if (release) '--release',
|
||||
];
|
||||
final List<String> options = <String>[testTarget, '-d', deviceId, if (release) '--release'];
|
||||
|
||||
final Process run = await startFlutter(
|
||||
'run',
|
||||
options: options,
|
||||
isBot: false,
|
||||
);
|
||||
final Process run = await startFlutter('run', options: options, isBot: false);
|
||||
|
||||
int? runExitCode;
|
||||
run.stdout
|
||||
.transform<String>(utf8.decoder)
|
||||
.transform<String>(const LineSplitter())
|
||||
.listen((String line) {
|
||||
print('run:stdout: $line');
|
||||
stdout.add(line);
|
||||
if (line.contains('Quit (terminate the application on the device).')) {
|
||||
ready.complete();
|
||||
}
|
||||
});
|
||||
final Stream<String> runStderr = run.stderr
|
||||
.transform<String>(utf8.decoder)
|
||||
.transform<String>(const LineSplitter())
|
||||
.asBroadcastStream();
|
||||
run.stdout.transform<String>(utf8.decoder).transform<String>(const LineSplitter()).listen((
|
||||
String line,
|
||||
) {
|
||||
print('run:stdout: $line');
|
||||
stdout.add(line);
|
||||
if (line.contains('Quit (terminate the application on the device).')) {
|
||||
ready.complete();
|
||||
}
|
||||
});
|
||||
final Stream<String> runStderr =
|
||||
run.stderr
|
||||
.transform<String>(utf8.decoder)
|
||||
.transform<String>(const LineSplitter())
|
||||
.asBroadcastStream();
|
||||
runStderr.listen((String line) => print('run:stderr: $line'));
|
||||
runStderr
|
||||
.skipWhile(isExpectedStderr)
|
||||
.listen((String line) => stderr.add(line));
|
||||
unawaited(run.exitCode.then<void>((int exitCode) { runExitCode = exitCode; }));
|
||||
await Future.any<dynamic>(<Future<dynamic>>[ ready.future, run.exitCode ]);
|
||||
runStderr.skipWhile(isExpectedStderr).listen((String line) => stderr.add(line));
|
||||
unawaited(
|
||||
run.exitCode.then<void>((int exitCode) {
|
||||
runExitCode = exitCode;
|
||||
}),
|
||||
);
|
||||
await Future.any<dynamic>(<Future<dynamic>>[ready.future, run.exitCode]);
|
||||
if (runExitCode != null) {
|
||||
throw 'Failed to run test app; runner unexpected exited, with exit code $runExitCode.';
|
||||
}
|
||||
@@ -327,9 +304,7 @@ abstract class RunOutputTask {
|
||||
throw 'flutter run ${release ? '--release' : ''} had unexpected output on standard error.';
|
||||
}
|
||||
|
||||
final List<String> engineLogs = List<String>.from(
|
||||
stdout.where(_engineLogRegex.hasMatch),
|
||||
);
|
||||
final List<String> engineLogs = List<String>.from(stdout.where(_engineLogRegex.hasMatch));
|
||||
if (engineLogs.isNotEmpty) {
|
||||
throw 'flutter run had unexpected Flutter engine logs $engineLogs';
|
||||
}
|
||||
@@ -345,14 +320,15 @@ abstract class RunOutputTask {
|
||||
bool isExpectedStderr(String line) => false;
|
||||
|
||||
/// Verify the output of `flutter run`.
|
||||
TaskResult verify(List<String> stdout, List<String> stderr) => throw UnimplementedError('verify is not implemented');
|
||||
TaskResult verify(List<String> stdout, List<String> stderr) =>
|
||||
throw UnimplementedError('verify is not implemented');
|
||||
|
||||
/// Helper that verifies a line in [list] matches [matcher].
|
||||
/// The [list] is updated to contain the lines remaining after the match.
|
||||
void _findNextMatcherInList(
|
||||
List<String> list,
|
||||
bool Function(String testLine) matcher,
|
||||
String errorMessageExpectedLine
|
||||
String errorMessageExpectedLine,
|
||||
) {
|
||||
final List<String> copyOfListForErrorMessage = List<String>.from(list);
|
||||
|
||||
|
||||
@@ -20,32 +20,34 @@ import '../framework/utils.dart';
|
||||
const int benchmarkServerPort = 9999;
|
||||
const int chromeDebugPort = 10000;
|
||||
|
||||
typedef WebBenchmarkOptions = ({
|
||||
bool useWasm,
|
||||
bool forceSingleThreadedSkwasm,
|
||||
});
|
||||
typedef WebBenchmarkOptions = ({bool useWasm, bool forceSingleThreadedSkwasm});
|
||||
|
||||
Future<TaskResult> runWebBenchmark(WebBenchmarkOptions benchmarkOptions) async {
|
||||
// Reduce logging level. Otherwise, package:webkit_inspection_protocol is way too spammy.
|
||||
Logger.root.level = Level.INFO;
|
||||
final String macrobenchmarksDirectory = path.join(flutterDirectory.path, 'dev', 'benchmarks', 'macrobenchmarks');
|
||||
final String macrobenchmarksDirectory = path.join(
|
||||
flutterDirectory.path,
|
||||
'dev',
|
||||
'benchmarks',
|
||||
'macrobenchmarks',
|
||||
);
|
||||
return inDirectory(macrobenchmarksDirectory, () async {
|
||||
await flutter('clean');
|
||||
await evalFlutter('build', options: <String>[
|
||||
'web',
|
||||
'--no-tree-shake-icons', // local engine builds are frequently out of sync with the Dart Kernel version
|
||||
if (benchmarkOptions.useWasm) ...<String>[
|
||||
'-O4',
|
||||
'--wasm',
|
||||
'--no-strip-wasm',
|
||||
await evalFlutter(
|
||||
'build',
|
||||
options: <String>[
|
||||
'web',
|
||||
'--no-tree-shake-icons', // local engine builds are frequently out of sync with the Dart Kernel version
|
||||
if (benchmarkOptions.useWasm) ...<String>['-O4', '--wasm', '--no-strip-wasm'],
|
||||
'--dart-define=FLUTTER_WEB_ENABLE_PROFILING=true',
|
||||
'--profile',
|
||||
'--no-web-resources-cdn',
|
||||
'-t',
|
||||
'lib/web_benchmarks.dart',
|
||||
],
|
||||
'--dart-define=FLUTTER_WEB_ENABLE_PROFILING=true',
|
||||
'--profile',
|
||||
'--no-web-resources-cdn',
|
||||
'-t',
|
||||
'lib/web_benchmarks.dart',
|
||||
]);
|
||||
final Completer<List<Map<String, dynamic>>> profileData = Completer<List<Map<String, dynamic>>>();
|
||||
);
|
||||
final Completer<List<Map<String, dynamic>>> profileData =
|
||||
Completer<List<Map<String, dynamic>>>();
|
||||
final List<Map<String, dynamic>> collectedProfiles = <Map<String, dynamic>>[];
|
||||
List<String>? benchmarks;
|
||||
late Iterator<String> benchmarkIterator;
|
||||
@@ -58,82 +60,91 @@ Future<TaskResult> runWebBenchmark(WebBenchmarkOptions benchmarkOptions) async {
|
||||
late io.HttpServer server;
|
||||
Cascade cascade = Cascade();
|
||||
List<Map<String, dynamic>>? latestPerformanceTrace;
|
||||
cascade = cascade.add((Request request) async {
|
||||
try {
|
||||
chrome ??= await whenChromeIsReady;
|
||||
if (request.requestedUri.path.endsWith('/profile-data')) {
|
||||
final Map<String, dynamic> profile = json.decode(await request.readAsString()) as Map<String, dynamic>;
|
||||
final String benchmarkName = profile['name'] as String;
|
||||
if (benchmarkName != benchmarkIterator.current) {
|
||||
profileData.completeError(Exception(
|
||||
'Browser returned benchmark results from a wrong benchmark.\n'
|
||||
'Requested to run benchmark ${benchmarkIterator.current}, but '
|
||||
'got results for $benchmarkName.',
|
||||
));
|
||||
unawaited(server.close());
|
||||
}
|
||||
cascade = cascade
|
||||
.add((Request request) async {
|
||||
try {
|
||||
chrome ??= await whenChromeIsReady;
|
||||
if (request.requestedUri.path.endsWith('/profile-data')) {
|
||||
final Map<String, dynamic> profile =
|
||||
json.decode(await request.readAsString()) as Map<String, dynamic>;
|
||||
final String benchmarkName = profile['name'] as String;
|
||||
if (benchmarkName != benchmarkIterator.current) {
|
||||
profileData.completeError(
|
||||
Exception(
|
||||
'Browser returned benchmark results from a wrong benchmark.\n'
|
||||
'Requested to run benchmark ${benchmarkIterator.current}, but '
|
||||
'got results for $benchmarkName.',
|
||||
),
|
||||
);
|
||||
unawaited(server.close());
|
||||
}
|
||||
|
||||
// Trace data is null when the benchmark is not frame-based, such as RawRecorder.
|
||||
if (latestPerformanceTrace != null) {
|
||||
final BlinkTraceSummary traceSummary = BlinkTraceSummary.fromJson(latestPerformanceTrace!)!;
|
||||
profile['totalUiFrame.average'] = traceSummary.averageTotalUIFrameTime.inMicroseconds;
|
||||
profile['scoreKeys'] ??= <dynamic>[]; // using dynamic for consistency with JSON
|
||||
(profile['scoreKeys'] as List<dynamic>).add('totalUiFrame.average');
|
||||
latestPerformanceTrace = null;
|
||||
// Trace data is null when the benchmark is not frame-based, such as RawRecorder.
|
||||
if (latestPerformanceTrace != null) {
|
||||
final BlinkTraceSummary traceSummary =
|
||||
BlinkTraceSummary.fromJson(latestPerformanceTrace!)!;
|
||||
profile['totalUiFrame.average'] =
|
||||
traceSummary.averageTotalUIFrameTime.inMicroseconds;
|
||||
profile['scoreKeys'] ??= <dynamic>[]; // using dynamic for consistency with JSON
|
||||
(profile['scoreKeys'] as List<dynamic>).add('totalUiFrame.average');
|
||||
latestPerformanceTrace = null;
|
||||
}
|
||||
collectedProfiles.add(profile);
|
||||
return Response.ok('Profile received');
|
||||
} else if (request.requestedUri.path.endsWith('/start-performance-tracing')) {
|
||||
latestPerformanceTrace = null;
|
||||
await chrome!.beginRecordingPerformance(
|
||||
request.requestedUri.queryParameters['label']!,
|
||||
);
|
||||
return Response.ok('Started performance tracing');
|
||||
} else if (request.requestedUri.path.endsWith('/stop-performance-tracing')) {
|
||||
latestPerformanceTrace = await chrome!.endRecordingPerformance();
|
||||
return Response.ok('Stopped performance tracing');
|
||||
} else if (request.requestedUri.path.endsWith('/on-error')) {
|
||||
final Map<String, dynamic> errorDetails =
|
||||
json.decode(await request.readAsString()) as Map<String, dynamic>;
|
||||
unawaited(server.close());
|
||||
// Keep the stack trace as a string. It's thrown in the browser, not this Dart VM.
|
||||
profileData.completeError('${errorDetails['error']}\n${errorDetails['stackTrace']}');
|
||||
return Response.ok('');
|
||||
} else if (request.requestedUri.path.endsWith('/next-benchmark')) {
|
||||
if (benchmarks == null) {
|
||||
benchmarks =
|
||||
(json.decode(await request.readAsString()) as List<dynamic>).cast<String>();
|
||||
benchmarkIterator = benchmarks!.iterator;
|
||||
}
|
||||
if (benchmarkIterator.moveNext()) {
|
||||
final String nextBenchmark = benchmarkIterator.current;
|
||||
print('Launching benchmark "$nextBenchmark"');
|
||||
return Response.ok(nextBenchmark);
|
||||
} else {
|
||||
profileData.complete(collectedProfiles);
|
||||
return Response.notFound('Finished running benchmarks.');
|
||||
}
|
||||
} else if (request.requestedUri.path.endsWith('/print-to-console')) {
|
||||
// A passthrough used by
|
||||
// `dev/benchmarks/macrobenchmarks/lib/web_benchmarks.dart`
|
||||
// to print information.
|
||||
final String message = await request.readAsString();
|
||||
print('[APP] $message');
|
||||
return Response.ok('Reported.');
|
||||
} else {
|
||||
return Response.notFound('This request is not handled by the profile-data handler.');
|
||||
}
|
||||
} catch (error, stackTrace) {
|
||||
profileData.completeError(error, stackTrace);
|
||||
return Response.internalServerError(body: '$error');
|
||||
}
|
||||
collectedProfiles.add(profile);
|
||||
return Response.ok('Profile received');
|
||||
} else if (request.requestedUri.path.endsWith('/start-performance-tracing')) {
|
||||
latestPerformanceTrace = null;
|
||||
await chrome!.beginRecordingPerformance(request.requestedUri.queryParameters['label']!);
|
||||
return Response.ok('Started performance tracing');
|
||||
} else if (request.requestedUri.path.endsWith('/stop-performance-tracing')) {
|
||||
latestPerformanceTrace = await chrome!.endRecordingPerformance();
|
||||
return Response.ok('Stopped performance tracing');
|
||||
} else if (request.requestedUri.path.endsWith('/on-error')) {
|
||||
final Map<String, dynamic> errorDetails = json.decode(await request.readAsString()) as Map<String, dynamic>;
|
||||
unawaited(server.close());
|
||||
// Keep the stack trace as a string. It's thrown in the browser, not this Dart VM.
|
||||
profileData.completeError('${errorDetails['error']}\n${errorDetails['stackTrace']}');
|
||||
return Response.ok('');
|
||||
} else if (request.requestedUri.path.endsWith('/next-benchmark')) {
|
||||
if (benchmarks == null) {
|
||||
benchmarks = (json.decode(await request.readAsString()) as List<dynamic>).cast<String>();
|
||||
benchmarkIterator = benchmarks!.iterator;
|
||||
}
|
||||
if (benchmarkIterator.moveNext()) {
|
||||
final String nextBenchmark = benchmarkIterator.current;
|
||||
print('Launching benchmark "$nextBenchmark"');
|
||||
return Response.ok(nextBenchmark);
|
||||
} else {
|
||||
profileData.complete(collectedProfiles);
|
||||
return Response.notFound('Finished running benchmarks.');
|
||||
}
|
||||
} else if (request.requestedUri.path.endsWith('/print-to-console')) {
|
||||
// A passthrough used by
|
||||
// `dev/benchmarks/macrobenchmarks/lib/web_benchmarks.dart`
|
||||
// to print information.
|
||||
final String message = await request.readAsString();
|
||||
print('[APP] $message');
|
||||
return Response.ok('Reported.');
|
||||
} else {
|
||||
return Response.notFound(
|
||||
'This request is not handled by the profile-data handler.');
|
||||
}
|
||||
} catch (error, stackTrace) {
|
||||
profileData.completeError(error, stackTrace);
|
||||
return Response.internalServerError(body: '$error');
|
||||
}
|
||||
}).add(createBuildDirectoryHandler(
|
||||
path.join(macrobenchmarksDirectory, 'build', 'web'),
|
||||
));
|
||||
})
|
||||
.add(createBuildDirectoryHandler(path.join(macrobenchmarksDirectory, 'build', 'web')));
|
||||
|
||||
server = await io.HttpServer.bind('localhost', benchmarkServerPort);
|
||||
try {
|
||||
shelf_io.serveRequests(server, cascade.handler);
|
||||
|
||||
final String dartToolDirectory = path.join('$macrobenchmarksDirectory/.dart_tool');
|
||||
final String userDataDir = io.Directory(dartToolDirectory).createTempSync('flutter_chrome_user_data.').path;
|
||||
final String userDataDir =
|
||||
io.Directory(dartToolDirectory).createTempSync('flutter_chrome_user_data.').path;
|
||||
|
||||
// TODO(yjbanov): temporarily disables headful Chrome until we get
|
||||
// devicelab hardware that is able to run it. Our current
|
||||
@@ -216,10 +227,12 @@ Handler createBuildDirectoryHandler(String buildDirectoryPath) {
|
||||
// crossOriginIsolated. This will make sure that we get high-resolution
|
||||
// timers for our benchmark measurements.
|
||||
if (mimeType == 'text/html' || mimeType == 'text/javascript') {
|
||||
return response.change(headers: <String, String>{
|
||||
'Cross-Origin-Opener-Policy': 'same-origin',
|
||||
'Cross-Origin-Embedder-Policy': 'require-corp',
|
||||
});
|
||||
return response.change(
|
||||
headers: <String, String>{
|
||||
'Cross-Origin-Opener-Policy': 'same-origin',
|
||||
'Cross-Origin-Embedder-Policy': 'require-corp',
|
||||
},
|
||||
);
|
||||
} else {
|
||||
return response;
|
||||
}
|
||||
|
||||
@@ -12,12 +12,16 @@ import '../framework/framework.dart';
|
||||
import '../framework/task_result.dart';
|
||||
import '../framework/utils.dart';
|
||||
|
||||
final Directory _editedFlutterGalleryDir = dir(path.join(Directory.systemTemp.path, 'edited_flutter_gallery'));
|
||||
final Directory flutterGalleryDir = dir(path.join(flutterDirectory.path, 'dev/integration_tests/flutter_gallery'));
|
||||
final Directory _editedFlutterGalleryDir = dir(
|
||||
path.join(Directory.systemTemp.path, 'edited_flutter_gallery'),
|
||||
);
|
||||
final Directory flutterGalleryDir = dir(
|
||||
path.join(flutterDirectory.path, 'dev/integration_tests/flutter_gallery'),
|
||||
);
|
||||
|
||||
const String kInitialStartupTime = 'InitialStartupTime';
|
||||
const String kFirstRestartTime = 'FistRestartTime';
|
||||
const String kFirstRecompileTime = 'FirstRecompileTime';
|
||||
const String kFirstRecompileTime = 'FirstRecompileTime';
|
||||
const String kSecondStartupTime = 'SecondStartupTime';
|
||||
const String kSecondRestartTime = 'SecondRestartTime';
|
||||
|
||||
@@ -29,12 +33,16 @@ abstract class WebDevice {
|
||||
TaskFunction createWebDevModeTest(String webDevice, bool enableIncrementalCompiler) {
|
||||
return () async {
|
||||
final List<String> options = <String>[
|
||||
'--hot', '-d', webDevice, '--verbose', '--resident', '--target=lib/main.dart',
|
||||
'--hot',
|
||||
'-d',
|
||||
webDevice,
|
||||
'--verbose',
|
||||
'--resident',
|
||||
'--target=lib/main.dart',
|
||||
];
|
||||
int hotRestartCount = 0;
|
||||
final String expectedMessage = webDevice == WebDevice.webServer
|
||||
? 'Recompile complete'
|
||||
: 'Reloaded application';
|
||||
final String expectedMessage =
|
||||
webDevice == WebDevice.webServer ? 'Recompile complete' : 'Reloaded application';
|
||||
final Map<String, int> measurements = <String, int>{};
|
||||
await inDirectory<void>(flutterDirectory, () async {
|
||||
rmTree(_editedFlutterGalleryDir);
|
||||
@@ -42,14 +50,8 @@ TaskFunction createWebDevModeTest(String webDevice, bool enableIncrementalCompil
|
||||
recursiveCopy(flutterGalleryDir, _editedFlutterGalleryDir);
|
||||
await inDirectory<void>(_editedFlutterGalleryDir, () async {
|
||||
{
|
||||
await flutter(
|
||||
'packages',
|
||||
options: <String>['get'],
|
||||
);
|
||||
final Process process = await startFlutter(
|
||||
'run',
|
||||
options: options,
|
||||
);
|
||||
await flutter('packages', options: <String>['get']);
|
||||
final Process process = await startFlutter('run', options: options);
|
||||
|
||||
final Completer<void> stdoutDone = Completer<void>();
|
||||
final Completer<void> stderrDone = Completer<void>();
|
||||
@@ -58,124 +60,126 @@ TaskFunction createWebDevModeTest(String webDevice, bool enableIncrementalCompil
|
||||
process.stdout
|
||||
.transform<String>(utf8.decoder)
|
||||
.transform<String>(const LineSplitter())
|
||||
.listen((String line) {
|
||||
// non-dwds builds do not know when the browser is loaded so keep trying
|
||||
// until this succeeds.
|
||||
if (line.contains('Ignoring terminal input')) {
|
||||
Future<void>.delayed(const Duration(seconds: 1)).then((void _) {
|
||||
process.stdin.write(restarted ? 'q' : 'r');
|
||||
});
|
||||
return;
|
||||
}
|
||||
if (line.contains('To hot restart')) {
|
||||
// measure clean start-up time.
|
||||
sw.stop();
|
||||
measurements[kInitialStartupTime] = sw.elapsedMilliseconds;
|
||||
sw
|
||||
..reset()
|
||||
..start();
|
||||
process.stdin.write('r');
|
||||
return;
|
||||
}
|
||||
if (line.contains(expectedMessage)) {
|
||||
if (hotRestartCount == 0) {
|
||||
measurements[kFirstRestartTime] = sw.elapsedMilliseconds;
|
||||
// Update the file and reload again.
|
||||
final File appDartSource = file(path.join(
|
||||
_editedFlutterGalleryDir.path, 'lib/gallery/app.dart',
|
||||
));
|
||||
appDartSource.writeAsStringSync(
|
||||
appDartSource.readAsStringSync().replaceFirst(
|
||||
"'Flutter Gallery'", "'Updated Flutter Gallery'",
|
||||
)
|
||||
);
|
||||
sw
|
||||
..reset()
|
||||
..start();
|
||||
process.stdin.writeln('r');
|
||||
++hotRestartCount;
|
||||
} else {
|
||||
restarted = true;
|
||||
measurements[kFirstRecompileTime] = sw.elapsedMilliseconds;
|
||||
// Quit after second hot restart.
|
||||
process.stdin.writeln('q');
|
||||
}
|
||||
}
|
||||
print('stdout: $line');
|
||||
}, onDone: () {
|
||||
stdoutDone.complete();
|
||||
});
|
||||
.listen(
|
||||
(String line) {
|
||||
// non-dwds builds do not know when the browser is loaded so keep trying
|
||||
// until this succeeds.
|
||||
if (line.contains('Ignoring terminal input')) {
|
||||
Future<void>.delayed(const Duration(seconds: 1)).then((void _) {
|
||||
process.stdin.write(restarted ? 'q' : 'r');
|
||||
});
|
||||
return;
|
||||
}
|
||||
if (line.contains('To hot restart')) {
|
||||
// measure clean start-up time.
|
||||
sw.stop();
|
||||
measurements[kInitialStartupTime] = sw.elapsedMilliseconds;
|
||||
sw
|
||||
..reset()
|
||||
..start();
|
||||
process.stdin.write('r');
|
||||
return;
|
||||
}
|
||||
if (line.contains(expectedMessage)) {
|
||||
if (hotRestartCount == 0) {
|
||||
measurements[kFirstRestartTime] = sw.elapsedMilliseconds;
|
||||
// Update the file and reload again.
|
||||
final File appDartSource = file(
|
||||
path.join(_editedFlutterGalleryDir.path, 'lib/gallery/app.dart'),
|
||||
);
|
||||
appDartSource.writeAsStringSync(
|
||||
appDartSource.readAsStringSync().replaceFirst(
|
||||
"'Flutter Gallery'",
|
||||
"'Updated Flutter Gallery'",
|
||||
),
|
||||
);
|
||||
sw
|
||||
..reset()
|
||||
..start();
|
||||
process.stdin.writeln('r');
|
||||
++hotRestartCount;
|
||||
} else {
|
||||
restarted = true;
|
||||
measurements[kFirstRecompileTime] = sw.elapsedMilliseconds;
|
||||
// Quit after second hot restart.
|
||||
process.stdin.writeln('q');
|
||||
}
|
||||
}
|
||||
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();
|
||||
});
|
||||
.listen(
|
||||
(String line) {
|
||||
print('stderr: $line');
|
||||
},
|
||||
onDone: () {
|
||||
stderrDone.complete();
|
||||
},
|
||||
);
|
||||
|
||||
await Future.wait<void>(<Future<void>>[
|
||||
stdoutDone.future,
|
||||
stderrDone.future,
|
||||
]);
|
||||
await Future.wait<void>(<Future<void>>[stdoutDone.future, stderrDone.future]);
|
||||
await process.exitCode;
|
||||
|
||||
}
|
||||
|
||||
// Start `flutter run` again to make sure it loads from the previous
|
||||
// state. dev compilers loads up from previously compiled JavaScript.
|
||||
{
|
||||
|
||||
final Stopwatch sw = Stopwatch()..start();
|
||||
final Process process = await startFlutter(
|
||||
'run',
|
||||
options: options,
|
||||
);
|
||||
final Process process = await startFlutter('run', options: options);
|
||||
final Completer<void> stdoutDone = Completer<void>();
|
||||
final Completer<void> stderrDone = Completer<void>();
|
||||
bool restarted = false;
|
||||
process.stdout
|
||||
.transform<String>(utf8.decoder)
|
||||
.transform<String>(const LineSplitter())
|
||||
.listen((String line) {
|
||||
// non-dwds builds do not know when the browser is loaded so keep trying
|
||||
// until this succeeds.
|
||||
if (line.contains('Ignoring terminal input')) {
|
||||
Future<void>.delayed(const Duration(seconds: 1)).then((void _) {
|
||||
process.stdin.write(restarted ? 'q' : 'r');
|
||||
});
|
||||
return;
|
||||
}
|
||||
if (line.contains('To hot restart')) {
|
||||
measurements[kSecondStartupTime] = sw.elapsedMilliseconds;
|
||||
sw
|
||||
..reset()
|
||||
..start();
|
||||
process.stdin.write('r');
|
||||
return;
|
||||
}
|
||||
if (line.contains(expectedMessage)) {
|
||||
restarted = true;
|
||||
measurements[kSecondRestartTime] = sw.elapsedMilliseconds;
|
||||
process.stdin.writeln('q');
|
||||
}
|
||||
print('stdout: $line');
|
||||
}, onDone: () {
|
||||
stdoutDone.complete();
|
||||
});
|
||||
.listen(
|
||||
(String line) {
|
||||
// non-dwds builds do not know when the browser is loaded so keep trying
|
||||
// until this succeeds.
|
||||
if (line.contains('Ignoring terminal input')) {
|
||||
Future<void>.delayed(const Duration(seconds: 1)).then((void _) {
|
||||
process.stdin.write(restarted ? 'q' : 'r');
|
||||
});
|
||||
return;
|
||||
}
|
||||
if (line.contains('To hot restart')) {
|
||||
measurements[kSecondStartupTime] = sw.elapsedMilliseconds;
|
||||
sw
|
||||
..reset()
|
||||
..start();
|
||||
process.stdin.write('r');
|
||||
return;
|
||||
}
|
||||
if (line.contains(expectedMessage)) {
|
||||
restarted = true;
|
||||
measurements[kSecondRestartTime] = sw.elapsedMilliseconds;
|
||||
process.stdin.writeln('q');
|
||||
}
|
||||
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();
|
||||
});
|
||||
.listen(
|
||||
(String line) {
|
||||
print('stderr: $line');
|
||||
},
|
||||
onDone: () {
|
||||
stderrDone.complete();
|
||||
},
|
||||
);
|
||||
|
||||
await Future.wait<void>(<Future<void>>[
|
||||
stdoutDone.future,
|
||||
stderrDone.future,
|
||||
]);
|
||||
await Future.wait<void>(<Future<void>>[stdoutDone.future, stderrDone.future]);
|
||||
await process.exitCode;
|
||||
}
|
||||
});
|
||||
@@ -183,12 +187,15 @@ TaskFunction createWebDevModeTest(String webDevice, bool enableIncrementalCompil
|
||||
if (hotRestartCount != 1) {
|
||||
return TaskResult.failure(null);
|
||||
}
|
||||
return TaskResult.success(measurements, benchmarkScoreKeys: <String>[
|
||||
kInitialStartupTime,
|
||||
kFirstRestartTime,
|
||||
kFirstRecompileTime,
|
||||
kSecondStartupTime,
|
||||
kSecondRestartTime,
|
||||
]);
|
||||
return TaskResult.success(
|
||||
measurements,
|
||||
benchmarkScoreKeys: <String>[
|
||||
kInitialStartupTime,
|
||||
kFirstRestartTime,
|
||||
kFirstRecompileTime,
|
||||
kSecondStartupTime,
|
||||
kSecondRestartTime,
|
||||
],
|
||||
);
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user