diff --git a/packages/flutter_tools/test/integration.shard/android_gradle_print_app_link_domains_test.dart b/packages/flutter_tools/test/integration.shard/android_gradle_print_app_link_domains_test.dart index eed136cc72..2533b264c5 100644 --- a/packages/flutter_tools/test/integration.shard/android_gradle_print_app_link_domains_test.dart +++ b/packages/flutter_tools/test/integration.shard/android_gradle_print_app_link_domains_test.dart @@ -147,7 +147,7 @@ void main() { tempDir.path, '--project-name=testapp', ], workingDirectory: tempDir.path); - expect(result.exitCode, 0); + expect(result, const ProcessResultMatcher()); // Adds intent filters for app links final String androidManifestPath = fileSystem.path.join(tempDir.path, 'android', 'app', 'src', 'main', 'AndroidManifest.xml'); final io.File androidManifestFile = io.File(androidManifestPath); @@ -166,7 +166,7 @@ void main() { 'apk', '--config-only', ], workingDirectory: tempDir.path); - expect(result.exitCode, 0); + expect(result, const ProcessResultMatcher()); final Directory androidApp = tempDir.childDirectory('android'); result = await processManager.run([ @@ -176,7 +176,7 @@ void main() { 'printDebugAppLinkDomains', ], workingDirectory: androidApp.path); - expect(result.exitCode, 0); + expect(result, const ProcessResultMatcher()); const List expectedLines = [ // Should only pick up the pure and hybrid intent filters diff --git a/packages/flutter_tools/test/integration.shard/android_gradle_print_application_id_test.dart b/packages/flutter_tools/test/integration.shard/android_gradle_print_application_id_test.dart index 563344660e..82ec3c84f4 100644 --- a/packages/flutter_tools/test/integration.shard/android_gradle_print_application_id_test.dart +++ b/packages/flutter_tools/test/integration.shard/android_gradle_print_application_id_test.dart @@ -35,7 +35,7 @@ void main() { tempDir.path, '--project-name=testapp', ], workingDirectory: tempDir.path); - expect(result.exitCode, 0); + expect(result, const ProcessResultMatcher()); // Ensure that gradle files exists from templates. result = await processManager.run([ flutterBin, @@ -43,7 +43,7 @@ void main() { 'apk', '--config-only', ], workingDirectory: tempDir.path); - expect(result.exitCode, 0); + expect(result, const ProcessResultMatcher()); final Directory androidApp = tempDir.childDirectory('android'); result = await processManager.run([ @@ -53,7 +53,7 @@ void main() { 'printDebugApplicationId', ], workingDirectory: androidApp.path); // Verify that gradlew has a javaVersion task. - expect(result.exitCode, 0); + expect(result, const ProcessResultMatcher()); // Verify the format is a number on its own line. const List expectedLines = [ 'ApplicationId: com.example.testapp', diff --git a/packages/flutter_tools/test/integration.shard/build_macos_config_only_test.dart b/packages/flutter_tools/test/integration.shard/build_macos_config_only_test.dart index cb27c40256..6fd271c55a 100644 --- a/packages/flutter_tools/test/integration.shard/build_macos_config_only_test.dart +++ b/packages/flutter_tools/test/integration.shard/build_macos_config_only_test.dart @@ -36,13 +36,7 @@ void main() { ]; final ProcessResult firstRunResult = await processManager.run(buildCommand, workingDirectory: workingDirectory); - printOnFailure('Output of flutter build macOS:'); - final String firstRunStdout = firstRunResult.stdout.toString(); - printOnFailure('First run stdout: $firstRunStdout'); - printOnFailure('First run stderr: ${firstRunResult.stderr}'); - - expect(firstRunResult.exitCode, 0); - expect(firstRunStdout, contains('Running pod install')); + expect(firstRunResult, const ProcessResultMatcher(stdoutPattern: 'Running pod install')); final File generatedConfig = fileSystem.file(fileSystem.path.join( workingDirectory, @@ -73,10 +67,7 @@ void main() { // Run again with no changes. final ProcessResult secondRunResult = await processManager.run(buildCommand, workingDirectory: workingDirectory); - final String secondRunStdout = secondRunResult.stdout.toString(); - printOnFailure('Second run stdout: $secondRunStdout'); - printOnFailure('Second run stderr: ${secondRunResult.stderr}'); - expect(secondRunResult.exitCode, 0); + expect(secondRunResult, const ProcessResultMatcher()); }, skip: !platform.isMacOS); // [intended] macOS builds only work on macos. } diff --git a/packages/flutter_tools/test/integration.shard/command_output_test.dart b/packages/flutter_tools/test/integration.shard/command_output_test.dart index e693ff1fe5..7b72ef6764 100644 --- a/packages/flutter_tools/test/integration.shard/command_output_test.dart +++ b/packages/flutter_tools/test/integration.shard/command_output_test.dart @@ -158,8 +158,10 @@ void main() { '--debug-url=http://127.0.0.1:3333*/', ], workingDirectory: helloWorld); - expect(result.exitCode, 1); - expect(result.stderr, contains('Invalid `--debug-url`: http://127.0.0.1:3333*/')); + expect( + result, + const ProcessResultMatcher(exitCode: 1, stderrPattern: 'Invalid `--debug-url`: http://127.0.0.1:3333*/'), + ); }); testWithoutContext('--debug-uri is an alias for --debug-url', () async { @@ -175,8 +177,14 @@ void main() { '--debug-uri=http://127.0.0.1:3333*/', // "uri" not "url" ], workingDirectory: helloWorld); - expect(result.exitCode, 1); - expect(result.stderr, contains('Invalid `--debug-url`: http://127.0.0.1:3333*/')); // _"url"_ not "uri"! + expect( + result, + const ProcessResultMatcher( + exitCode: 1, + // _"url"_ not "uri"! + stderrPattern: 'Invalid `--debug-url`: http://127.0.0.1:3333*/', + ), + ); }); testWithoutContext('will load bootstrap script before starting', () async { @@ -211,8 +219,10 @@ void main() { '--bundle-sksl-path=foo/bar/baz.json', // This file does not exist. ], workingDirectory: helloWorld); - expect(result.exitCode, 1); - expect(result.stderr, contains('No SkSL shader bundle found at foo/bar/baz.json')); + expect(result, const ProcessResultMatcher( + exitCode: 1, + stderrPattern: 'No SkSL shader bundle found at foo/bar/baz.json'), + ); }); testWithoutContext('flutter attach does not support --release', () async { @@ -257,7 +267,7 @@ void main() { 'json', ], workingDirectory: helloWorld); - expect(result.exitCode, 0); + expect(result, const ProcessResultMatcher()); expect(result.stderr, isEmpty); }); } diff --git a/packages/flutter_tools/test/integration.shard/deferred_components_test.dart b/packages/flutter_tools/test/integration.shard/deferred_components_test.dart index 6cf038b5a0..f01ea24bf5 100644 --- a/packages/flutter_tools/test/integration.shard/deferred_components_test.dart +++ b/packages/flutter_tools/test/integration.shard/deferred_components_test.dart @@ -39,10 +39,7 @@ void main() { '--target-platform=android-arm64', ], workingDirectory: tempDir.path); - printOnFailure('stdout:\n${result.stdout}'); - printOnFailure('stderr:\n${result.stderr}'); - expect(result.exitCode, 0); - expect(result.stdout.toString(), contains('app-release.aab')); + expect(result, const ProcessResultMatcher(stdoutPattern: 'app-release.aab')); expect(result.stdout.toString(), contains('Deferred components prebuild validation passed.')); expect(result.stdout.toString(), contains('Deferred components gen_snapshot validation passed.')); @@ -106,7 +103,7 @@ void main() { expect(archive.findFile('component1/assets/flutter_assets/test_assets/asset2.txt') != null, true); expect(archive.findFile('base/assets/flutter_assets/test_assets/asset1.txt') != null, true); - expect(result.exitCode, 0); + expect(result, const ProcessResultMatcher()); }); testWithoutContext('simple build appbundle no-deferred-components succeeds', () async { @@ -121,11 +118,9 @@ void main() { '--no-deferred-components', ], workingDirectory: tempDir.path); - printOnFailure('stdout:\n${result.stdout}'); - printOnFailure('stderr:\n${result.stderr}'); - expect(result.stdout.toString().contains('app-release.aab'), true); - expect(result.stdout.toString().contains('Deferred components prebuild validation passed.'), false); - expect(result.stdout.toString().contains('Deferred components gen_snapshot validation passed.'), false); + expect(result, const ProcessResultMatcher(stdoutPattern: 'app-release.aab')); + expect(result.stdout.toString(), isNot(contains('Deferred components prebuild validation passed.'))); + expect(result.stdout.toString(), isNot(contains('Deferred components gen_snapshot validation passed.'))); final String line = result.stdout.toString() .split('\n') @@ -153,8 +148,6 @@ void main() { expect(archive.findFile('component1/assets/flutter_assets/test_assets/asset2.txt') != null, false); expect(archive.findFile('base/assets/flutter_assets/test_assets/asset2.txt') != null, true); expect(archive.findFile('base/assets/flutter_assets/test_assets/asset1.txt') != null, true); - - expect(result.exitCode, 0); }); testWithoutContext('simple build appbundle mismatched golden no-validate-deferred-components succeeds', () async { @@ -169,14 +162,13 @@ void main() { '--no-validate-deferred-components', ], workingDirectory: tempDir.path); + expect(result, const ProcessResultMatcher(stdoutPattern: 'app-release.aab')); printOnFailure('stdout:\n${result.stdout}'); printOnFailure('stderr:\n${result.stderr}'); - expect(result.stdout.toString().contains('app-release.aab'), true); - expect(result.stdout.toString().contains('Deferred components prebuild validation passed.'), false); - expect(result.stdout.toString().contains('Deferred components gen_snapshot validation passed.'), false); - - expect(result.stdout.toString().contains('New loading units were found:'), false); - expect(result.stdout.toString().contains('Previously existing loading units no longer exist:'), false); + expect(result.stdout.toString(), isNot(contains('Deferred components prebuild validation passed.'))); + expect(result.stdout.toString(), isNot(contains('Deferred components gen_snapshot validation passed.'))); + expect(result.stdout.toString(), isNot(contains('New loading units were found:'))); + expect(result.stdout.toString(), isNot(contains('Previously existing loading units no longer exist:'))); final String line = result.stdout.toString() .split('\n') @@ -202,8 +194,6 @@ void main() { expect(archive.findFile('component1/assets/flutter_assets/test_assets/asset2.txt') != null, true); expect(archive.findFile('base/assets/flutter_assets/test_assets/asset1.txt') != null, true); - - expect(result.exitCode, 0); }); testWithoutContext('simple build appbundle missing android dynamic feature module fails', () async { @@ -217,16 +207,15 @@ void main() { 'appbundle', ], workingDirectory: tempDir.path); - expect(result.stdout.toString().contains('app-release.aab'), false); - expect(result.stdout.toString().contains('Deferred components prebuild validation passed.'), false); - expect(result.stdout.toString().contains('Deferred components gen_snapshot validation passed.'), false); + expect(result, const ProcessResultMatcher(exitCode: 1, stdoutPattern: 'Newly generated android files:')); + + expect(result.stdout.toString(), isNot(contains('app-release.aab'))); + expect(result.stdout.toString(), isNot(contains('Deferred components prebuild validation passed.'))); + expect(result.stdout.toString(), isNot(contains('Deferred components gen_snapshot validation passed.'))); - expect(result.stdout.toString(), contains('Newly generated android files:')); final String pathSeparator = fileSystem.path.separator; expect(result.stdout.toString(), contains('build${pathSeparator}android_deferred_components_setup_files${pathSeparator}component1${pathSeparator}build.gradle')); expect(result.stdout.toString(), contains('build${pathSeparator}android_deferred_components_setup_files${pathSeparator}component1${pathSeparator}src${pathSeparator}main${pathSeparator}AndroidManifest.xml')); - - expect(result.exitCode, 1); }); testWithoutContext('simple build appbundle missing golden fails', () async { @@ -240,16 +229,15 @@ void main() { 'appbundle', ], workingDirectory: tempDir.path); - expect(result.stdout.toString().contains('app-release.aab'), false); - expect(result.stdout.toString().contains('Deferred components prebuild validation passed.'), true); - expect(result.stdout.toString().contains('Deferred components gen_snapshot validation passed.'), false); + expect(result, const ProcessResultMatcher(exitCode: 1)); + expect(result.stdout.toString(), isNot(contains('app-release.aab'))); + expect(result.stdout.toString(), contains('Deferred components prebuild validation passed.')); + expect(result.stdout.toString(), isNot(contains('Deferred components gen_snapshot validation passed.'))); expect(result.stdout.toString(), contains('New loading units were found:')); expect(result.stdout.toString(), contains('- package:test/deferred_library.dart')); - expect(result.stdout.toString().contains('Previously existing loading units no longer exist:'), false); - - expect(result.exitCode, 1); + expect(result.stdout.toString(), isNot(contains('Previously existing loading units no longer exist:'))); }); testWithoutContext('simple build appbundle mismatched golden fails', () async { @@ -263,9 +251,15 @@ void main() { 'appbundle', ], workingDirectory: tempDir.path); - expect(result.stdout.toString().contains('app-release.aab'), false); - expect(result.stdout.toString().contains('Deferred components prebuild validation passed.'), true); - expect(result.stdout.toString().contains('Deferred components gen_snapshot validation passed.'), false); + expect( + result, + const ProcessResultMatcher( + exitCode: 1, + stdoutPattern: 'Deferred components prebuild validation passed.', + ), + ); + expect(result.stdout.toString(), isNot(contains('app-release.aab'))); + expect(result.stdout.toString(), isNot(contains('Deferred components gen_snapshot validation passed.'))); expect(result.stdout.toString(), contains('New loading units were found:')); expect(result.stdout.toString(), contains('- package:test/deferred_library.dart')); @@ -275,6 +269,5 @@ void main() { expect(result.stdout.toString(), contains('This loading unit check will not fail again on the next build attempt')); - expect(result.exitCode, 1); }); } diff --git a/packages/flutter_tools/test/integration.shard/web_plugin_registrant_test.dart b/packages/flutter_tools/test/integration.shard/web_plugin_registrant_test.dart index 47c07e70bd..f3907b530f 100644 --- a/packages/flutter_tools/test/integration.shard/web_plugin_registrant_test.dart +++ b/packages/flutter_tools/test/integration.shard/web_plugin_registrant_test.dart @@ -18,6 +18,7 @@ import 'package:flutter_tools/src/globals.dart' as globals; import '../src/common.dart'; import '../src/context.dart'; import '../src/test_flutter_command_runner.dart'; +import 'test_utils.dart'; void main() { late Directory tempDir; @@ -275,7 +276,7 @@ Future _ensureFlutterToolsSnapshot() async { printOnFailure('Output of dart ${snapshotArgs.join(" ")}:'); printOnFailure(snapshotResult.stdout.toString()); printOnFailure(snapshotResult.stderr.toString()); - expect(snapshotResult.exitCode, 0); + expect(snapshotResult, const ProcessResultMatcher()); } Future _restoreFlutterToolsSnapshot() async { @@ -415,10 +416,7 @@ Future _analyzeEntity(FileSystemEntity target) async { args, workingDirectory: target is Directory ? target.path : target.dirname, ); - printOnFailure('Output of flutter analyze:'); - printOnFailure(exec.stdout.toString()); - printOnFailure(exec.stderr.toString()); - expect(exec.exitCode, 0); + expect(exec, const ProcessResultMatcher()); } Future _buildWebProject(Directory workingDir) async { @@ -445,17 +443,14 @@ Future _runFlutterSnapshot(List flutterCommandArgs, Directory work ); final List args = [ + globals.artifacts!.getArtifactPath(Artifact.engineDartBinary, platform: TargetPlatform.web_javascript), flutterToolsSnapshotPath, ...flutterCommandArgs ]; - final ProcessResult exec = await Process.run( - globals.artifacts!.getArtifactPath(Artifact.engineDartBinary, platform: TargetPlatform.web_javascript), + final ProcessResult exec = await globals.processManager.run( args, workingDirectory: workingDir.path, ); - printOnFailure('Output of flutter ${flutterCommandArgs.join(" ")}:'); - printOnFailure(exec.stdout.toString()); - printOnFailure(exec.stderr.toString()); - expect(exec.exitCode, 0); + expect(exec, const ProcessResultMatcher()); }