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
@@ -12,11 +12,13 @@ import '../utils.dart';
|
||||
Future<void> addToAppLifeCycleRunner() async {
|
||||
if (Platform.isMacOS) {
|
||||
printProgress('${green}Running add-to-app life cycle iOS integration tests$reset...');
|
||||
final String addToAppDir = path.join(flutterRoot, 'dev', 'integration_tests', 'ios_add2app_life_cycle');
|
||||
await runCommand('./build_and_test.sh',
|
||||
<String>[],
|
||||
workingDirectory: addToAppDir,
|
||||
final String addToAppDir = path.join(
|
||||
flutterRoot,
|
||||
'dev',
|
||||
'integration_tests',
|
||||
'ios_add2app_life_cycle',
|
||||
);
|
||||
await runCommand('./build_and_test.sh', <String>[], workingDirectory: addToAppDir);
|
||||
} else {
|
||||
throw Exception('Only iOS has add-to-add lifecycle tests at this time.');
|
||||
}
|
||||
|
||||
@@ -9,12 +9,8 @@ import '../utils.dart';
|
||||
|
||||
Future<void> analyzeRunner() async {
|
||||
printProgress('${green}Running analysis testing$reset');
|
||||
await runCommand(
|
||||
'dart',
|
||||
<String>[
|
||||
'--enable-asserts',
|
||||
path.join(flutterRoot, 'dev', 'bots', 'analyze.dart'),
|
||||
],
|
||||
workingDirectory: flutterRoot,
|
||||
);
|
||||
await runCommand('dart', <String>[
|
||||
'--enable-asserts',
|
||||
path.join(flutterRoot, 'dev', 'bots', 'analyze.dart'),
|
||||
], workingDirectory: flutterRoot);
|
||||
}
|
||||
|
||||
@@ -25,10 +25,13 @@ import '../utils.dart';
|
||||
Future<void> androidJava11IntegrationToolTestsRunner() async {
|
||||
final String toolsPath = path.join(flutterRoot, 'packages', 'flutter_tools');
|
||||
|
||||
final List<String> allTests = Directory(path.join(toolsPath, 'test', 'android_java11_integration.shard'))
|
||||
.listSync(recursive: true).whereType<File>()
|
||||
.map<String>((FileSystemEntity entry) => path.relative(entry.path, from: toolsPath))
|
||||
.where((String testPath) => path.basename(testPath).endsWith('_test.dart')).toList();
|
||||
final List<String> allTests =
|
||||
Directory(path.join(toolsPath, 'test', 'android_java11_integration.shard'))
|
||||
.listSync(recursive: true)
|
||||
.whereType<File>()
|
||||
.map<String>((FileSystemEntity entry) => path.relative(entry.path, from: toolsPath))
|
||||
.where((String testPath) => path.basename(testPath).endsWith('_test.dart'))
|
||||
.toList();
|
||||
|
||||
await runDartTest(
|
||||
toolsPath,
|
||||
|
||||
@@ -11,10 +11,13 @@ import '../utils.dart';
|
||||
Future<void> androidPreviewIntegrationToolTestsRunner() async {
|
||||
final String toolsPath = path.join(flutterRoot, 'packages', 'flutter_tools');
|
||||
|
||||
final List<String> allTests = Directory(path.join(toolsPath, 'test', 'android_preview_integration.shard'))
|
||||
.listSync(recursive: true).whereType<File>()
|
||||
.map<String>((FileSystemEntity entry) => path.relative(entry.path, from: toolsPath))
|
||||
.where((String testPath) => path.basename(testPath).endsWith('_test.dart')).toList();
|
||||
final List<String> allTests =
|
||||
Directory(path.join(toolsPath, 'test', 'android_preview_integration.shard'))
|
||||
.listSync(recursive: true)
|
||||
.whereType<File>()
|
||||
.map<String>((FileSystemEntity entry) => path.relative(entry.path, from: toolsPath))
|
||||
.where((String testPath) => path.basename(testPath).endsWith('_test.dart'))
|
||||
.toList();
|
||||
|
||||
await runDartTest(
|
||||
toolsPath,
|
||||
|
||||
@@ -11,40 +11,25 @@ import '../utils.dart';
|
||||
|
||||
Future<void> customerTestingRunner() async {
|
||||
printProgress('${green}Running customer testing$reset');
|
||||
await runCommand(
|
||||
'git',
|
||||
const <String>[
|
||||
'fetch',
|
||||
'origin',
|
||||
'master',
|
||||
],
|
||||
workingDirectory: flutterRoot,
|
||||
);
|
||||
await runCommand(
|
||||
'git',
|
||||
const <String>[
|
||||
'branch',
|
||||
'-f',
|
||||
'master',
|
||||
'origin/master',
|
||||
],
|
||||
workingDirectory: flutterRoot,
|
||||
);
|
||||
await runCommand('git', const <String>[
|
||||
'fetch',
|
||||
'origin',
|
||||
'master',
|
||||
], workingDirectory: flutterRoot);
|
||||
await runCommand('git', const <String>[
|
||||
'branch',
|
||||
'-f',
|
||||
'master',
|
||||
'origin/master',
|
||||
], workingDirectory: flutterRoot);
|
||||
final Map<String, String> env = Platform.environment;
|
||||
final String? revision = env['REVISION'];
|
||||
if (revision != null) {
|
||||
await runCommand(
|
||||
'git',
|
||||
<String>[
|
||||
'checkout',
|
||||
revision,
|
||||
],
|
||||
workingDirectory: flutterRoot,
|
||||
);
|
||||
await runCommand('git', <String>['checkout', revision], workingDirectory: flutterRoot);
|
||||
}
|
||||
final String winScript = path.join(flutterRoot, 'dev', 'customer_testing', 'ci.bat');
|
||||
await runCommand(
|
||||
Platform.isWindows? winScript: './ci.sh',
|
||||
Platform.isWindows ? winScript : './ci.sh',
|
||||
<String>[],
|
||||
workingDirectory: path.join(flutterRoot, 'dev', 'customer_testing'),
|
||||
);
|
||||
|
||||
@@ -7,14 +7,11 @@ import '../utils.dart';
|
||||
|
||||
Future<void> docsRunner() async {
|
||||
printProgress('${green}Running flutter doc tests$reset');
|
||||
await runCommand(
|
||||
'./dev/bots/docs.sh',
|
||||
const <String>[
|
||||
'--output',
|
||||
'dev/docs/api_docs.zip',
|
||||
'--keep-staging',
|
||||
'--staging-dir',
|
||||
'dev/docs',
|
||||
],
|
||||
workingDirectory: flutterRoot,
|
||||
);}
|
||||
await runCommand('./dev/bots/docs.sh', const <String>[
|
||||
'--output',
|
||||
'dev/docs/api_docs.zip',
|
||||
'--keep-staging',
|
||||
'--staging-dir',
|
||||
'dev/docs',
|
||||
], workingDirectory: flutterRoot);
|
||||
}
|
||||
|
||||
@@ -22,63 +22,39 @@ import '../utils.dart';
|
||||
Future<void> runFlutterDriverAndroidTests() async {
|
||||
print('Running Flutter Driver Android tests...');
|
||||
|
||||
await runCommand(
|
||||
'flutter',
|
||||
<String>[
|
||||
'drive',
|
||||
'lib/flutter_rendered_blue_rectangle_main.dart',
|
||||
// There are no reason to enable development flags for this test.
|
||||
// Disable them to work around flakiness issues, and in general just
|
||||
// make less things start up unnecessarily.
|
||||
'--no-dds',
|
||||
'--no-enable-dart-profiling',
|
||||
'--test-arguments=test',
|
||||
'--test-arguments=--reporter=expanded',
|
||||
],
|
||||
workingDirectory: path.join(
|
||||
'dev',
|
||||
'integration_tests',
|
||||
'native_driver_test',
|
||||
),
|
||||
);
|
||||
await runCommand('flutter', <String>[
|
||||
'drive',
|
||||
'lib/flutter_rendered_blue_rectangle_main.dart',
|
||||
// There are no reason to enable development flags for this test.
|
||||
// Disable them to work around flakiness issues, and in general just
|
||||
// make less things start up unnecessarily.
|
||||
'--no-dds',
|
||||
'--no-enable-dart-profiling',
|
||||
'--test-arguments=test',
|
||||
'--test-arguments=--reporter=expanded',
|
||||
], workingDirectory: path.join('dev', 'integration_tests', 'native_driver_test'));
|
||||
|
||||
await runCommand(
|
||||
'flutter',
|
||||
<String>[
|
||||
'drive',
|
||||
'lib/platform_view_blue_orange_gradient_main.dart',
|
||||
// There are no reason to enable development flags for this test.
|
||||
// Disable them to work around flakiness issues, and in general just
|
||||
// make less things start up unnecessarily.
|
||||
'--no-dds',
|
||||
'--no-enable-dart-profiling',
|
||||
'--test-arguments=test',
|
||||
'--test-arguments=--reporter=expanded',
|
||||
],
|
||||
workingDirectory: path.join(
|
||||
'dev',
|
||||
'integration_tests',
|
||||
'native_driver_test',
|
||||
),
|
||||
);
|
||||
await runCommand('flutter', <String>[
|
||||
'drive',
|
||||
'lib/platform_view_blue_orange_gradient_main.dart',
|
||||
// There are no reason to enable development flags for this test.
|
||||
// Disable them to work around flakiness issues, and in general just
|
||||
// make less things start up unnecessarily.
|
||||
'--no-dds',
|
||||
'--no-enable-dart-profiling',
|
||||
'--test-arguments=test',
|
||||
'--test-arguments=--reporter=expanded',
|
||||
], workingDirectory: path.join('dev', 'integration_tests', 'native_driver_test'));
|
||||
|
||||
await runCommand(
|
||||
'flutter',
|
||||
<String>[
|
||||
'drive',
|
||||
'lib/external_texture_smiley_face_main.dart',
|
||||
// There are no reason to enable development flags for this test.
|
||||
// Disable them to work around flakiness issues, and in general just
|
||||
// make less things start up unnecessarily.
|
||||
'--no-dds',
|
||||
'--no-enable-dart-profiling',
|
||||
'--test-arguments=test',
|
||||
'--test-arguments=--reporter=expanded',
|
||||
],
|
||||
workingDirectory: path.join(
|
||||
'dev',
|
||||
'integration_tests',
|
||||
'native_driver_test',
|
||||
),
|
||||
);
|
||||
await runCommand('flutter', <String>[
|
||||
'drive',
|
||||
'lib/external_texture_smiley_face_main.dart',
|
||||
// There are no reason to enable development flags for this test.
|
||||
// Disable them to work around flakiness issues, and in general just
|
||||
// make less things start up unnecessarily.
|
||||
'--no-dds',
|
||||
'--no-enable-dart-profiling',
|
||||
'--test-arguments=test',
|
||||
'--test-arguments=--reporter=expanded',
|
||||
], workingDirectory: path.join('dev', 'integration_tests', 'native_driver_test'));
|
||||
}
|
||||
|
||||
@@ -13,68 +13,47 @@ import '../utils.dart';
|
||||
|
||||
/// Executes the test suite for the flutter/packages repo.
|
||||
Future<void> flutterPackagesRunner() async {
|
||||
|
||||
Future<void> runAnalyze() async {
|
||||
printProgress('${green}Running analysis for flutter/packages$reset');
|
||||
final Directory checkout = Directory.systemTemp.createTempSync('flutter_packages.');
|
||||
await runCommand(
|
||||
'git',
|
||||
const <String>[
|
||||
'-c',
|
||||
'core.longPaths=true',
|
||||
'clone',
|
||||
'https://github.com/flutter/packages.git',
|
||||
'.',
|
||||
],
|
||||
workingDirectory: checkout.path,
|
||||
);
|
||||
await runCommand('git', const <String>[
|
||||
'-c',
|
||||
'core.longPaths=true',
|
||||
'clone',
|
||||
'https://github.com/flutter/packages.git',
|
||||
'.',
|
||||
], workingDirectory: checkout.path);
|
||||
final String packagesCommit = await getFlutterPackagesVersion(flutterRoot: flutterRoot);
|
||||
await runCommand(
|
||||
'git',
|
||||
<String>[
|
||||
'-c',
|
||||
'core.longPaths=true',
|
||||
'checkout',
|
||||
packagesCommit,
|
||||
],
|
||||
workingDirectory: checkout.path,
|
||||
);
|
||||
await runCommand('git', <String>[
|
||||
'-c',
|
||||
'core.longPaths=true',
|
||||
'checkout',
|
||||
packagesCommit,
|
||||
], workingDirectory: checkout.path);
|
||||
// Prep the repository tooling.
|
||||
// This test does not use tool_runner.sh because in this context the test
|
||||
// should always run on the entire packages repo, while tool_runner.sh
|
||||
// is designed for flutter/packages CI and only analyzes changed repository
|
||||
// files when run for anything but master.
|
||||
final String toolDir = path.join(checkout.path, 'script', 'tool');
|
||||
await runCommand(
|
||||
'dart',
|
||||
const <String>[
|
||||
'pub',
|
||||
'get',
|
||||
],
|
||||
workingDirectory: toolDir,
|
||||
);
|
||||
await runCommand('dart', const <String>['pub', 'get'], workingDirectory: toolDir);
|
||||
final String toolScript = path.join(toolDir, 'bin', 'flutter_plugin_tools.dart');
|
||||
await runCommand(
|
||||
'dart',
|
||||
<String>[
|
||||
'run',
|
||||
toolScript,
|
||||
'analyze',
|
||||
// Fetch the oldest possible dependencies, rather than the newest, to
|
||||
// insulate flutter/flutter from out-of-band failures when new versions
|
||||
// of dependencies are published. This compensates for the fact that
|
||||
// flutter/packages doesn't use pinned dependencies, and for the
|
||||
// purposes of this test using old dependencies is fine. See
|
||||
// https://github.com/flutter/flutter/issues/129633
|
||||
'--downgrade',
|
||||
'--custom-analysis=script/configs/custom_analysis.yaml',
|
||||
],
|
||||
workingDirectory: checkout.path,
|
||||
);
|
||||
await runCommand('dart', <String>[
|
||||
'run',
|
||||
toolScript,
|
||||
'analyze',
|
||||
// Fetch the oldest possible dependencies, rather than the newest, to
|
||||
// insulate flutter/flutter from out-of-band failures when new versions
|
||||
// of dependencies are published. This compensates for the fact that
|
||||
// flutter/packages doesn't use pinned dependencies, and for the
|
||||
// purposes of this test using old dependencies is fine. See
|
||||
// https://github.com/flutter/flutter/issues/129633
|
||||
'--downgrade',
|
||||
'--custom-analysis=script/configs/custom_analysis.yaml',
|
||||
], workingDirectory: checkout.path);
|
||||
}
|
||||
await selectSubshard(<String, ShardRunner>{
|
||||
'analyze': runAnalyze,
|
||||
});
|
||||
|
||||
await selectSubshard(<String, ShardRunner>{'analyze': runAnalyze});
|
||||
}
|
||||
|
||||
/// Returns the commit hash of the flutter/packages repository that's rolled in.
|
||||
@@ -92,7 +71,12 @@ Future<String> getFlutterPackagesVersion({
|
||||
String? packagesVersionFile,
|
||||
required String flutterRoot,
|
||||
}) async {
|
||||
final String flutterPackagesVersionFile = path.join(flutterRoot, 'bin', 'internal', 'flutter_packages.version');
|
||||
final String flutterPackagesVersionFile = path.join(
|
||||
flutterRoot,
|
||||
'bin',
|
||||
'internal',
|
||||
'flutter_packages.version',
|
||||
);
|
||||
|
||||
final File versionFile = fileSystem.file(packagesVersionFile ?? flutterPackagesVersionFile);
|
||||
final String versionFileContents = await versionFile.readAsString();
|
||||
|
||||
@@ -9,7 +9,9 @@ import 'package:path/path.dart' as path;
|
||||
import '../utils.dart';
|
||||
|
||||
Future<void> frameworkCoverageRunner() async {
|
||||
final File coverageFile = File(path.join(flutterRoot, 'packages', 'flutter', 'coverage', 'lcov.info'));
|
||||
final File coverageFile = File(
|
||||
path.join(flutterRoot, 'packages', 'flutter', 'coverage', 'lcov.info'),
|
||||
);
|
||||
if (!coverageFile.existsSync()) {
|
||||
foundError(<String>[
|
||||
'${red}Coverage file not found.$reset',
|
||||
@@ -19,7 +21,8 @@ Future<void> frameworkCoverageRunner() async {
|
||||
return;
|
||||
}
|
||||
coverageFile.deleteSync();
|
||||
await runFlutterTest(path.join(flutterRoot, 'packages', 'flutter'),
|
||||
await runFlutterTest(
|
||||
path.join(flutterRoot, 'packages', 'flutter'),
|
||||
options: const <String>['--coverage'],
|
||||
);
|
||||
if (!coverageFile.existsSync()) {
|
||||
|
||||
@@ -14,7 +14,10 @@ import '../utils.dart';
|
||||
import 'run_test_harness_tests.dart';
|
||||
|
||||
Future<void> frameworkTestsRunner() async {
|
||||
final List<String> trackWidgetCreationAlternatives = <String>['--track-widget-creation', '--no-track-widget-creation'];
|
||||
final List<String> trackWidgetCreationAlternatives = <String>[
|
||||
'--track-widget-creation',
|
||||
'--no-track-widget-creation',
|
||||
];
|
||||
|
||||
Future<void> runWidgets() async {
|
||||
printProgress('${green}Running packages/flutter tests $reset for ${cyan}test/widgets/$reset');
|
||||
@@ -22,7 +25,7 @@ Future<void> frameworkTestsRunner() async {
|
||||
await runFlutterTest(
|
||||
path.join(flutterRoot, 'packages', 'flutter'),
|
||||
options: <String>[trackWidgetCreationOption],
|
||||
tests: <String>[ path.join('test', 'widgets') + path.separator ],
|
||||
tests: <String>[path.join('test', 'widgets') + path.separator],
|
||||
);
|
||||
}
|
||||
// Try compiling code outside of the packages/flutter directory with and without --track-widget-creation
|
||||
@@ -42,7 +45,10 @@ Future<void> frameworkTestsRunner() async {
|
||||
// Run profile mode tests (see packages/flutter/test_profile/README.md)
|
||||
await runFlutterTest(
|
||||
path.join(flutterRoot, 'packages', 'flutter'),
|
||||
options: <String>['--dart-define=dart.vm.product=false', '--dart-define=dart.vm.profile=true'],
|
||||
options: <String>[
|
||||
'--dart-define=dart.vm.product=false',
|
||||
'--dart-define=dart.vm.profile=true',
|
||||
],
|
||||
tests: <String>['test_profile${path.separator}'],
|
||||
);
|
||||
}
|
||||
@@ -55,15 +61,19 @@ Future<void> frameworkTestsRunner() async {
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
Future<void> runLibraries() async {
|
||||
final List<String> tests = Directory(path.join(flutterRoot, 'packages', 'flutter', 'test'))
|
||||
.listSync(followLinks: false)
|
||||
.whereType<Directory>()
|
||||
.where((Directory dir) => !dir.path.endsWith('widgets'))
|
||||
.map<String>((Directory dir) => path.join('test', path.basename(dir.path)) + path.separator)
|
||||
.toList();
|
||||
printProgress('${green}Running packages/flutter tests$reset for $cyan${tests.join(", ")}$reset');
|
||||
final List<String> tests =
|
||||
Directory(path.join(flutterRoot, 'packages', 'flutter', 'test'))
|
||||
.listSync(followLinks: false)
|
||||
.whereType<Directory>()
|
||||
.where((Directory dir) => !dir.path.endsWith('widgets'))
|
||||
.map<String>(
|
||||
(Directory dir) => path.join('test', path.basename(dir.path)) + path.separator,
|
||||
)
|
||||
.toList();
|
||||
printProgress(
|
||||
'${green}Running packages/flutter tests$reset for $cyan${tests.join(", ")}$reset',
|
||||
);
|
||||
for (final String trackWidgetCreationOption in trackWidgetCreationAlternatives) {
|
||||
await runFlutterTest(
|
||||
path.join(flutterRoot, 'packages', 'flutter'),
|
||||
@@ -74,17 +84,15 @@ Future<void> frameworkTestsRunner() async {
|
||||
}
|
||||
|
||||
Future<void> runExampleTests() async {
|
||||
await runCommand(
|
||||
flutter,
|
||||
<String>['config', '--enable-${Platform.operatingSystem}-desktop'],
|
||||
workingDirectory: flutterRoot,
|
||||
);
|
||||
await runCommand(
|
||||
dart,
|
||||
<String>[path.join(flutterRoot, 'dev', 'tools', 'examples_smoke_test.dart')],
|
||||
workingDirectory: path.join(flutterRoot, 'examples', 'api'),
|
||||
);
|
||||
for (final FileSystemEntity entity in Directory(path.join(flutterRoot, 'examples')).listSync()) {
|
||||
await runCommand(flutter, <String>[
|
||||
'config',
|
||||
'--enable-${Platform.operatingSystem}-desktop',
|
||||
], workingDirectory: flutterRoot);
|
||||
await runCommand(dart, <String>[
|
||||
path.join(flutterRoot, 'dev', 'tools', 'examples_smoke_test.dart'),
|
||||
], workingDirectory: path.join(flutterRoot, 'examples', 'api'));
|
||||
for (final FileSystemEntity entity
|
||||
in Directory(path.join(flutterRoot, 'examples')).listSync()) {
|
||||
if (entity is! Directory || !Directory(path.join(entity.path, 'test')).existsSync()) {
|
||||
continue;
|
||||
}
|
||||
@@ -105,14 +113,25 @@ Future<void> frameworkTestsRunner() async {
|
||||
required Set<String> disallowed,
|
||||
}) async {
|
||||
try {
|
||||
await runCommand(
|
||||
flutter,
|
||||
<String>[
|
||||
'build', 'appbundle', '--$modeArgument', path.join('lib', sourceFile),
|
||||
],
|
||||
workingDirectory: tracingDirectory,
|
||||
await runCommand(flutter, <String>[
|
||||
'build',
|
||||
'appbundle',
|
||||
'--$modeArgument',
|
||||
path.join('lib', sourceFile),
|
||||
], workingDirectory: tracingDirectory);
|
||||
final Archive archive = ZipDecoder().decodeBytes(
|
||||
File(
|
||||
path.join(
|
||||
tracingDirectory,
|
||||
'build',
|
||||
'app',
|
||||
'outputs',
|
||||
'bundle',
|
||||
modeArgument,
|
||||
'app-$modeArgument.aab',
|
||||
),
|
||||
).readAsBytesSync(),
|
||||
);
|
||||
final Archive archive = ZipDecoder().decodeBytes(File(path.join(tracingDirectory, 'build', 'app', 'outputs', 'bundle', modeArgument, 'app-$modeArgument.aab')).readAsBytesSync());
|
||||
final ArchiveFile libapp = archive.findFile('base/lib/arm64-v8a/libapp.so')!;
|
||||
final Uint8List libappBytes = libapp.content as Uint8List; // bytes decompressed here
|
||||
final String libappStrings = utf8.decode(libappBytes, allowMalformed: true);
|
||||
@@ -120,72 +139,78 @@ Future<void> frameworkTestsRunner() async {
|
||||
final List<String> results = <String>[];
|
||||
for (final String pattern in allowed) {
|
||||
if (!libappStrings.contains(pattern)) {
|
||||
results.add('When building with --$modeArgument, expected to find "$pattern" in libapp.so but could not find it.');
|
||||
results.add(
|
||||
'When building with --$modeArgument, expected to find "$pattern" in libapp.so but could not find it.',
|
||||
);
|
||||
}
|
||||
}
|
||||
for (final String pattern in disallowed) {
|
||||
if (libappStrings.contains(pattern)) {
|
||||
results.add('When building with --$modeArgument, expected to not find "$pattern" in libapp.so but did find it.');
|
||||
results.add(
|
||||
'When building with --$modeArgument, expected to not find "$pattern" in libapp.so but did find it.',
|
||||
);
|
||||
}
|
||||
}
|
||||
return results;
|
||||
} catch (error, stackTrace) {
|
||||
return <String>[
|
||||
error.toString(),
|
||||
...stackTrace.toString().trimRight().split('\n'),
|
||||
];
|
||||
return <String>[error.toString(), ...stackTrace.toString().trimRight().split('\n')];
|
||||
}
|
||||
}
|
||||
|
||||
final List<String> results = <String>[];
|
||||
results.addAll(await verifyTracingAppBuild(
|
||||
modeArgument: 'profile',
|
||||
sourceFile: 'control.dart', // this is the control, the other two below are the actual test
|
||||
allowed: <String>{
|
||||
'TIMELINE ARGUMENTS TEST CONTROL FILE',
|
||||
'toTimelineArguments used in non-debug build', // we call toTimelineArguments directly to check the message does exist
|
||||
},
|
||||
disallowed: <String>{
|
||||
'BUILT IN DEBUG MODE', 'BUILT IN RELEASE MODE',
|
||||
},
|
||||
));
|
||||
results.addAll(await verifyTracingAppBuild(
|
||||
modeArgument: 'profile',
|
||||
sourceFile: 'test.dart',
|
||||
allowed: <String>{
|
||||
'BUILT IN PROFILE MODE', 'RenderTest.performResize called', // controls
|
||||
'BUILD', 'LAYOUT', 'PAINT', // we output these to the timeline in profile builds
|
||||
// (LAYOUT and PAINT also exist because of NEEDS-LAYOUT and NEEDS-PAINT in RenderObject.toStringShort)
|
||||
},
|
||||
disallowed: <String>{
|
||||
'BUILT IN DEBUG MODE', 'BUILT IN RELEASE MODE',
|
||||
'TestWidget.debugFillProperties called', 'RenderTest.debugFillProperties called', // debug only
|
||||
'toTimelineArguments used in non-debug build', // entire function should get dropped by tree shaker
|
||||
},
|
||||
));
|
||||
results.addAll(await verifyTracingAppBuild(
|
||||
modeArgument: 'release',
|
||||
sourceFile: 'test.dart',
|
||||
allowed: <String>{
|
||||
'BUILT IN RELEASE MODE', 'RenderTest.performResize called', // controls
|
||||
},
|
||||
disallowed: <String>{
|
||||
'BUILT IN DEBUG MODE', 'BUILT IN PROFILE MODE',
|
||||
'BUILD', 'LAYOUT', 'PAINT', // these are only used in Timeline.startSync calls that should not appear in release builds
|
||||
'TestWidget.debugFillProperties called', 'RenderTest.debugFillProperties called', // debug only
|
||||
'toTimelineArguments used in non-debug build', // not included in release builds
|
||||
},
|
||||
));
|
||||
results.addAll(
|
||||
await verifyTracingAppBuild(
|
||||
modeArgument: 'profile',
|
||||
sourceFile: 'control.dart', // this is the control, the other two below are the actual test
|
||||
allowed: <String>{
|
||||
'TIMELINE ARGUMENTS TEST CONTROL FILE',
|
||||
'toTimelineArguments used in non-debug build', // we call toTimelineArguments directly to check the message does exist
|
||||
},
|
||||
disallowed: <String>{'BUILT IN DEBUG MODE', 'BUILT IN RELEASE MODE'},
|
||||
),
|
||||
);
|
||||
results.addAll(
|
||||
await verifyTracingAppBuild(
|
||||
modeArgument: 'profile',
|
||||
sourceFile: 'test.dart',
|
||||
allowed: <String>{
|
||||
'BUILT IN PROFILE MODE', 'RenderTest.performResize called', // controls
|
||||
'BUILD', 'LAYOUT', 'PAINT', // we output these to the timeline in profile builds
|
||||
// (LAYOUT and PAINT also exist because of NEEDS-LAYOUT and NEEDS-PAINT in RenderObject.toStringShort)
|
||||
},
|
||||
disallowed: <String>{
|
||||
'BUILT IN DEBUG MODE', 'BUILT IN RELEASE MODE',
|
||||
'TestWidget.debugFillProperties called',
|
||||
'RenderTest.debugFillProperties called', // debug only
|
||||
'toTimelineArguments used in non-debug build', // entire function should get dropped by tree shaker
|
||||
},
|
||||
),
|
||||
);
|
||||
results.addAll(
|
||||
await verifyTracingAppBuild(
|
||||
modeArgument: 'release',
|
||||
sourceFile: 'test.dart',
|
||||
allowed: <String>{
|
||||
'BUILT IN RELEASE MODE', 'RenderTest.performResize called', // controls
|
||||
},
|
||||
disallowed: <String>{
|
||||
'BUILT IN DEBUG MODE', 'BUILT IN PROFILE MODE',
|
||||
'BUILD',
|
||||
'LAYOUT',
|
||||
'PAINT', // these are only used in Timeline.startSync calls that should not appear in release builds
|
||||
'TestWidget.debugFillProperties called',
|
||||
'RenderTest.debugFillProperties called', // debug only
|
||||
'toTimelineArguments used in non-debug build', // not included in release builds
|
||||
},
|
||||
),
|
||||
);
|
||||
if (results.isNotEmpty) {
|
||||
foundError(results);
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> runFixTests(String package) async {
|
||||
final List<String> args = <String>[
|
||||
'fix',
|
||||
'--compare-to-golden',
|
||||
];
|
||||
final List<String> args = <String>['fix', '--compare-to-golden'];
|
||||
await runCommand(
|
||||
dart,
|
||||
args,
|
||||
@@ -194,14 +219,10 @@ Future<void> frameworkTestsRunner() async {
|
||||
}
|
||||
|
||||
Future<void> runPrivateTests() async {
|
||||
final List<String> args = <String>[
|
||||
'run',
|
||||
'bin/test_private.dart',
|
||||
];
|
||||
final List<String> args = <String>['run', 'bin/test_private.dart'];
|
||||
final Map<String, String> environment = <String, String>{
|
||||
'FLUTTER_ROOT': flutterRoot,
|
||||
if (Directory(pubCache).existsSync())
|
||||
'PUB_CACHE': pubCache,
|
||||
if (Directory(pubCache).existsSync()) 'PUB_CACHE': pubCache,
|
||||
};
|
||||
adjustEnvironmentToEnableFlutterAsserts(environment);
|
||||
await runCommand(
|
||||
@@ -217,7 +238,9 @@ Future<void> frameworkTestsRunner() async {
|
||||
// These tests need to be platform agnostic as they are only run on a linux
|
||||
// machine to save on execution time and cost.
|
||||
Future<void> runSlow() async {
|
||||
printProgress('${green}Running slow package tests$reset for directories other than packages/flutter');
|
||||
printProgress(
|
||||
'${green}Running slow package tests$reset for directories other than packages/flutter',
|
||||
);
|
||||
await runTracingTests();
|
||||
await runFixTests('flutter');
|
||||
await runFixTests('flutter_test');
|
||||
@@ -227,21 +250,26 @@ Future<void> frameworkTestsRunner() async {
|
||||
}
|
||||
|
||||
Future<void> runMisc() async {
|
||||
printProgress('${green}Running package tests$reset for directories other than packages/flutter');
|
||||
printProgress(
|
||||
'${green}Running package tests$reset for directories other than packages/flutter',
|
||||
);
|
||||
await testHarnessTestsRunner();
|
||||
await runExampleTests();
|
||||
await runFlutterTest(
|
||||
path.join(flutterRoot, 'dev', 'a11y_assessments'),
|
||||
tests: <String>[ 'test' ],
|
||||
tests: <String>['test'],
|
||||
);
|
||||
await runDartTest(path.join(flutterRoot, 'dev', 'bots'));
|
||||
await runDartTest(
|
||||
path.join(flutterRoot, 'dev', 'devicelab'),
|
||||
ensurePrecompiledTool: false, // See https://github.com/flutter/flutter/issues/86209
|
||||
ensurePrecompiledTool: false, // See https://github.com/flutter/flutter/issues/86209
|
||||
);
|
||||
await runDartTest(path.join(flutterRoot, 'dev', 'conductor', 'core'), forceSingleCore: true);
|
||||
// TODO(gspencergoog): Remove the exception for fatalWarnings once https://github.com/flutter/flutter/issues/113782 has landed.
|
||||
await runFlutterTest(path.join(flutterRoot, 'dev', 'integration_tests', 'android_semantics_testing'), fatalWarnings: false);
|
||||
await runFlutterTest(
|
||||
path.join(flutterRoot, 'dev', 'integration_tests', 'android_semantics_testing'),
|
||||
fatalWarnings: false,
|
||||
);
|
||||
await runFlutterTest(path.join(flutterRoot, 'dev', 'integration_tests', 'ui'));
|
||||
await runFlutterTest(path.join(flutterRoot, 'dev', 'manual_tests'));
|
||||
await runFlutterTest(path.join(flutterRoot, 'dev', 'tools'));
|
||||
@@ -249,19 +277,31 @@ Future<void> frameworkTestsRunner() async {
|
||||
await runFlutterTest(path.join(flutterRoot, 'dev', 'tools', 'gen_defaults'));
|
||||
await runFlutterTest(path.join(flutterRoot, 'dev', 'tools', 'gen_keycodes'));
|
||||
await runFlutterTest(path.join(flutterRoot, 'dev', 'benchmarks', 'test_apps', 'stocks'));
|
||||
await runFlutterTest(path.join(flutterRoot, 'packages', 'flutter_driver'), tests: <String>[path.join('test', 'src', 'real_tests')]);
|
||||
await runFlutterTest(path.join(flutterRoot, 'packages', 'integration_test'), options: <String>[
|
||||
'--enable-vmservice',
|
||||
// Web-specific tests depend on Chromium, so they run as part of the web_long_running_tests shard.
|
||||
'--exclude-tags=web',
|
||||
]);
|
||||
await runFlutterTest(
|
||||
path.join(flutterRoot, 'packages', 'flutter_driver'),
|
||||
tests: <String>[path.join('test', 'src', 'real_tests')],
|
||||
);
|
||||
await runFlutterTest(
|
||||
path.join(flutterRoot, 'packages', 'integration_test'),
|
||||
options: <String>[
|
||||
'--enable-vmservice',
|
||||
// Web-specific tests depend on Chromium, so they run as part of the web_long_running_tests shard.
|
||||
'--exclude-tags=web',
|
||||
],
|
||||
);
|
||||
// Run java unit tests for integration_test
|
||||
//
|
||||
// Generate Gradle wrapper if it doesn't exist.
|
||||
Process.runSync(
|
||||
flutter,
|
||||
<String>['build', 'apk', '--config-only'],
|
||||
workingDirectory: path.join(flutterRoot, 'packages', 'integration_test', 'example', 'android'),
|
||||
workingDirectory: path.join(
|
||||
flutterRoot,
|
||||
'packages',
|
||||
'integration_test',
|
||||
'example',
|
||||
'android',
|
||||
),
|
||||
);
|
||||
await runCommand(
|
||||
path.join(flutterRoot, 'packages', 'integration_test', 'example', 'android', 'gradlew$bat'),
|
||||
@@ -270,7 +310,13 @@ Future<void> frameworkTestsRunner() async {
|
||||
'--tests',
|
||||
'dev.flutter.plugins.integration_test.FlutterDeviceScreenshotTest',
|
||||
],
|
||||
workingDirectory: path.join(flutterRoot, 'packages', 'integration_test', 'example', 'android'),
|
||||
workingDirectory: path.join(
|
||||
flutterRoot,
|
||||
'packages',
|
||||
'integration_test',
|
||||
'example',
|
||||
'android',
|
||||
),
|
||||
);
|
||||
await runFlutterTest(path.join(flutterRoot, 'packages', 'flutter_goldens'));
|
||||
await runFlutterTest(path.join(flutterRoot, 'packages', 'flutter_localizations'));
|
||||
@@ -278,11 +324,11 @@ Future<void> frameworkTestsRunner() async {
|
||||
await runFlutterTest(path.join(flutterRoot, 'packages', 'fuchsia_remote_debug_protocol'));
|
||||
await runFlutterTest(path.join(flutterRoot, 'dev', 'integration_tests', 'non_nullable'));
|
||||
const String httpClientWarning =
|
||||
'Warning: At least one test in this suite creates an HttpClient. When running a test suite that uses\n'
|
||||
'TestWidgetsFlutterBinding, all HTTP requests will return status code 400, and no network request\n'
|
||||
'will actually be made. Any test expecting a real network connection and status code will fail.\n'
|
||||
'To test code that needs an HttpClient, provide your own HttpClient implementation to the code under\n'
|
||||
'test, so that your test can consistently provide a testable response to the code under test.';
|
||||
'Warning: At least one test in this suite creates an HttpClient. When running a test suite that uses\n'
|
||||
'TestWidgetsFlutterBinding, all HTTP requests will return status code 400, and no network request\n'
|
||||
'will actually be made. Any test expecting a real network connection and status code will fail.\n'
|
||||
'To test code that needs an HttpClient, provide your own HttpClient implementation to the code under\n'
|
||||
'test, so that your test can consistently provide a testable response to the code under test.';
|
||||
await runFlutterTest(
|
||||
path.join(flutterRoot, 'packages', 'flutter_test'),
|
||||
script: path.join('test', 'bindings_test_failure.dart'),
|
||||
@@ -292,8 +338,8 @@ Future<void> frameworkTestsRunner() async {
|
||||
final Iterable<Match> matches = httpClientWarning.allMatches(result.flattenedStdout!);
|
||||
if (matches.isEmpty || matches.length > 1) {
|
||||
return 'Failed to print warning about HttpClientUsage, or printed it too many times.\n\n'
|
||||
'stdout:\n${result.flattenedStdout}\n\n'
|
||||
'stderr:\n${result.flattenedStderr}';
|
||||
'stdout:\n${result.flattenedStdout}\n\n'
|
||||
'stderr:\n${result.flattenedStderr}';
|
||||
}
|
||||
return null;
|
||||
},
|
||||
|
||||
@@ -8,24 +8,16 @@ import '../utils.dart';
|
||||
// Runs flutter_precache.
|
||||
Future<void> fuchsiaPrecacheRunner() async {
|
||||
printProgress('${green}Running flutter precache tests$reset');
|
||||
await runCommand(
|
||||
'flutter',
|
||||
const <String>[
|
||||
'config',
|
||||
'--enable-fuchsia',
|
||||
],
|
||||
workingDirectory: flutterRoot,
|
||||
);
|
||||
await runCommand(
|
||||
'flutter',
|
||||
const <String>[
|
||||
'precache',
|
||||
'--flutter_runner',
|
||||
'--fuchsia',
|
||||
'--no-android',
|
||||
'--no-ios',
|
||||
'--force',
|
||||
],
|
||||
workingDirectory: flutterRoot,
|
||||
);
|
||||
await runCommand('flutter', const <String>[
|
||||
'config',
|
||||
'--enable-fuchsia',
|
||||
], workingDirectory: flutterRoot);
|
||||
await runCommand('flutter', const <String>[
|
||||
'precache',
|
||||
'--flutter_runner',
|
||||
'--fuchsia',
|
||||
'--no-android',
|
||||
'--no-ios',
|
||||
'--force',
|
||||
], workingDirectory: flutterRoot);
|
||||
}
|
||||
|
||||
@@ -17,17 +17,13 @@ import '../utils.dart';
|
||||
Future<void> skpGeneratorTestsRunner() async {
|
||||
printProgress('${green}Running skp_generator from flutter/tests$reset');
|
||||
final Directory checkout = Directory.systemTemp.createTempSync('flutter_skp_generator.');
|
||||
await runCommand(
|
||||
'git',
|
||||
<String>[
|
||||
'-c',
|
||||
'core.longPaths=true',
|
||||
'clone',
|
||||
'https://github.com/flutter/tests.git',
|
||||
'.',
|
||||
],
|
||||
workingDirectory: checkout.path,
|
||||
);
|
||||
await runCommand('git', <String>[
|
||||
'-c',
|
||||
'core.longPaths=true',
|
||||
'clone',
|
||||
'https://github.com/flutter/tests.git',
|
||||
'.',
|
||||
], workingDirectory: checkout.path);
|
||||
await runCommand(
|
||||
'./build.sh',
|
||||
const <String>[],
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
import 'dart:io' show File, Platform;
|
||||
import 'dart:io' show File, Platform;
|
||||
|
||||
import 'package:path/path.dart' as path;
|
||||
|
||||
@@ -19,11 +19,12 @@ String get platformFolderName {
|
||||
if (Platform.isLinux) {
|
||||
return 'linux-x64';
|
||||
}
|
||||
throw UnsupportedError('The platform ${Platform.operatingSystem} is not supported by this script.');
|
||||
throw UnsupportedError(
|
||||
'The platform ${Platform.operatingSystem} is not supported by this script.',
|
||||
);
|
||||
}
|
||||
|
||||
Future<void> testHarnessTestsRunner() async {
|
||||
|
||||
printProgress('${green}Running test harness tests...$reset');
|
||||
|
||||
await _validateEngineHash();
|
||||
@@ -55,10 +56,10 @@ Future<void> testHarnessTestsRunner() async {
|
||||
printOutput: false,
|
||||
outputChecker: (CommandResult result) {
|
||||
return result.flattenedStdout!.contains('failingPendingTimerTest')
|
||||
? null
|
||||
: 'Failed to find the stack trace for the pending Timer.\n\n'
|
||||
'stdout:\n${result.flattenedStdout}\n\n'
|
||||
'stderr:\n${result.flattenedStderr}';
|
||||
? null
|
||||
: 'Failed to find the stack trace for the pending Timer.\n\n'
|
||||
'stdout:\n${result.flattenedStdout}\n\n'
|
||||
'stderr:\n${result.flattenedStderr}';
|
||||
},
|
||||
),
|
||||
() => runFlutterTest(
|
||||
@@ -67,16 +68,17 @@ Future<void> testHarnessTestsRunner() async {
|
||||
expectFailure: true,
|
||||
printOutput: false,
|
||||
outputChecker: (CommandResult result) {
|
||||
const String expectedError = '══╡ EXCEPTION CAUGHT BY FLUTTER TEST FRAMEWORK ╞════════════════════════════════════════════════════\n'
|
||||
const String expectedError =
|
||||
'══╡ EXCEPTION CAUGHT BY FLUTTER TEST FRAMEWORK ╞════════════════════════════════════════════════════\n'
|
||||
'The following StateError was thrown running a test (but after the test had completed):\n'
|
||||
'Bad state: Exception thrown after test completed.';
|
||||
if (result.flattenedStdout!.contains(expectedError)) {
|
||||
return null;
|
||||
}
|
||||
return 'Failed to find expected output on stdout.\n\n'
|
||||
'Expected output:\n$expectedError\n\n'
|
||||
'Actual stdout:\n${result.flattenedStdout}\n\n'
|
||||
'Actual stderr:\n${result.flattenedStderr}';
|
||||
'Expected output:\n$expectedError\n\n'
|
||||
'Actual stdout:\n${result.flattenedStdout}\n\n'
|
||||
'Actual stderr:\n${result.flattenedStderr}';
|
||||
},
|
||||
),
|
||||
() => runFlutterTest(
|
||||
@@ -134,7 +136,15 @@ Future<void> testHarnessTestsRunner() async {
|
||||
/// Verify the Flutter Engine is the revision in
|
||||
/// bin/cache/internal/engine.version.
|
||||
Future<void> _validateEngineHash() async {
|
||||
final String flutterTester = path.join(flutterRoot, 'bin', 'cache', 'artifacts', 'engine', platformFolderName, 'flutter_tester$exe');
|
||||
final String flutterTester = path.join(
|
||||
flutterRoot,
|
||||
'bin',
|
||||
'cache',
|
||||
'artifacts',
|
||||
'engine',
|
||||
platformFolderName,
|
||||
'flutter_tester$exe',
|
||||
);
|
||||
|
||||
if (runningInDartHHHBot) {
|
||||
// The Dart HHH bots intentionally modify the local artifact cache
|
||||
@@ -145,7 +155,9 @@ Future<void> _validateEngineHash() async {
|
||||
return;
|
||||
}
|
||||
final String expectedVersion = File(engineVersionFile).readAsStringSync().trim();
|
||||
final CommandResult result = await runCommand(flutterTester, <String>['--help'], outputMode: OutputMode.capture);
|
||||
final CommandResult result = await runCommand(flutterTester, <String>[
|
||||
'--help',
|
||||
], outputMode: OutputMode.capture);
|
||||
if (result.flattenedStdout!.isNotEmpty) {
|
||||
foundError(<String>[
|
||||
'${red}The stdout of `$flutterTester --help` was not empty:$reset',
|
||||
@@ -165,6 +177,8 @@ Future<void> _validateEngineHash() async {
|
||||
return;
|
||||
}
|
||||
if (!actualVersion.contains(expectedVersion)) {
|
||||
foundError(<String>['${red}Expected "Flutter Engine Version: $expectedVersion", but found "$actualVersion".$reset']);
|
||||
foundError(<String>[
|
||||
'${red}Expected "Flutter Engine Version: $expectedVersion", but found "$actualVersion".$reset',
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,16 +14,12 @@ import '../utils.dart';
|
||||
|
||||
Future<void> verifyCodesignedTestRunner() async {
|
||||
printProgress('${green}Running binaries codesign verification$reset');
|
||||
await runCommand(
|
||||
'flutter',
|
||||
<String>[
|
||||
'precache',
|
||||
'--android',
|
||||
'--ios',
|
||||
'--macos'
|
||||
],
|
||||
workingDirectory: flutterRoot,
|
||||
);
|
||||
await runCommand('flutter', <String>[
|
||||
'precache',
|
||||
'--android',
|
||||
'--ios',
|
||||
'--macos',
|
||||
], workingDirectory: flutterRoot);
|
||||
|
||||
await verifyExist(flutterRoot);
|
||||
await verifySignatures(flutterRoot);
|
||||
@@ -43,7 +39,7 @@ const List<String> expectedEntitlements = <String>[
|
||||
/// This list should be kept in sync with the actual contents of Flutter's
|
||||
/// cache.
|
||||
List<String> binariesWithEntitlements(String flutterRoot) {
|
||||
return <String> [
|
||||
return <String>[
|
||||
'artifacts/engine/android-arm-profile/darwin-x64/gen_snapshot',
|
||||
'artifacts/engine/android-arm-release/darwin-x64/gen_snapshot',
|
||||
'artifacts/engine/android-arm64-profile/darwin-x64/gen_snapshot',
|
||||
@@ -75,8 +71,7 @@ List<String> binariesWithEntitlements(String flutterRoot) {
|
||||
'dart-sdk/bin/dartaotruntime',
|
||||
'dart-sdk/bin/utils/gen_snapshot',
|
||||
'dart-sdk/bin/utils/wasm-opt',
|
||||
]
|
||||
.map((String relativePath) => path.join(flutterRoot, 'bin', 'cache', relativePath)).toList();
|
||||
].map((String relativePath) => path.join(flutterRoot, 'bin', 'cache', relativePath)).toList();
|
||||
}
|
||||
|
||||
/// Binaries that are only expected to be codesigned.
|
||||
@@ -105,8 +100,7 @@ List<String> binariesWithoutEntitlements(String flutterRoot) {
|
||||
'artifacts/engine/ios/extension_safe/Flutter.xcframework/ios-arm64/Flutter.framework/Flutter',
|
||||
'artifacts/engine/ios/extension_safe/Flutter.xcframework/ios-arm64_x86_64-simulator/Flutter.framework/Flutter',
|
||||
'artifacts/ios-deploy/ios-deploy',
|
||||
]
|
||||
.map((String relativePath) => path.join(flutterRoot, 'bin', 'cache', relativePath)).toList();
|
||||
].map((String relativePath) => path.join(flutterRoot, 'bin', 'cache', relativePath)).toList();
|
||||
}
|
||||
|
||||
/// Binaries that are not expected to be codesigned.
|
||||
@@ -119,11 +113,9 @@ List<String> unsignedBinaries(String flutterRoot) {
|
||||
'artifacts/engine/ios-release/Flutter.xcframework/ios-arm64_x86_64-simulator/dSYMs/Flutter.framework.dSYM/Contents/Resources/DWARF/Flutter',
|
||||
'artifacts/engine/ios-release/extension_safe/Flutter.xcframework/ios-arm64/dSYMs/Flutter.framework.dSYM/Contents/Resources/DWARF/Flutter',
|
||||
'artifacts/engine/ios-release/extension_safe/Flutter.xcframework/ios-arm64_x86_64-simulator/dSYMs/Flutter.framework.dSYM/Contents/Resources/DWARF/Flutter',
|
||||
]
|
||||
.map((String relativePath) => path.join(flutterRoot, 'bin', 'cache', relativePath)).toList();
|
||||
].map((String relativePath) => path.join(flutterRoot, 'bin', 'cache', relativePath)).toList();
|
||||
}
|
||||
|
||||
|
||||
/// xcframeworks that are expected to be codesigned.
|
||||
///
|
||||
/// This list should be kept in sync with the actual contents of Flutter's
|
||||
@@ -139,8 +131,7 @@ List<String> signedXcframeworks(String flutterRoot) {
|
||||
'artifacts/engine/darwin-x64-profile/FlutterMacOS.xcframework',
|
||||
'artifacts/engine/darwin-x64-release/FlutterMacOS.xcframework',
|
||||
'artifacts/engine/darwin-x64/FlutterMacOS.xcframework',
|
||||
]
|
||||
.map((String relativePath) => path.join(flutterRoot, 'bin', 'cache', relativePath)).toList();
|
||||
].map((String relativePath) => path.join(flutterRoot, 'bin', 'cache', relativePath)).toList();
|
||||
}
|
||||
|
||||
/// Verify the existence of all expected binaries in cache.
|
||||
@@ -151,25 +142,30 @@ List<String> signedXcframeworks(String flutterRoot) {
|
||||
/// [binariesWithEntitlements], [binariesWithoutEntitlements], and
|
||||
/// [unsignedBinaries] lists should be updated accordingly.
|
||||
Future<void> verifyExist(
|
||||
String flutterRoot,
|
||||
{@visibleForTesting ProcessManager processManager = const LocalProcessManager()
|
||||
String flutterRoot, {
|
||||
@visibleForTesting ProcessManager processManager = const LocalProcessManager(),
|
||||
}) async {
|
||||
final List<String> binaryPaths = await findBinaryPaths(
|
||||
path.join(flutterRoot, 'bin', 'cache'),
|
||||
processManager: processManager,
|
||||
);
|
||||
final List<String> expectedSigned = binariesWithEntitlements(flutterRoot) + binariesWithoutEntitlements(flutterRoot);
|
||||
final List<String> expectedSigned =
|
||||
binariesWithEntitlements(flutterRoot) + binariesWithoutEntitlements(flutterRoot);
|
||||
final List<String> expectedUnsigned = unsignedBinaries(flutterRoot);
|
||||
final Set<String> foundFiles = <String>{
|
||||
for (final String binaryPath in binaryPaths)
|
||||
if (expectedSigned.contains(binaryPath)) binaryPath
|
||||
else if (expectedUnsigned.contains(binaryPath)) binaryPath
|
||||
else throw Exception('Found unexpected binary in cache: $binaryPath'),
|
||||
if (expectedSigned.contains(binaryPath))
|
||||
binaryPath
|
||||
else if (expectedUnsigned.contains(binaryPath))
|
||||
binaryPath
|
||||
else
|
||||
throw Exception('Found unexpected binary in cache: $binaryPath'),
|
||||
};
|
||||
|
||||
if (foundFiles.length < expectedSigned.length) {
|
||||
final List<String> unfoundFiles = <String>[
|
||||
for (final String file in expectedSigned) if (!foundFiles.contains(file)) file,
|
||||
for (final String file in expectedSigned)
|
||||
if (!foundFiles.contains(file)) file,
|
||||
];
|
||||
print(
|
||||
'Expected binaries not found in cache:\n\n${unfoundFiles.join('\n')}\n\n'
|
||||
@@ -185,16 +181,17 @@ Future<void> verifyExist(
|
||||
|
||||
/// Verify code signatures and entitlements of all binaries in the cache.
|
||||
Future<void> verifySignatures(
|
||||
String flutterRoot,
|
||||
{@visibleForTesting ProcessManager processManager = const LocalProcessManager()}
|
||||
) async {
|
||||
String flutterRoot, {
|
||||
@visibleForTesting ProcessManager processManager = const LocalProcessManager(),
|
||||
}) async {
|
||||
final List<String> unsignedFiles = <String>[];
|
||||
final List<String> wrongEntitlementBinaries = <String>[];
|
||||
final List<String> unexpectedFiles = <String>[];
|
||||
final String cacheDirectory = path.join(flutterRoot, 'bin', 'cache');
|
||||
final String cacheDirectory = path.join(flutterRoot, 'bin', 'cache');
|
||||
|
||||
final List<String> binariesAndXcframeworks =
|
||||
(await findBinaryPaths(cacheDirectory, processManager: processManager)) + (await findXcframeworksPaths(cacheDirectory, processManager: processManager));
|
||||
(await findBinaryPaths(cacheDirectory, processManager: processManager)) +
|
||||
(await findXcframeworksPaths(cacheDirectory, processManager: processManager));
|
||||
|
||||
for (final String pathToCheck in binariesAndXcframeworks) {
|
||||
bool verifySignature = false;
|
||||
@@ -220,13 +217,11 @@ Future<void> verifySignatures(
|
||||
continue;
|
||||
}
|
||||
print('Verifying the code signature of $pathToCheck');
|
||||
final io.ProcessResult codeSignResult = await processManager.run(
|
||||
<String>[
|
||||
'codesign',
|
||||
'-vvv',
|
||||
pathToCheck,
|
||||
],
|
||||
);
|
||||
final io.ProcessResult codeSignResult = await processManager.run(<String>[
|
||||
'codesign',
|
||||
'-vvv',
|
||||
pathToCheck,
|
||||
]);
|
||||
if (codeSignResult.exitCode != 0) {
|
||||
unsignedFiles.add(pathToCheck);
|
||||
print(
|
||||
@@ -238,7 +233,11 @@ Future<void> verifySignatures(
|
||||
}
|
||||
if (verifyEntitlements) {
|
||||
print('Verifying entitlements of $pathToCheck');
|
||||
if (!(await hasExpectedEntitlements(pathToCheck, flutterRoot, processManager: processManager))) {
|
||||
if (!(await hasExpectedEntitlements(
|
||||
pathToCheck,
|
||||
flutterRoot,
|
||||
processManager: processManager,
|
||||
))) {
|
||||
wrongEntitlementBinaries.add(pathToCheck);
|
||||
}
|
||||
}
|
||||
@@ -280,22 +279,18 @@ Future<void> verifySignatures(
|
||||
|
||||
/// Find every binary file in the given [rootDirectory].
|
||||
Future<List<String>> findBinaryPaths(
|
||||
String rootDirectory,
|
||||
{@visibleForTesting ProcessManager processManager = const LocalProcessManager()
|
||||
String rootDirectory, {
|
||||
@visibleForTesting ProcessManager processManager = const LocalProcessManager(),
|
||||
}) async {
|
||||
final List<String> allBinaryPaths = <String>[];
|
||||
final io.ProcessResult result = await processManager.run(
|
||||
<String>[
|
||||
'find',
|
||||
rootDirectory,
|
||||
'-type',
|
||||
'f',
|
||||
],
|
||||
);
|
||||
final List<String> allFiles = (result.stdout as String)
|
||||
.split('\n')
|
||||
.where((String s) => s.isNotEmpty)
|
||||
.toList();
|
||||
final io.ProcessResult result = await processManager.run(<String>[
|
||||
'find',
|
||||
rootDirectory,
|
||||
'-type',
|
||||
'f',
|
||||
]);
|
||||
final List<String> allFiles =
|
||||
(result.stdout as String).split('\n').where((String s) => s.isNotEmpty).toList();
|
||||
|
||||
await Future.forEach(allFiles, (String filePath) async {
|
||||
if (await isBinary(filePath, processManager: processManager)) {
|
||||
@@ -308,22 +303,19 @@ Future<List<String>> findBinaryPaths(
|
||||
|
||||
/// Find every xcframework in the given [rootDirectory].
|
||||
Future<List<String>> findXcframeworksPaths(
|
||||
String rootDirectory,
|
||||
{@visibleForTesting ProcessManager processManager = const LocalProcessManager()
|
||||
}) async {
|
||||
final io.ProcessResult result = await processManager.run(
|
||||
<String>[
|
||||
'find',
|
||||
rootDirectory,
|
||||
'-type',
|
||||
'd',
|
||||
'-name',
|
||||
'*xcframework',
|
||||
],
|
||||
);
|
||||
final List<String> allXcframeworkPaths = LineSplitter.split(result.stdout as String)
|
||||
.where((String s) => s.isNotEmpty)
|
||||
.toList();
|
||||
String rootDirectory, {
|
||||
@visibleForTesting ProcessManager processManager = const LocalProcessManager(),
|
||||
}) async {
|
||||
final io.ProcessResult result = await processManager.run(<String>[
|
||||
'find',
|
||||
rootDirectory,
|
||||
'-type',
|
||||
'd',
|
||||
'-name',
|
||||
'*xcframework',
|
||||
]);
|
||||
final List<String> allXcframeworkPaths =
|
||||
LineSplitter.split(result.stdout as String).where((String s) => s.isNotEmpty).toList();
|
||||
for (final String path in allXcframeworkPaths) {
|
||||
print('Found: $path\n');
|
||||
}
|
||||
@@ -332,35 +324,31 @@ Future<List<String>> findXcframeworksPaths(
|
||||
|
||||
/// Check mime-type of file at [filePath] to determine if it is binary.
|
||||
Future<bool> isBinary(
|
||||
String filePath,
|
||||
{@visibleForTesting ProcessManager processManager = const LocalProcessManager()}
|
||||
) async {
|
||||
final io.ProcessResult result = await processManager.run(
|
||||
<String>[
|
||||
'file',
|
||||
'--mime-type',
|
||||
'-b', // is binary
|
||||
filePath,
|
||||
],
|
||||
);
|
||||
String filePath, {
|
||||
@visibleForTesting ProcessManager processManager = const LocalProcessManager(),
|
||||
}) async {
|
||||
final io.ProcessResult result = await processManager.run(<String>[
|
||||
'file',
|
||||
'--mime-type',
|
||||
'-b', // is binary
|
||||
filePath,
|
||||
]);
|
||||
return (result.stdout as String).contains('application/x-mach-binary');
|
||||
}
|
||||
|
||||
/// Check if the binary has the expected entitlements.
|
||||
Future<bool> hasExpectedEntitlements(
|
||||
String binaryPath,
|
||||
String flutterRoot,
|
||||
{@visibleForTesting ProcessManager processManager = const LocalProcessManager()}
|
||||
) async {
|
||||
final io.ProcessResult entitlementResult = await processManager.run(
|
||||
<String>[
|
||||
'codesign',
|
||||
'--display',
|
||||
'--entitlements',
|
||||
':-',
|
||||
binaryPath,
|
||||
],
|
||||
);
|
||||
String flutterRoot, {
|
||||
@visibleForTesting ProcessManager processManager = const LocalProcessManager(),
|
||||
}) async {
|
||||
final io.ProcessResult entitlementResult = await processManager.run(<String>[
|
||||
'codesign',
|
||||
'--display',
|
||||
'--entitlements',
|
||||
':-',
|
||||
binaryPath,
|
||||
]);
|
||||
|
||||
if (entitlementResult.exitCode != 0) {
|
||||
print(
|
||||
@@ -373,8 +361,7 @@ Future<bool> hasExpectedEntitlements(
|
||||
bool passes = true;
|
||||
final String output = entitlementResult.stdout as String;
|
||||
for (final String entitlement in expectedEntitlements) {
|
||||
final bool entitlementExpected =
|
||||
binariesWithEntitlements(flutterRoot).contains(binaryPath);
|
||||
final bool entitlementExpected = binariesWithEntitlements(flutterRoot).contains(binaryPath);
|
||||
if (output.contains(entitlement) != entitlementExpected) {
|
||||
print(
|
||||
'File "$binaryPath" ${entitlementExpected ? 'does not have expected' : 'has unexpected'} '
|
||||
|
||||
@@ -3,7 +3,19 @@
|
||||
// found in the LICENSE file.
|
||||
|
||||
import 'dart:convert';
|
||||
import 'dart:io' show Directory, File, FileSystemEntity, HttpClient, HttpClientRequest, HttpClientResponse, Platform, Process, RawSocket, SocketDirection, SocketException;
|
||||
import 'dart:io'
|
||||
show
|
||||
Directory,
|
||||
File,
|
||||
FileSystemEntity,
|
||||
HttpClient,
|
||||
HttpClientRequest,
|
||||
HttpClientResponse,
|
||||
Platform,
|
||||
Process,
|
||||
RawSocket,
|
||||
SocketDirection,
|
||||
SocketException;
|
||||
import 'dart:math' as math;
|
||||
import 'package:file/local.dart';
|
||||
import 'package:path/path.dart' as path;
|
||||
@@ -16,7 +28,6 @@ import '../utils.dart';
|
||||
typedef ShardRunner = Future<void> Function();
|
||||
|
||||
class WebTestsSuite {
|
||||
|
||||
WebTestsSuite(this.flutterTestArgs);
|
||||
|
||||
/// Tests that we don't run on Web.
|
||||
@@ -59,15 +70,15 @@ class WebTestsSuite {
|
||||
'test/rendering/platform_view_test.dart',
|
||||
],
|
||||
'skwasm': <String>[
|
||||
// These tests are not compilable on the web due to dependencies on
|
||||
// VM-specific functionality.
|
||||
'test/services/message_codecs_vm_test.dart',
|
||||
'test/examples/sector_layout_test.dart',
|
||||
// These tests are not compilable on the web due to dependencies on
|
||||
// VM-specific functionality.
|
||||
'test/services/message_codecs_vm_test.dart',
|
||||
'test/examples/sector_layout_test.dart',
|
||||
|
||||
// These tests are broken and need to be fixed.
|
||||
// TODO(jacksongardner): https://github.com/flutter/flutter/issues/71604
|
||||
'test/material/text_field_test.dart',
|
||||
'test/widgets/performance_overlay_test.dart',
|
||||
// These tests are broken and need to be fixed.
|
||||
// TODO(jacksongardner): https://github.com/flutter/flutter/issues/71604
|
||||
'test/material/text_field_test.dart',
|
||||
'test/widgets/performance_overlay_test.dart',
|
||||
],
|
||||
};
|
||||
|
||||
@@ -80,10 +91,10 @@ class WebTestsSuite {
|
||||
/// and make sure it runs _all_ shards.
|
||||
///
|
||||
/// The last shard also runs the Web plugin tests.
|
||||
int get webShardCount => Platform.environment.containsKey('WEB_SHARD_COUNT')
|
||||
? int.parse(Platform.environment['WEB_SHARD_COUNT']!)
|
||||
: 8;
|
||||
|
||||
int get webShardCount =>
|
||||
Platform.environment.containsKey('WEB_SHARD_COUNT')
|
||||
? int.parse(Platform.environment['WEB_SHARD_COUNT']!)
|
||||
: 8;
|
||||
|
||||
static const List<String> _kAllBuildModes = <String>['debug', 'profile', 'release'];
|
||||
|
||||
@@ -91,7 +102,6 @@ class WebTestsSuite {
|
||||
|
||||
/// Coarse-grained integration tests running on the Web.
|
||||
Future<void> webLongRunningTestsRunner() async {
|
||||
|
||||
final String engineVersionFile = path.join(flutterRoot, 'bin', 'internal', 'engine.version');
|
||||
final String engineRealmFile = path.join(flutterRoot, 'bin', 'internal', 'engine.realm');
|
||||
final String engineVersion = File(engineVersionFile).readAsStringSync().trim();
|
||||
@@ -144,8 +154,13 @@ class WebTestsSuite {
|
||||
|
||||
// This test doesn't do anything interesting w.r.t. rendering, so we don't run the full build mode x renderer matrix.
|
||||
() => _runWebE2eTest('profile_diagnostics_integration', buildMode: 'debug', renderer: 'html'),
|
||||
() => _runWebE2eTest('profile_diagnostics_integration', buildMode: 'profile', renderer: 'canvaskit'),
|
||||
() => _runWebE2eTest('profile_diagnostics_integration', buildMode: 'release', renderer: 'html'),
|
||||
() => _runWebE2eTest(
|
||||
'profile_diagnostics_integration',
|
||||
buildMode: 'profile',
|
||||
renderer: 'canvaskit',
|
||||
),
|
||||
() =>
|
||||
_runWebE2eTest('profile_diagnostics_integration', buildMode: 'release', renderer: 'html'),
|
||||
|
||||
// This test is only known to work in debug mode.
|
||||
() => _runWebE2eTest('scroll_wheel_integration', buildMode: 'debug', renderer: 'html'),
|
||||
@@ -162,14 +177,30 @@ class WebTestsSuite {
|
||||
() => _runWebE2eTest('url_strategy_integration', buildMode: 'release', renderer: 'html'),
|
||||
|
||||
// This test doesn't do anything interesting w.r.t. rendering, so we don't run the full build mode x renderer matrix.
|
||||
() => _runWebE2eTest('capabilities_integration_canvaskit', buildMode: 'debug', renderer: 'auto'),
|
||||
() => _runWebE2eTest('capabilities_integration_canvaskit', buildMode: 'profile', renderer: 'canvaskit'),
|
||||
() => _runWebE2eTest(
|
||||
'capabilities_integration_canvaskit',
|
||||
buildMode: 'debug',
|
||||
renderer: 'auto',
|
||||
),
|
||||
() => _runWebE2eTest(
|
||||
'capabilities_integration_canvaskit',
|
||||
buildMode: 'profile',
|
||||
renderer: 'canvaskit',
|
||||
),
|
||||
() => _runWebE2eTest('capabilities_integration_html', buildMode: 'release', renderer: 'html'),
|
||||
|
||||
// This test doesn't do anything interesting w.r.t. rendering, so we don't run the full build mode x renderer matrix.
|
||||
// CacheWidth and CacheHeight are only currently supported in CanvasKit mode, so we don't run the test in HTML mode.
|
||||
() => _runWebE2eTest('cache_width_cache_height_integration', buildMode: 'debug', renderer: 'auto'),
|
||||
() => _runWebE2eTest('cache_width_cache_height_integration', buildMode: 'profile', renderer: 'canvaskit'),
|
||||
() => _runWebE2eTest(
|
||||
'cache_width_cache_height_integration',
|
||||
buildMode: 'debug',
|
||||
renderer: 'auto',
|
||||
),
|
||||
() => _runWebE2eTest(
|
||||
'cache_width_cache_height_integration',
|
||||
buildMode: 'profile',
|
||||
renderer: 'canvaskit',
|
||||
),
|
||||
|
||||
() => _runWebTreeshakeTest(),
|
||||
|
||||
@@ -185,17 +216,45 @@ class WebTestsSuite {
|
||||
() => _runGalleryE2eWebTest('profile', canvasKit: true),
|
||||
() => _runGalleryE2eWebTest('release'),
|
||||
() => _runGalleryE2eWebTest('release', canvasKit: true),
|
||||
() => runWebServiceWorkerTest(headless: true, testType: ServiceWorkerTestType.withoutFlutterJs),
|
||||
() =>
|
||||
runWebServiceWorkerTest(headless: true, testType: ServiceWorkerTestType.withoutFlutterJs),
|
||||
() => runWebServiceWorkerTest(headless: true, testType: ServiceWorkerTestType.withFlutterJs),
|
||||
() => runWebServiceWorkerTest(headless: true, testType: ServiceWorkerTestType.withFlutterJsShort),
|
||||
() => runWebServiceWorkerTest(headless: true, testType: ServiceWorkerTestType.withFlutterJsEntrypointLoadedEvent),
|
||||
() => runWebServiceWorkerTest(headless: true, testType: ServiceWorkerTestType.withFlutterJsTrustedTypesOn),
|
||||
() => runWebServiceWorkerTest(headless: true, testType: ServiceWorkerTestType.withFlutterJsNonceOn),
|
||||
() => runWebServiceWorkerTestWithCachingResources(headless: true, testType: ServiceWorkerTestType.withoutFlutterJs),
|
||||
() => runWebServiceWorkerTestWithCachingResources(headless: true, testType: ServiceWorkerTestType.withFlutterJs),
|
||||
() => runWebServiceWorkerTestWithCachingResources(headless: true, testType: ServiceWorkerTestType.withFlutterJsShort),
|
||||
() => runWebServiceWorkerTestWithCachingResources(headless: true, testType: ServiceWorkerTestType.withFlutterJsEntrypointLoadedEvent),
|
||||
() => runWebServiceWorkerTestWithCachingResources(headless: true, testType: ServiceWorkerTestType.withFlutterJsTrustedTypesOn),
|
||||
() => runWebServiceWorkerTest(
|
||||
headless: true,
|
||||
testType: ServiceWorkerTestType.withFlutterJsShort,
|
||||
),
|
||||
() => runWebServiceWorkerTest(
|
||||
headless: true,
|
||||
testType: ServiceWorkerTestType.withFlutterJsEntrypointLoadedEvent,
|
||||
),
|
||||
() => runWebServiceWorkerTest(
|
||||
headless: true,
|
||||
testType: ServiceWorkerTestType.withFlutterJsTrustedTypesOn,
|
||||
),
|
||||
() => runWebServiceWorkerTest(
|
||||
headless: true,
|
||||
testType: ServiceWorkerTestType.withFlutterJsNonceOn,
|
||||
),
|
||||
() => runWebServiceWorkerTestWithCachingResources(
|
||||
headless: true,
|
||||
testType: ServiceWorkerTestType.withoutFlutterJs,
|
||||
),
|
||||
() => runWebServiceWorkerTestWithCachingResources(
|
||||
headless: true,
|
||||
testType: ServiceWorkerTestType.withFlutterJs,
|
||||
),
|
||||
() => runWebServiceWorkerTestWithCachingResources(
|
||||
headless: true,
|
||||
testType: ServiceWorkerTestType.withFlutterJsShort,
|
||||
),
|
||||
() => runWebServiceWorkerTestWithCachingResources(
|
||||
headless: true,
|
||||
testType: ServiceWorkerTestType.withFlutterJsEntrypointLoadedEvent,
|
||||
),
|
||||
() => runWebServiceWorkerTestWithCachingResources(
|
||||
headless: true,
|
||||
testType: ServiceWorkerTestType.withFlutterJsTrustedTypesOn,
|
||||
),
|
||||
() => runWebServiceWorkerTestWithGeneratedEntrypoint(headless: true),
|
||||
() => runWebServiceWorkerTestWithBlockedServiceWorkers(headless: true),
|
||||
() => runWebServiceWorkerTestWithCustomServiceWorkerVersion(headless: true),
|
||||
@@ -206,23 +265,25 @@ class WebTestsSuite {
|
||||
() => _runWebDebugTest('lib/stack_trace.dart'),
|
||||
() => _runWebDebugTest('lib/framework_stack_trace.dart'),
|
||||
() => _runWebDebugTest('lib/web_directory_loading.dart'),
|
||||
() => _runWebDebugTest('lib/web_resources_cdn_test.dart',
|
||||
additionalArguments: <String>[
|
||||
'--dart-define=TEST_FLUTTER_ENGINE_VERSION=$engineVersion',
|
||||
]),
|
||||
() => _runWebDebugTest(
|
||||
'lib/web_resources_cdn_test.dart',
|
||||
additionalArguments: <String>['--dart-define=TEST_FLUTTER_ENGINE_VERSION=$engineVersion'],
|
||||
),
|
||||
() => _runWebDebugTest('test/test.dart'),
|
||||
() => _runWebDebugTest('lib/null_safe_main.dart'),
|
||||
() => _runWebDebugTest('lib/web_define_loading.dart',
|
||||
() => _runWebDebugTest(
|
||||
'lib/web_define_loading.dart',
|
||||
additionalArguments: <String>[
|
||||
'--dart-define=test.valueA=Example,A',
|
||||
'--dart-define=test.valueB=Value',
|
||||
]
|
||||
],
|
||||
),
|
||||
() => _runWebReleaseTest('lib/web_define_loading.dart',
|
||||
() => _runWebReleaseTest(
|
||||
'lib/web_define_loading.dart',
|
||||
additionalArguments: <String>[
|
||||
'--dart-define=test.valueA=Example,A',
|
||||
'--dart-define=test.valueB=Value',
|
||||
]
|
||||
],
|
||||
),
|
||||
() => _runWebDebugTest('lib/assertion_test.dart'),
|
||||
() => _runWebReleaseTest('lib/assertion_test.dart'),
|
||||
@@ -295,15 +356,11 @@ class WebTestsSuite {
|
||||
String expectResponseFileContent = '',
|
||||
}) async {
|
||||
printProgress('${green}Running integration tests $target in $buildMode mode.$reset');
|
||||
await runCommand(
|
||||
flutter,
|
||||
<String>[ 'clean' ],
|
||||
workingDirectory: testAppDirectory,
|
||||
);
|
||||
await runCommand(flutter, <String>['clean'], workingDirectory: testAppDirectory);
|
||||
// This must match the testOutputsDirectory defined in flutter_driver's driver/common.dart.
|
||||
final String driverOutputPath = Platform.environment['FLUTTER_TEST_OUTPUTS_DIR'] ?? path.join(testAppDirectory, 'build');
|
||||
final String responseFile =
|
||||
path.join(driverOutputPath, 'integration_response_data.json');
|
||||
final String driverOutputPath =
|
||||
Platform.environment['FLUTTER_TEST_OUTPUTS_DIR'] ?? path.join(testAppDirectory, 'build');
|
||||
final String responseFile = path.join(driverOutputPath, 'integration_response_data.json');
|
||||
if (File(responseFile).existsSync()) {
|
||||
File(responseFile).deleteSync();
|
||||
}
|
||||
@@ -335,13 +392,10 @@ class WebTestsSuite {
|
||||
'--dart-define=FLUTTER_WEB_USE_SKIA=false',
|
||||
'--dart-define=FLUTTER_WEB_USE_SKWASM=false',
|
||||
],
|
||||
|
||||
],
|
||||
expectNonZeroExit: expectFailure,
|
||||
workingDirectory: testAppDirectory,
|
||||
environment: <String, String>{
|
||||
'FLUTTER_WEB': 'true',
|
||||
},
|
||||
environment: <String, String>{'FLUTTER_WEB': 'true'},
|
||||
removeLine: (String line) {
|
||||
if (!silenceBrowserOutput) {
|
||||
return false;
|
||||
@@ -374,25 +428,19 @@ class WebTestsSuite {
|
||||
// The app is compiled in `--profile` mode to prevent the compiler from
|
||||
// minifying the symbols.
|
||||
Future<void> _runWebTreeshakeTest() async {
|
||||
final String testAppDirectory = path.join(flutterRoot, 'dev', 'integration_tests', 'web_e2e_tests');
|
||||
final String target = path.join('lib', 'treeshaking_main.dart');
|
||||
await runCommand(
|
||||
flutter,
|
||||
<String>[ 'clean' ],
|
||||
workingDirectory: testAppDirectory,
|
||||
final String testAppDirectory = path.join(
|
||||
flutterRoot,
|
||||
'dev',
|
||||
'integration_tests',
|
||||
'web_e2e_tests',
|
||||
);
|
||||
final String target = path.join('lib', 'treeshaking_main.dart');
|
||||
await runCommand(flutter, <String>['clean'], workingDirectory: testAppDirectory);
|
||||
await runCommand(
|
||||
flutter,
|
||||
<String>[
|
||||
'build',
|
||||
'web',
|
||||
'--target=$target',
|
||||
'--profile',
|
||||
],
|
||||
<String>['build', 'web', '--target=$target', '--profile'],
|
||||
workingDirectory: testAppDirectory,
|
||||
environment: <String, String>{
|
||||
'FLUTTER_WEB': 'true',
|
||||
},
|
||||
environment: <String, String>{'FLUTTER_WEB': 'true'},
|
||||
);
|
||||
|
||||
final File mainDartJs = File(path.join(testAppDirectory, 'build', 'web', 'main.dart.js'));
|
||||
@@ -426,7 +474,7 @@ class WebTestsSuite {
|
||||
if (count > kMaxExpectedDebugFillProperties) {
|
||||
throw Exception(
|
||||
'Too many occurrences of "$word" in compiled JavaScript.\n'
|
||||
'Expected no more than $kMaxExpectedDebugFillProperties, but found $count.'
|
||||
'Expected no more than $kMaxExpectedDebugFillProperties, but found $count.',
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -440,30 +488,32 @@ class WebTestsSuite {
|
||||
///
|
||||
/// The test is written using `package:integration_test` (despite the "e2e" in
|
||||
/// the name, which is there for historic reasons).
|
||||
Future<void> _runGalleryE2eWebTest(String buildMode, { bool canvasKit = false }) async {
|
||||
Future<void> _runGalleryE2eWebTest(String buildMode, {bool canvasKit = false}) async {
|
||||
// TODO(yjbanov): this is temporarily disabled due to https://github.com/flutter/flutter/issues/147731
|
||||
if (buildMode == 'debug' && canvasKit) {
|
||||
print('SKIPPED: Gallery e2e web test in debug CanvasKit mode due to https://github.com/flutter/flutter/issues/147731');
|
||||
print(
|
||||
'SKIPPED: Gallery e2e web test in debug CanvasKit mode due to https://github.com/flutter/flutter/issues/147731',
|
||||
);
|
||||
return;
|
||||
}
|
||||
printProgress('${green}Running flutter_gallery integration test in --$buildMode using ${canvasKit ? 'CanvasKit' : 'HTML'} renderer.$reset');
|
||||
final String testAppDirectory = path.join(flutterRoot, 'dev', 'integration_tests', 'flutter_gallery');
|
||||
await runCommand(
|
||||
flutter,
|
||||
<String>[ 'clean' ],
|
||||
workingDirectory: testAppDirectory,
|
||||
printProgress(
|
||||
'${green}Running flutter_gallery integration test in --$buildMode using ${canvasKit ? 'CanvasKit' : 'HTML'} renderer.$reset',
|
||||
);
|
||||
final String testAppDirectory = path.join(
|
||||
flutterRoot,
|
||||
'dev',
|
||||
'integration_tests',
|
||||
'flutter_gallery',
|
||||
);
|
||||
await runCommand(flutter, <String>['clean'], workingDirectory: testAppDirectory);
|
||||
await runCommand(
|
||||
flutter,
|
||||
<String>[
|
||||
...flutterTestArgs,
|
||||
'drive',
|
||||
if (canvasKit)
|
||||
'--dart-define=FLUTTER_WEB_USE_SKIA=true',
|
||||
if (!canvasKit)
|
||||
'--dart-define=FLUTTER_WEB_USE_SKIA=false',
|
||||
if (!canvasKit)
|
||||
'--dart-define=FLUTTER_WEB_AUTO_DETECT=false',
|
||||
if (canvasKit) '--dart-define=FLUTTER_WEB_USE_SKIA=true',
|
||||
if (!canvasKit) '--dart-define=FLUTTER_WEB_USE_SKIA=false',
|
||||
if (!canvasKit) '--dart-define=FLUTTER_WEB_AUTO_DETECT=false',
|
||||
'--driver=test_driver/transitions_perf_e2e_test.dart',
|
||||
'--target=test_driver/transitions_perf_e2e.dart',
|
||||
'--browser-name=chrome',
|
||||
@@ -472,9 +522,7 @@ class WebTestsSuite {
|
||||
'--$buildMode',
|
||||
],
|
||||
workingDirectory: testAppDirectory,
|
||||
environment: <String, String>{
|
||||
'FLUTTER_WEB': 'true',
|
||||
},
|
||||
environment: <String, String>{'FLUTTER_WEB': 'true'},
|
||||
);
|
||||
}
|
||||
|
||||
@@ -483,24 +531,12 @@ class WebTestsSuite {
|
||||
final String appBuildDirectory = path.join(testAppDirectory, 'build', 'web');
|
||||
|
||||
// Build the app.
|
||||
await runCommand(flutter, <String>['clean'], workingDirectory: testAppDirectory);
|
||||
await runCommand(
|
||||
flutter,
|
||||
<String>[ 'clean' ],
|
||||
<String>['build', 'web', '--$buildMode', '-t', entrypoint],
|
||||
workingDirectory: testAppDirectory,
|
||||
);
|
||||
await runCommand(
|
||||
flutter,
|
||||
<String>[
|
||||
'build',
|
||||
'web',
|
||||
'--$buildMode',
|
||||
'-t',
|
||||
entrypoint,
|
||||
],
|
||||
workingDirectory: testAppDirectory,
|
||||
environment: <String, String>{
|
||||
'FLUTTER_WEB': 'true',
|
||||
},
|
||||
environment: <String, String>{'FLUTTER_WEB': 'true'},
|
||||
);
|
||||
|
||||
// Run the app.
|
||||
@@ -514,24 +550,20 @@ class WebTestsSuite {
|
||||
);
|
||||
|
||||
if (!result.contains('--- TEST SUCCEEDED ---')) {
|
||||
foundError(<String>[
|
||||
result,
|
||||
'${red}Web stack trace integration test failed.$reset',
|
||||
]);
|
||||
foundError(<String>[result, '${red}Web stack trace integration test failed.$reset']);
|
||||
}
|
||||
}
|
||||
|
||||
/// Debug mode is special because `flutter build web` doesn't build in debug mode.
|
||||
///
|
||||
/// Instead, we use `flutter run --debug` and sniff out the standard output.
|
||||
Future<void> _runWebDebugTest(String target, {
|
||||
List<String> additionalArguments = const<String>[],
|
||||
Future<void> _runWebDebugTest(
|
||||
String target, {
|
||||
List<String> additionalArguments = const <String>[],
|
||||
}) async {
|
||||
final String testAppDirectory = path.join(flutterRoot, 'dev', 'integration_tests', 'web');
|
||||
bool success = false;
|
||||
final Map<String, String> environment = <String, String>{
|
||||
'FLUTTER_WEB': 'true',
|
||||
};
|
||||
final Map<String, String> environment = <String, String>{'FLUTTER_WEB': 'true'};
|
||||
adjustEnvironmentToEnableFlutterAsserts(environment);
|
||||
final CommandResult result = await runCommand(
|
||||
flutter,
|
||||
@@ -576,18 +608,15 @@ class WebTestsSuite {
|
||||
}
|
||||
|
||||
/// Run a web integration test in release mode.
|
||||
Future<void> _runWebReleaseTest(String target, {
|
||||
List<String> additionalArguments = const<String>[],
|
||||
Future<void> _runWebReleaseTest(
|
||||
String target, {
|
||||
List<String> additionalArguments = const <String>[],
|
||||
}) async {
|
||||
final String testAppDirectory = path.join(flutterRoot, 'dev', 'integration_tests', 'web');
|
||||
final String appBuildDirectory = path.join(testAppDirectory, 'build', 'web');
|
||||
|
||||
// Build the app.
|
||||
await runCommand(
|
||||
flutter,
|
||||
<String>[ 'clean' ],
|
||||
workingDirectory: testAppDirectory,
|
||||
);
|
||||
await runCommand(flutter, <String>['clean'], workingDirectory: testAppDirectory);
|
||||
await runCommand(
|
||||
flutter,
|
||||
<String>[
|
||||
@@ -600,9 +629,7 @@ class WebTestsSuite {
|
||||
target,
|
||||
],
|
||||
workingDirectory: testAppDirectory,
|
||||
environment: <String, String>{
|
||||
'FLUTTER_WEB': 'true',
|
||||
},
|
||||
environment: <String, String>{'FLUTTER_WEB': 'true'},
|
||||
);
|
||||
|
||||
// Run the app.
|
||||
@@ -616,35 +643,43 @@ class WebTestsSuite {
|
||||
);
|
||||
|
||||
if (!result.contains('--- TEST SUCCEEDED ---')) {
|
||||
foundError(<String>[
|
||||
result,
|
||||
'${red}Web release mode test failed.$reset',
|
||||
]);
|
||||
foundError(<String>[result, '${red}Web release mode test failed.$reset']);
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> _runWebUnitTests(String webRenderer, bool useWasm) async {
|
||||
final Map<String, ShardRunner> subshards = <String, ShardRunner>{};
|
||||
|
||||
final Directory flutterPackageDirectory = Directory(path.join(flutterRoot, 'packages', 'flutter'));
|
||||
final Directory flutterPackageTestDirectory = Directory(path.join(flutterPackageDirectory.path, 'test'));
|
||||
final Directory flutterPackageDirectory = Directory(
|
||||
path.join(flutterRoot, 'packages', 'flutter'),
|
||||
);
|
||||
final Directory flutterPackageTestDirectory = Directory(
|
||||
path.join(flutterPackageDirectory.path, 'test'),
|
||||
);
|
||||
|
||||
final List<String> allTests = flutterPackageTestDirectory
|
||||
.listSync()
|
||||
.whereType<Directory>()
|
||||
.expand((Directory directory) => directory
|
||||
.listSync(recursive: true)
|
||||
.where((FileSystemEntity entity) => entity.path.endsWith('_test.dart'))
|
||||
)
|
||||
.whereType<File>()
|
||||
.map<String>((File file) => path.relative(file.path, from: flutterPackageDirectory.path))
|
||||
.where((String filePath) => !kWebTestFileKnownFailures[webRenderer]!.contains(path.split(filePath).join('/')))
|
||||
.toList()
|
||||
// Finally we shuffle the list because we want the average cost per file to be uniformly
|
||||
// distributed. If the list is not sorted then different shards and batches may have
|
||||
// very different characteristics.
|
||||
// We use a constant seed for repeatability.
|
||||
..shuffle(math.Random(0));
|
||||
final List<String> allTests =
|
||||
flutterPackageTestDirectory
|
||||
.listSync()
|
||||
.whereType<Directory>()
|
||||
.expand(
|
||||
(Directory directory) => directory
|
||||
.listSync(recursive: true)
|
||||
.where((FileSystemEntity entity) => entity.path.endsWith('_test.dart')),
|
||||
)
|
||||
.whereType<File>()
|
||||
.map<String>(
|
||||
(File file) => path.relative(file.path, from: flutterPackageDirectory.path),
|
||||
)
|
||||
.where(
|
||||
(String filePath) =>
|
||||
!kWebTestFileKnownFailures[webRenderer]!.contains(path.split(filePath).join('/')),
|
||||
)
|
||||
.toList()
|
||||
// Finally we shuffle the list because we want the average cost per file to be uniformly
|
||||
// distributed. If the list is not sorted then different shards and batches may have
|
||||
// very different characteristics.
|
||||
// We use a constant seed for repeatability.
|
||||
..shuffle(math.Random(0));
|
||||
|
||||
assert(webShardCount >= 1);
|
||||
final int testsPerShard = (allTests.length / webShardCount).ceil();
|
||||
@@ -652,15 +687,13 @@ class WebTestsSuite {
|
||||
|
||||
// This for loop computes all but the last shard.
|
||||
for (int index = 0; index < webShardCount - 1; index += 1) {
|
||||
subshards['$index'] = () => _runFlutterWebTest(
|
||||
webRenderer,
|
||||
flutterPackageDirectory.path,
|
||||
allTests.sublist(
|
||||
index * testsPerShard,
|
||||
(index + 1) * testsPerShard,
|
||||
),
|
||||
useWasm,
|
||||
);
|
||||
subshards['$index'] =
|
||||
() => _runFlutterWebTest(
|
||||
webRenderer,
|
||||
flutterPackageDirectory.path,
|
||||
allTests.sublist(index * testsPerShard, (index + 1) * testsPerShard),
|
||||
useWasm,
|
||||
);
|
||||
}
|
||||
|
||||
// The last shard also runs the flutter_web_plugins tests.
|
||||
@@ -671,10 +704,7 @@ class WebTestsSuite {
|
||||
await _runFlutterWebTest(
|
||||
webRenderer,
|
||||
flutterPackageDirectory.path,
|
||||
allTests.sublist(
|
||||
(webShardCount - 1) * testsPerShard,
|
||||
allTests.length,
|
||||
),
|
||||
allTests.sublist((webShardCount - 1) * testsPerShard, allTests.length),
|
||||
useWasm,
|
||||
);
|
||||
await _runFlutterWebTest(
|
||||
@@ -734,9 +764,7 @@ class WebTestsSuite {
|
||||
...tests,
|
||||
],
|
||||
workingDirectory: workingDirectory,
|
||||
environment: <String, String>{
|
||||
'FLUTTER_WEB': 'true',
|
||||
},
|
||||
environment: <String, String>{'FLUTTER_WEB': 'true'},
|
||||
);
|
||||
// metriciFile is a transitional file that needs to be deleted once it is parsed.
|
||||
// TODO(godofredoc): Ensure metricFile is parsed and aggregated before deleting.
|
||||
@@ -794,7 +822,8 @@ class WebTestsSuite {
|
||||
final HttpClientRequest request = await client.getUrl(chromeDriverUrl);
|
||||
final HttpClientResponse response = await request.close();
|
||||
final String responseString = await response.transform(utf8.decoder).join();
|
||||
final Map<String, dynamic> webDriverStatus = json.decode(responseString) as Map<String, dynamic>;
|
||||
final Map<String, dynamic> webDriverStatus =
|
||||
json.decode(responseString) as Map<String, dynamic>;
|
||||
client.close();
|
||||
final bool webDriverReady = (webDriverStatus['value'] as Map<String, dynamic>)['ready'] as bool;
|
||||
if (!webDriverReady) {
|
||||
|
||||
Reference in New Issue
Block a user