From 1e6dde4eb16c27854344468d72da1d4ca9a3e487 Mon Sep 17 00:00:00 2001 From: Matan Lurey Date: Thu, 29 Aug 2024 08:35:52 -0700 Subject: [PATCH] Migrate another big chunk of the engine repo to `package:test` (flutter/engine#54853) There are almost no behavioral changes. Because `dart test` runs with assertions, and the former command does not, I had to tweak some of the engine tool tests because they would assert that there were duplicate names - but I didn't change any actual code besides the test expectations themselves/the fixtures. This is not all of the engine, but is approximately 1/3 of all imports of `package:litetest` migrated. --- engine/src/flutter/ci/pubspec.yaml | 5 +- engine/src/flutter/ci/test/format_test.dart | 38 ++--- engine/src/flutter/testing/run_tests.py | 5 +- .../build_bucket_golden_scraper/pubspec.yaml | 5 +- .../build_bucket_golden_scraper_test.dart | 6 +- .../tools/dir_contents_diff/pubspec.yaml | 3 +- .../test/dir_contents_diff_test.dart | 15 +- .../flutter/tools/engine_tool/pubspec.yaml | 2 +- .../engine_tool/test/build_command_test.dart | 37 +++-- .../engine_tool/test/entry_point_test.dart | 2 +- .../engine_tool/test/fetch_command_test.dart | 6 +- .../tools/engine_tool/test/fixtures.dart | 24 +-- .../engine_tool/test/format_command_test.dart | 2 +- .../tools/engine_tool/test/gn_test.dart | 2 +- .../tools/engine_tool/test/label_test.dart | 2 +- .../engine_tool/test/lint_command_test.dart | 3 +- .../tools/engine_tool/test/logger_test.dart | 2 +- .../engine_tool/test/phone_home_test.dart | 2 +- .../engine_tool/test/proc_utils_test.dart | 4 +- .../engine_tool/test/query_command_test.dart | 18 ++- .../engine_tool/test/run_command_test.dart | 15 +- .../engine_tool/test/test_command_test.dart | 3 +- .../engine_tool/test/typed_json_test.dart | 145 ++++++++++++------ .../flutter/tools/engine_tool/test/utils.dart | 60 ++------ .../tools/engine_tool/test/utils_test.dart | 2 +- .../engine_tool/test/worker_pool_test.dart | 2 +- .../src/flutter/tools/githooks/pubspec.yaml | 5 +- .../tools/githooks/test/githooks_test.dart | 2 +- .../src/flutter/tools/licenses/pubspec.yaml | 2 +- .../tools/licenses/test/formatter_test.dart | 2 +- .../pkg/engine_build_configs/pubspec.yaml | 5 +- .../test/build_config_loader_test.dart | 2 +- .../test/build_config_runner_test.dart | 2 +- .../test/build_config_test.dart | 2 +- .../test/ci_yaml_test.dart | 2 +- .../tools/pkg/engine_repo_tools/pubspec.yaml | 5 +- .../test/engine_repo_tools_test.dart | 44 +----- .../tools/pkg/git_repo_tools/pubspec.yaml | 5 +- .../test/git_repo_tools_test.dart | 3 +- 39 files changed, 237 insertions(+), 254 deletions(-) diff --git a/engine/src/flutter/ci/pubspec.yaml b/engine/src/flutter/ci/pubspec.yaml index 8749bff129..b86c37bb84 100644 --- a/engine/src/flutter/ci/pubspec.yaml +++ b/engine/src/flutter/ci/pubspec.yaml @@ -20,6 +20,5 @@ dependencies: process: any dev_dependencies: - async_helper: any - expect: any - litetest: any + engine_repo_tools: any + test: any diff --git a/engine/src/flutter/ci/test/format_test.dart b/engine/src/flutter/ci/test/format_test.dart index fffbba5b5a..da06a2d5f3 100644 --- a/engine/src/flutter/ci/test/format_test.dart +++ b/engine/src/flutter/ci/test/format_test.dart @@ -4,13 +4,13 @@ import 'dart:io' as io; -import 'package:litetest/litetest.dart'; +import 'package:engine_repo_tools/engine_repo_tools.dart'; import 'package:path/path.dart' as path; +import 'package:test/test.dart'; import '../bin/format.dart' as target; -final io.File script = io.File.fromUri(io.Platform.script).absolute; -final io.Directory repoDir = script.parent.parent.parent; +final io.Directory repoDir = Engine.findWithin().flutterDir; class FileContentPair { FileContentPair(this.original, this.formatted); @@ -32,22 +32,21 @@ final FileContentPair pythonContentPair = FileContentPair( "if __name__=='__main__':\n sys.exit(\nMain(sys.argv)\n)\n", "if __name__ == '__main__':\n sys.exit(Main(sys.argv))\n"); final FileContentPair whitespaceContentPair = FileContentPair( - 'int main() {\n return 0; \n}\n', - 'int main() {\n return 0;\n}\n'); + 'int main() {\n return 0; \n}\n', 'int main() {\n return 0;\n}\n'); final FileContentPair headerContentPair = FileContentPair( - [ - '#ifndef FOO_H_', - '#define FOO_H_', - '', - '#endif // FOO_H_', - ].join('\n'), - [ - '#ifndef FLUTTER_FORMAT_TEST_H_', - '#define FLUTTER_FORMAT_TEST_H_', - '', - '#endif // FLUTTER_FORMAT_TEST_H_', - '', - ].join('\n'), + [ + '#ifndef FOO_H_', + '#define FOO_H_', + '', + '#endif // FOO_H_', + ].join('\n'), + [ + '#ifndef FLUTTER_FORMAT_TEST_H_', + '#define FLUTTER_FORMAT_TEST_H_', + '', + '#endif // FLUTTER_FORMAT_TEST_H_', + '', + ].join('\n'), ); class TestFileFixture { @@ -238,7 +237,8 @@ void main() { try { fixture.gitAdd(); io.Process.runSync( - formatterPath, ['--check', 'header', '--fix'], + formatterPath, + ['--check', 'header', '--fix'], workingDirectory: repoDir.path, ); final Iterable files = fixture.getFileContents(); diff --git a/engine/src/flutter/testing/run_tests.py b/engine/src/flutter/testing/run_tests.py index 8495368460..1564da7698 100755 --- a/engine/src/flutter/testing/run_tests.py +++ b/engine/src/flutter/testing/run_tests.py @@ -966,10 +966,7 @@ def uses_package_test_runner(package): # arguments to pass to each of the packages tests. def build_dart_host_test_list(build_dir): dart_host_tests = [ - ( - os.path.join('flutter', 'ci'), - [os.path.join(BUILDROOT_DIR, 'flutter')], - ), + (os.path.join('flutter', 'ci'), []), ( os.path.join('flutter', 'flutter_frontend_server'), [ diff --git a/engine/src/flutter/tools/build_bucket_golden_scraper/pubspec.yaml b/engine/src/flutter/tools/build_bucket_golden_scraper/pubspec.yaml index 867bbe5ef5..667717300a 100644 --- a/engine/src/flutter/tools/build_bucket_golden_scraper/pubspec.yaml +++ b/engine/src/flutter/tools/build_bucket_golden_scraper/pubspec.yaml @@ -18,7 +18,4 @@ dependencies: path: any dev_dependencies: - async_helper: any - expect: any - litetest: any - smith: any + test: any diff --git a/engine/src/flutter/tools/build_bucket_golden_scraper/test/build_bucket_golden_scraper_test.dart b/engine/src/flutter/tools/build_bucket_golden_scraper/test/build_bucket_golden_scraper_test.dart index ff95e266e1..04d4065eaf 100644 --- a/engine/src/flutter/tools/build_bucket_golden_scraper/test/build_bucket_golden_scraper_test.dart +++ b/engine/src/flutter/tools/build_bucket_golden_scraper/test/build_bucket_golden_scraper_test.dart @@ -5,10 +5,10 @@ import 'dart:io' as io; import 'package:build_bucket_golden_scraper/build_bucket_golden_scraper.dart'; -import 'package:litetest/litetest.dart'; import 'package:path/path.dart' as p; +import 'package:test/test.dart'; -int main(List args) { +void main() { test('parses command-line arguments', () { // Create a fake engine directory. final io.Directory buildRoot = io.Directory.systemTemp.createTempSync('build_bucket_golden_scraper_test_engine'); @@ -69,6 +69,4 @@ iVBORw0KGgoAAAANSUhEUgAAADcAAAA3CAYAAACo29JGAAAAAXNSR0IArs4c6QAAAAlwSFlzAAALEwAA buildRoot.deleteSync(recursive: true); } }); - - return 0; } diff --git a/engine/src/flutter/tools/dir_contents_diff/pubspec.yaml b/engine/src/flutter/tools/dir_contents_diff/pubspec.yaml index b7e3ad62cc..2e51ec4e0f 100644 --- a/engine/src/flutter/tools/dir_contents_diff/pubspec.yaml +++ b/engine/src/flutter/tools/dir_contents_diff/pubspec.yaml @@ -9,5 +9,6 @@ environment: resolution: workspace dev_dependencies: - litetest: any + engine_repo_tools: any path: any + test: any diff --git a/engine/src/flutter/tools/dir_contents_diff/test/dir_contents_diff_test.dart b/engine/src/flutter/tools/dir_contents_diff/test/dir_contents_diff_test.dart index d2ed1c51ae..b8172f839d 100644 --- a/engine/src/flutter/tools/dir_contents_diff/test/dir_contents_diff_test.dart +++ b/engine/src/flutter/tools/dir_contents_diff/test/dir_contents_diff_test.dart @@ -4,12 +4,17 @@ import 'dart:io' as io; -import 'package:litetest/litetest.dart'; +import 'package:engine_repo_tools/engine_repo_tools.dart'; import 'package:path/path.dart' as p; +import 'package:test/test.dart'; void main() { // Find a path to `dir_contents_diff.dart` from the working directory. - final String pkgPath = io.File.fromUri(io.Platform.script).parent.parent.path; + final String pkgPath = p.join( + Engine.findWithin().flutterDir.path, + 'tools', + 'dir_contents_diff', + ); final String binPath = p.join( pkgPath, 'bin', @@ -44,7 +49,8 @@ void main() { }); test('lists files and diffs successfully, even with an EOF newline', () { - final String goldenPath = p.join(pkgPath, 'test', 'file_ok_eof_newline.txt'); + final String goldenPath = + p.join(pkgPath, 'test', 'file_ok_eof_newline.txt'); final String dirPath = p.join(pkgPath, 'test', 'fixtures'); final (int exitCode, String output) = runSync(goldenPath, dirPath); if (exitCode != 0) { @@ -67,7 +73,8 @@ void main() { }); test('diff fails when an unexpected file is present', () { - final String goldenPath = p.join(pkgPath, 'test', 'file_bad_unexpected.txt'); + final String goldenPath = + p.join(pkgPath, 'test', 'file_bad_unexpected.txt'); final String dirPath = p.join(pkgPath, 'test', 'fixtures'); final (int exitCode, String output) = runSync(goldenPath, dirPath); if (exitCode == 0) { diff --git a/engine/src/flutter/tools/engine_tool/pubspec.yaml b/engine/src/flutter/tools/engine_tool/pubspec.yaml index f752846118..d6b5b2a185 100644 --- a/engine/src/flutter/tools/engine_tool/pubspec.yaml +++ b/engine/src/flutter/tools/engine_tool/pubspec.yaml @@ -24,5 +24,5 @@ dependencies: process_runner: any dev_dependencies: - litetest: any process_fakes: any + test: any diff --git a/engine/src/flutter/tools/engine_tool/test/build_command_test.dart b/engine/src/flutter/tools/engine_tool/test/build_command_test.dart index aebc181c24..47f803d9a0 100644 --- a/engine/src/flutter/tools/engine_tool/test/build_command_test.dart +++ b/engine/src/flutter/tools/engine_tool/test/build_command_test.dart @@ -10,9 +10,9 @@ import 'package:engine_tool/src/build_utils.dart'; import 'package:engine_tool/src/commands/command_runner.dart'; import 'package:engine_tool/src/environment.dart'; import 'package:engine_tool/src/logger.dart'; -import 'package:litetest/litetest.dart'; import 'package:path/path.dart' as path; import 'package:platform/platform.dart'; +import 'package:test/test.dart'; import 'fixtures.dart' as fixtures; import 'utils.dart'; @@ -38,7 +38,6 @@ void main() { final Map configs = { 'linux_test_config': linuxTestConfig, - 'linux_test_config2': linuxTestConfig, 'mac_test_config': macTestConfig, 'win_test_config': winTestConfig, }; @@ -53,8 +52,9 @@ void main() { cannedProcesses: cannedProcesses, ); try { - final List result = runnableBuilds(testEnv.environment, configs, true); - expect(result.length, equals(8)); + final List result = + runnableBuilds(testEnv.environment, configs, true); + expect(result.length, equals(4)); expect(result[0].name, equals('ci/build_name')); } finally { testEnv.cleanup(); @@ -123,7 +123,7 @@ void main() { expect(testEnv.processHistory.length, greaterThanOrEqualTo(3)); expect( testEnv.processHistory[2].command, - containsStringsInOrder(['python3', 'gen/script.py']), + containsAllInOrder(['python3', 'gen/script.py']), ); } finally { testEnv.cleanup(); @@ -251,7 +251,7 @@ void main() { expect(testEnv.processHistory[0].command[0], contains(path.join('tools', 'gn'))); expect(testEnv.processHistory[0].command, - doesNotContainAny(['--rbe'])); + isNot(contains(['--rbe']))); expect(testEnv.processHistory[1].command[0], contains(path.join('ninja', 'ninja'))); } finally { @@ -278,7 +278,7 @@ void main() { expect(testEnv.processHistory[0].command[0], contains(path.join('tools', 'gn'))); expect(testEnv.processHistory[0].command, - doesNotContainAny(['--rbe'])); + isNot(contains(['--rbe']))); expect(testEnv.processHistory[1].command[0], contains(path.join('ninja', 'ninja'))); } finally { @@ -305,7 +305,10 @@ void main() { ); try { final Environment env = testEnv.environment; - expectArgumentError(() => mangleConfigName(env, 'build')); + expect( + () => mangleConfigName(env, 'build'), + throwsArgumentError, + ); } finally { testEnv.cleanup(); } @@ -316,9 +319,9 @@ void main() { cannedProcesses: cannedProcesses, ); try { - final Environment env = testEnv.environment; - expect(demangleConfigName(env, 'build'), equals('linux/build')); - expect(demangleConfigName(env, 'ci/build'), equals('ci/build')); + final Environment env = testEnv.environment; + expect(demangleConfigName(env, 'build'), equals('linux/build')); + expect(demangleConfigName(env, 'ci/build'), equals('ci/build')); } finally { testEnv.cleanup(); } @@ -453,9 +456,9 @@ void main() { test('build command gracefully handles no matched targets', () async { final List cannedProcesses = [ - CannedProcess((List command) => - command.contains('desc'), - stdout: fixtures.gnDescOutputEmpty(gnPattern: 'testing/scenario_app:sceario_app'), + CannedProcess((List command) => command.contains('desc'), + stdout: fixtures.gnDescOutputEmpty( + gnPattern: 'testing/scenario_app:sceario_app'), exitCode: 1), ]; final TestEnvironment testEnv = TestEnvironment.withTestEngine( @@ -496,7 +499,8 @@ void main() { help: true, ); final int result = await runner.run([ - 'help', 'build', + 'help', + 'build', ]); expect(result, equals(0)); } finally { @@ -528,7 +532,8 @@ void main() { help: true, ); final int result = await runner.run([ - 'help', 'build', + 'help', + 'build', ]); expect(result, equals(0)); } finally { diff --git a/engine/src/flutter/tools/engine_tool/test/entry_point_test.dart b/engine/src/flutter/tools/engine_tool/test/entry_point_test.dart index 052b36106d..b7c9b05253 100644 --- a/engine/src/flutter/tools/engine_tool/test/entry_point_test.dart +++ b/engine/src/flutter/tools/engine_tool/test/entry_point_test.dart @@ -5,10 +5,10 @@ import 'dart:io' as io; import 'package:engine_repo_tools/engine_repo_tools.dart'; -import 'package:litetest/litetest.dart'; import 'package:path/path.dart' as path; import 'package:platform/platform.dart'; import 'package:process_runner/process_runner.dart'; +import 'package:test/test.dart'; void main() { final Engine engine; diff --git a/engine/src/flutter/tools/engine_tool/test/fetch_command_test.dart b/engine/src/flutter/tools/engine_tool/test/fetch_command_test.dart index 2488f448a9..8431a16ae6 100644 --- a/engine/src/flutter/tools/engine_tool/test/fetch_command_test.dart +++ b/engine/src/flutter/tools/engine_tool/test/fetch_command_test.dart @@ -10,10 +10,10 @@ import 'package:engine_repo_tools/engine_repo_tools.dart'; import 'package:engine_tool/src/commands/command_runner.dart'; import 'package:engine_tool/src/environment.dart'; import 'package:engine_tool/src/logger.dart'; -import 'package:litetest/litetest.dart'; import 'package:platform/platform.dart'; import 'package:process_fakes/process_fakes.dart'; import 'package:process_runner/process_runner.dart'; +import 'package:test/test.dart'; void main() { final Engine? engine = Engine.tryFindWithin(); @@ -62,7 +62,7 @@ void main() { expect(runHistory.length, greaterThanOrEqualTo(1)); expect( runHistory[0], - containsStringsInOrder(['gclient', 'sync', '-D']), + containsAllInOrder(['gclient', 'sync', '-D']), ); }); @@ -78,7 +78,7 @@ void main() { expect(runHistory.length, greaterThanOrEqualTo(1)); expect( runHistory[0], - containsStringsInOrder(['gclient', 'sync', '-D']), + containsAllInOrder(['gclient', 'sync', '-D']), ); }); } diff --git a/engine/src/flutter/tools/engine_tool/test/fixtures.dart b/engine/src/flutter/tools/engine_tool/test/fixtures.dart index 70de4d36a9..6b119103bc 100644 --- a/engine/src/flutter/tools/engine_tool/test/fixtures.dart +++ b/engine/src/flutter/tools/engine_tool/test/fixtures.dart @@ -2,13 +2,15 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -String testConfig(String osDimension, String osPlatform) => ''' +String testConfig(String osDimension, String osPlatform, + {String suffix = ''}) => + ''' { "builds": [ { "archives": [ { - "name": "build_name", + "name": "build_name$suffix", "base_path": "base/path", "type": "gcs", "include_paths": ["include/path"], @@ -22,16 +24,16 @@ String testConfig(String osDimension, String osPlatform) => ''' "variable": false }, "gn": ["--gn-arg", "--lto", "--no-rbe"], - "name": "ci/build_name", + "name": "ci/build_name$suffix", "description": "This is a very long description that will test that the help message is wrapped correctly at an appropriate number of characters.", "ninja": { - "config": "build_name", + "config": "build_name$suffix", "targets": ["ninja_target"] }, "tests": [ { "language": "python3", - "name": "build_name tests", + "name": "build_name$suffix tests", "parameters": ["--test-params"], "script": "test/script.py", "contexts": ["context"] @@ -55,9 +57,9 @@ String testConfig(String osDimension, String osPlatform) => ''' "os=$osDimension" ], "gn": ["--gn-arg", "--lto", "--no-rbe"], - "name": "$osPlatform/host_debug", + "name": "$osPlatform/host_debug$suffix", "ninja": { - "config": "host_debug", + "config": "host_debug$suffix", "targets": ["ninja_target"] } }, @@ -66,9 +68,9 @@ String testConfig(String osDimension, String osPlatform) => ''' "os=$osDimension" ], "gn": ["--gn-arg", "--lto", "--no-rbe"], - "name": "$osPlatform/android_debug_arm64", + "name": "$osPlatform/android_debug${suffix}_arm64", "ninja": { - "config": "android_debug_arm64", + "config": "android_debug${suffix}_arm64", "targets": ["ninja_target"] } }, @@ -77,9 +79,9 @@ String testConfig(String osDimension, String osPlatform) => ''' "os=$osDimension" ], "gn": ["--gn-arg", "--lto", "--rbe"], - "name": "ci/android_debug_rbe_arm64", + "name": "ci/android_debug${suffix}_rbe_arm64", "ninja": { - "config": "android_debug_rbe_arm64", + "config": "android_debug${suffix}_rbe_arm64", "targets": ["ninja_target"] } } diff --git a/engine/src/flutter/tools/engine_tool/test/format_command_test.dart b/engine/src/flutter/tools/engine_tool/test/format_command_test.dart index 3256320f4e..6c7b88af96 100644 --- a/engine/src/flutter/tools/engine_tool/test/format_command_test.dart +++ b/engine/src/flutter/tools/engine_tool/test/format_command_test.dart @@ -11,11 +11,11 @@ import 'package:engine_tool/src/commands/command_runner.dart'; import 'package:engine_tool/src/commands/flags.dart'; import 'package:engine_tool/src/environment.dart'; import 'package:engine_tool/src/logger.dart'; -import 'package:litetest/litetest.dart'; import 'package:logging/logging.dart' as log; import 'package:platform/platform.dart'; import 'package:process_fakes/process_fakes.dart'; import 'package:process_runner/process_runner.dart'; +import 'package:test/test.dart'; void main() { final Engine engine; diff --git a/engine/src/flutter/tools/engine_tool/test/gn_test.dart b/engine/src/flutter/tools/engine_tool/test/gn_test.dart index 8bebbd335c..cfa7e160b1 100644 --- a/engine/src/flutter/tools/engine_tool/test/gn_test.dart +++ b/engine/src/flutter/tools/engine_tool/test/gn_test.dart @@ -4,7 +4,7 @@ import 'package:engine_tool/src/gn.dart'; import 'package:engine_tool/src/label.dart'; -import 'package:litetest/litetest.dart'; +import 'package:test/test.dart'; import 'utils.dart'; diff --git a/engine/src/flutter/tools/engine_tool/test/label_test.dart b/engine/src/flutter/tools/engine_tool/test/label_test.dart index b12cf5129a..0e401149e4 100644 --- a/engine/src/flutter/tools/engine_tool/test/label_test.dart +++ b/engine/src/flutter/tools/engine_tool/test/label_test.dart @@ -3,7 +3,7 @@ // found in the LICENSE file. import 'package:engine_tool/src/label.dart'; -import 'package:litetest/litetest.dart'; +import 'package:test/test.dart'; void main() { group('Label', () { diff --git a/engine/src/flutter/tools/engine_tool/test/lint_command_test.dart b/engine/src/flutter/tools/engine_tool/test/lint_command_test.dart index 9f1a7835f5..2d6eb697b7 100644 --- a/engine/src/flutter/tools/engine_tool/test/lint_command_test.dart +++ b/engine/src/flutter/tools/engine_tool/test/lint_command_test.dart @@ -11,10 +11,10 @@ import 'package:engine_repo_tools/engine_repo_tools.dart'; import 'package:engine_tool/src/commands/command_runner.dart'; import 'package:engine_tool/src/environment.dart'; import 'package:engine_tool/src/logger.dart'; -import 'package:litetest/litetest.dart'; import 'package:platform/platform.dart'; import 'package:process_fakes/process_fakes.dart'; import 'package:process_runner/process_runner.dart'; +import 'package:test/test.dart'; import 'fixtures.dart' as fixtures; @@ -47,7 +47,6 @@ void main() { final Map configs = { 'linux_test_config': linuxTestConfig, - 'linux_test_config2': linuxTestConfig, 'mac_test_config': macTestConfig, 'win_test_config': winTestConfig, }; diff --git a/engine/src/flutter/tools/engine_tool/test/logger_test.dart b/engine/src/flutter/tools/engine_tool/test/logger_test.dart index 1deea42fec..ddbf9270d8 100644 --- a/engine/src/flutter/tools/engine_tool/test/logger_test.dart +++ b/engine/src/flutter/tools/engine_tool/test/logger_test.dart @@ -3,8 +3,8 @@ // found in the LICENSE file. import 'package:engine_tool/src/logger.dart'; -import 'package:litetest/litetest.dart'; import 'package:logging/logging.dart' as log; +import 'package:test/test.dart'; void main() { List stringsFromLogs(List logs) { diff --git a/engine/src/flutter/tools/engine_tool/test/phone_home_test.dart b/engine/src/flutter/tools/engine_tool/test/phone_home_test.dart index d861de617f..8a29041158 100644 --- a/engine/src/flutter/tools/engine_tool/test/phone_home_test.dart +++ b/engine/src/flutter/tools/engine_tool/test/phone_home_test.dart @@ -3,7 +3,7 @@ // found in the LICENSE file. import 'package:engine_tool/src/phone_home.dart'; -import 'package:litetest/litetest.dart'; +import 'package:test/test.dart'; void main() { test('can et phone home', () async { diff --git a/engine/src/flutter/tools/engine_tool/test/proc_utils_test.dart b/engine/src/flutter/tools/engine_tool/test/proc_utils_test.dart index 8f32dacf29..946fbafb73 100644 --- a/engine/src/flutter/tools/engine_tool/test/proc_utils_test.dart +++ b/engine/src/flutter/tools/engine_tool/test/proc_utils_test.dart @@ -10,10 +10,10 @@ import 'package:engine_tool/src/environment.dart'; import 'package:engine_tool/src/logger.dart'; import 'package:engine_tool/src/proc_utils.dart'; import 'package:engine_tool/src/worker_pool.dart'; -import 'package:litetest/litetest.dart'; import 'package:platform/platform.dart'; import 'package:process_fakes/process_fakes.dart'; import 'package:process_runner/process_runner.dart'; +import 'package:test/test.dart'; void main() { final Engine engine; @@ -79,7 +79,7 @@ void main() { ProcessTask('F', env, io.Directory.current, ['failure']); final bool r = await wp.run({task}); expect(r, equals(false)); - expect(task.processArtifacts.exitCode, notEquals(0)); + expect(task.processArtifacts.exitCode, isNot(0)); final ProcessArtifacts loaded = ProcessArtifacts.fromFile(io.File(task.processArtifactsPath)); expect(loaded.stdout, equals('stdout failure')); diff --git a/engine/src/flutter/tools/engine_tool/test/query_command_test.dart b/engine/src/flutter/tools/engine_tool/test/query_command_test.dart index c4c762d4a3..aef566489e 100644 --- a/engine/src/flutter/tools/engine_tool/test/query_command_test.dart +++ b/engine/src/flutter/tools/engine_tool/test/query_command_test.dart @@ -7,9 +7,9 @@ import 'dart:convert' as convert; import 'package:engine_build_configs/engine_build_configs.dart'; import 'package:engine_tool/src/commands/command_runner.dart'; import 'package:engine_tool/src/environment.dart'; -import 'package:litetest/litetest.dart'; import 'package:logging/logging.dart' as log; import 'package:platform/platform.dart'; +import 'package:test/test.dart'; import 'fixtures.dart' as fixtures; import 'utils.dart'; @@ -21,6 +21,12 @@ void main() { as Map, ); + final BuilderConfig linuxTestConfig2 = BuilderConfig.fromJson( + path: 'ci/builders/linux_test_config2.json', + map: convert.jsonDecode(fixtures.testConfig('Linux', Platform.linux, suffix: '2')) + as Map, + ); + final BuilderConfig macTestConfig = BuilderConfig.fromJson( path: 'ci/builders/mac_test_config.json', map: convert.jsonDecode(fixtures.testConfig('Mac-12', Platform.macOS)) @@ -35,7 +41,7 @@ void main() { final Map configs = { 'linux_test_config': linuxTestConfig, - 'linux_test_config2': linuxTestConfig, + 'linux_test_config2': linuxTestConfig2, 'mac_test_config': macTestConfig, 'win_test_config': winTestConfig, }; @@ -75,10 +81,10 @@ void main() { ' "linux/android_debug_arm64" config\n', ' "ci/android_debug_rbe_arm64" config\n', '"linux_test_config2" builder:\n', - ' "ci/build_name" config\n', - ' "linux/host_debug" config\n', - ' "linux/android_debug_arm64" config\n', - ' "ci/android_debug_rbe_arm64" config\n', + ' "ci/build_name2" config\n', + ' "linux/host_debug2" config\n', + ' "linux/android_debug2_arm64" config\n', + ' "ci/android_debug2_rbe_arm64" config\n', ]), ); } finally { diff --git a/engine/src/flutter/tools/engine_tool/test/run_command_test.dart b/engine/src/flutter/tools/engine_tool/test/run_command_test.dart index 494a382738..1bf2d3094e 100644 --- a/engine/src/flutter/tools/engine_tool/test/run_command_test.dart +++ b/engine/src/flutter/tools/engine_tool/test/run_command_test.dart @@ -13,10 +13,10 @@ import 'package:engine_tool/src/environment.dart'; import 'package:engine_tool/src/label.dart'; import 'package:engine_tool/src/logger.dart'; import 'package:engine_tool/src/run_utils.dart'; -import 'package:litetest/litetest.dart'; import 'package:platform/platform.dart'; import 'package:process_fakes/process_fakes.dart'; import 'package:process_runner/process_runner.dart'; +import 'package:test/test.dart'; import 'fixtures.dart' as fixtures; @@ -50,7 +50,6 @@ void main() { final Map configs = { 'linux_test_config': linuxTestConfig, - 'linux_test_config2': linuxTestConfig, 'mac_test_config': macTestConfig, 'win_test_config': winTestConfig, }; @@ -62,10 +61,10 @@ void main() { abi: ffi.Abi.linuxX64, engine: engine, platform: FakePlatform( - operatingSystem: Platform.linux, - resolvedExecutable: io.Platform.resolvedExecutable, - pathSeparator: '/', - numberOfProcessors: 32, + operatingSystem: Platform.linux, + resolvedExecutable: io.Platform.resolvedExecutable, + pathSeparator: '/', + numberOfProcessors: 32, ), processRunner: ProcessRunner( processManager: FakeProcessManager(onStart: (List command) { @@ -100,7 +99,7 @@ void main() { expect(result, equals(0)); expect(runHistory.length, greaterThanOrEqualTo(6)); expect(runHistory[5], - containsStringsInOrder(['flutter', 'run', '--weird_argument'])); + containsAllInOrder(['flutter', 'run', '--weird_argument'])); }); test('parse devices list', () async { @@ -165,7 +164,7 @@ void main() { // Observe that we selected android_debug_arm64 as the target. expect( runHistory[5], - containsStringsInOrder([ + containsAllInOrder([ 'flutter', 'run', '--local-engine', diff --git a/engine/src/flutter/tools/engine_tool/test/test_command_test.dart b/engine/src/flutter/tools/engine_tool/test/test_command_test.dart index dfb640da62..792ecfb8be 100644 --- a/engine/src/flutter/tools/engine_tool/test/test_command_test.dart +++ b/engine/src/flutter/tools/engine_tool/test/test_command_test.dart @@ -7,8 +7,8 @@ import 'dart:convert' as convert; import 'package:engine_build_configs/engine_build_configs.dart'; import 'package:engine_tool/src/commands/command_runner.dart'; import 'package:engine_tool/src/environment.dart'; -import 'package:litetest/litetest.dart'; import 'package:platform/platform.dart'; +import 'package:test/test.dart'; import 'fixtures.dart' as fixtures; import 'utils.dart'; @@ -34,7 +34,6 @@ void main() { final Map configs = { 'linux_test_config': linuxTestConfig, - 'linux_test_config2': linuxTestConfig, 'mac_test_config': macTestConfig, 'win_test_config': winTestConfig, }; diff --git a/engine/src/flutter/tools/engine_tool/test/typed_json_test.dart b/engine/src/flutter/tools/engine_tool/test/typed_json_test.dart index c23df2b794..ca2d2c9634 100644 --- a/engine/src/flutter/tools/engine_tool/test/typed_json_test.dart +++ b/engine/src/flutter/tools/engine_tool/test/typed_json_test.dart @@ -3,23 +3,27 @@ // found in the LICENSE file. import 'package:engine_tool/src/typed_json.dart'; -import 'package:litetest/litetest.dart'; +import 'package:test/test.dart'; void main() { group('JsonObject.string', () { test('returns string value', () { - const JsonObject jsonObject = JsonObject({'key': 'value'}); + const JsonObject jsonObject = + JsonObject({'key': 'value'}); expect(jsonObject.string('key'), 'value'); }); test('throws due to missing key', () { - const JsonObject jsonObject = JsonObject({'key': 'value'}); - expect(() => jsonObject.string('missing'), throwsA(isInstanceOf())); + const JsonObject jsonObject = + JsonObject({'key': 'value'}); + expect(() => jsonObject.string('missing'), + throwsA(const isInstanceOf())); }); test('throws due to wrong type', () { const JsonObject jsonObject = JsonObject({'key': 42}); - expect(() => jsonObject.string('key'), throwsA(isInstanceOf())); + expect(() => jsonObject.string('key'), + throwsA(const isInstanceOf())); }); }); @@ -31,12 +35,15 @@ void main() { test('throws due to missing key', () { const JsonObject jsonObject = JsonObject({'key': 42}); - expect(() => jsonObject.integer('missing'), throwsA(isInstanceOf())); + expect(() => jsonObject.integer('missing'), + throwsA(const isInstanceOf())); }); test('throws due to wrong type', () { - const JsonObject jsonObject = JsonObject({'key': 'value'}); - expect(() => jsonObject.integer('key'), throwsA(isInstanceOf())); + const JsonObject jsonObject = + JsonObject({'key': 'value'}); + expect(() => jsonObject.integer('key'), + throwsA(const isInstanceOf())); }); }); @@ -48,51 +55,67 @@ void main() { test('throws due to missing key', () { const JsonObject jsonObject = JsonObject({'key': true}); - expect(() => jsonObject.boolean('missing'), throwsA(isInstanceOf())); + expect(() => jsonObject.boolean('missing'), + throwsA(const isInstanceOf())); }); test('throws due to wrong type', () { - const JsonObject jsonObject = JsonObject({'key': 'value'}); - expect(() => jsonObject.boolean('key'), throwsA(isInstanceOf())); + const JsonObject jsonObject = + JsonObject({'key': 'value'}); + expect(() => jsonObject.boolean('key'), + throwsA(const isInstanceOf())); }); }); group('JsonObject.stringList', () { test('returns string list value', () { - const JsonObject jsonObject = JsonObject({'key': ['value1', 'value2']}); + const JsonObject jsonObject = JsonObject({ + 'key': ['value1', 'value2'] + }); expect(jsonObject.stringList('key'), ['value1', 'value2']); }); test('throws due to missing key', () { - const JsonObject jsonObject = JsonObject({'key': ['value1', 'value2']}); - expect(() => jsonObject.stringList('missing'), throwsA(isInstanceOf())); + const JsonObject jsonObject = JsonObject({ + 'key': ['value1', 'value2'] + }); + expect(() => jsonObject.stringList('missing'), + throwsA(const isInstanceOf())); }); test('throws due to wrong type', () { - const JsonObject jsonObject = JsonObject({'key': 'value'}); - expect(() => jsonObject.stringList('key'), throwsA(isInstanceOf())); + const JsonObject jsonObject = + JsonObject({'key': 'value'}); + expect(() => jsonObject.stringList('key'), + throwsA(const isInstanceOf())); }); test('throws due to wrong element type', () { - const JsonObject jsonObject = JsonObject({'key': ['value1', 42]}); - expect(() => jsonObject.stringList('key'), throwsA(isInstanceOf())); + const JsonObject jsonObject = JsonObject({ + 'key': ['value1', 42] + }); + expect(() => jsonObject.stringList('key'), + throwsA(const isInstanceOf())); }); }); group('JsonObject.stringOrNull', () { test('returns string value', () { - const JsonObject jsonObject = JsonObject({'key': 'value'}); + const JsonObject jsonObject = + JsonObject({'key': 'value'}); expect(jsonObject.stringOrNull('key'), 'value'); }); test('returns null due to missing key', () { - const JsonObject jsonObject = JsonObject({'key': 'value'}); + const JsonObject jsonObject = + JsonObject({'key': 'value'}); expect(jsonObject.stringOrNull('missing'), isNull); }); test('throws due to wrong type', () { const JsonObject jsonObject = JsonObject({'key': 42}); - expect(() => jsonObject.stringOrNull('key'), throwsA(isInstanceOf())); + expect(() => jsonObject.stringOrNull('key'), + throwsA(const isInstanceOf())); }); }); @@ -108,8 +131,10 @@ void main() { }); test('throws due to wrong type', () { - const JsonObject jsonObject = JsonObject({'key': 'value'}); - expect(() => jsonObject.integerOrNull('key'), throwsA(isInstanceOf())); + const JsonObject jsonObject = + JsonObject({'key': 'value'}); + expect(() => jsonObject.integerOrNull('key'), + throwsA(const isInstanceOf())); }); }); @@ -125,36 +150,48 @@ void main() { }); test('throws due to wrong type', () { - const JsonObject jsonObject = JsonObject({'key': 'value'}); - expect(() => jsonObject.booleanOrNull('key'), throwsA(isInstanceOf())); + const JsonObject jsonObject = + JsonObject({'key': 'value'}); + expect(() => jsonObject.booleanOrNull('key'), + throwsA(const isInstanceOf())); }); }); group('JsonObject.stringListOrNull', () { test('returns string list value', () { - const JsonObject jsonObject = JsonObject({'key': ['value1', 'value2']}); + const JsonObject jsonObject = JsonObject({ + 'key': ['value1', 'value2'] + }); expect(jsonObject.stringListOrNull('key'), ['value1', 'value2']); }); test('returns null due to missing key', () { - const JsonObject jsonObject = JsonObject({'key': ['value1', 'value2']}); + const JsonObject jsonObject = JsonObject({ + 'key': ['value1', 'value2'] + }); expect(jsonObject.stringListOrNull('missing'), isNull); }); test('throws due to wrong type', () { - const JsonObject jsonObject = JsonObject({'key': 'value'}); - expect(() => jsonObject.stringListOrNull('key'), throwsA(isInstanceOf())); + const JsonObject jsonObject = + JsonObject({'key': 'value'}); + expect(() => jsonObject.stringListOrNull('key'), + throwsA(const isInstanceOf())); }); test('throws due to wrong element type', () { - const JsonObject jsonObject = JsonObject({'key': ['value1', 42]}); - expect(() => jsonObject.stringListOrNull('key'), throwsA(isInstanceOf())); + const JsonObject jsonObject = JsonObject({ + 'key': ['value1', 42] + }); + expect(() => jsonObject.stringListOrNull('key'), + throwsA(const isInstanceOf())); }); }); group('JsonObject.map', () { test('returns multiple fields', () { - final (String name, int age, bool isStudent) = const JsonObject({ + final (String name, int age, bool isStudent) = + const JsonObject({ 'name': 'Alice', 'age': 42, 'isStudent': true, @@ -185,9 +222,13 @@ void main() { fail('Expected JsonMapException'); } on JsonMapException catch (e) { expect( - e.exceptions.map((JsonReadException e) => (e as MissingKeyJsonReadException).key).toList(), - containsStringsInOrder(['name', 'isStudent'], - )); + e.exceptions + .map((JsonReadException e) => + (e as MissingKeyJsonReadException).key) + .toList(), + containsAllInOrder( + ['name', 'isStudent'], + )); } }); @@ -207,18 +248,22 @@ void main() { fail('Expected JsonMapException'); } on JsonMapException catch (e) { expect( - e.exceptions.map((JsonReadException e) => switch (e) { - final InvalidTypeJsonReadException e => e.key, - final MissingKeyJsonReadException e => e.key, - _ => throw StateError('Unexpected exception type: $e'), - }).toList(), - containsStringsInOrder(['name', 'age'], - )); + e.exceptions + .map((JsonReadException e) => switch (e) { + final InvalidTypeJsonReadException e => e.key, + final MissingKeyJsonReadException e => e.key, + _ => throw StateError('Unexpected exception type: $e'), + }) + .toList(), + containsAllInOrder( + ['name', 'age'], + )); } }); test('allows a default with onError', () { - final (String name, int age, bool isStudent) = const JsonObject({ + final (String name, int age, bool isStudent) = + const JsonObject({ 'name': 'Alice', 'age': 42, 'isStudent': 'true', @@ -230,11 +275,13 @@ void main() { ); }, onError: expectAsync2((_, JsonMapException e) { expect( - e.exceptions.map((JsonReadException e) => switch (e) { - final InvalidTypeJsonReadException e => e.key, - final MissingKeyJsonReadException e => e.key, - _ => throw StateError('Unexpected exception type: $e'), - }).toList(), + e.exceptions + .map((JsonReadException e) => switch (e) { + final InvalidTypeJsonReadException e => e.key, + final MissingKeyJsonReadException e => e.key, + _ => throw StateError('Unexpected exception type: $e'), + }) + .toList(), ['isStudent'], ); return ('Bob', 0, false); @@ -258,7 +305,7 @@ void main() { json.boolean('isStudent'), ); }); - }, throwsA(isInstanceOf())); + }, throwsA(const isInstanceOf())); }); }); } diff --git a/engine/src/flutter/tools/engine_tool/test/utils.dart b/engine/src/flutter/tools/engine_tool/test/utils.dart index f9f94bac7e..6cc07e320b 100644 --- a/engine/src/flutter/tools/engine_tool/test/utils.dart +++ b/engine/src/flutter/tools/engine_tool/test/utils.dart @@ -8,11 +8,11 @@ import 'dart:io' as io; import 'package:engine_repo_tools/engine_repo_tools.dart'; import 'package:engine_tool/src/environment.dart'; import 'package:engine_tool/src/logger.dart'; -import 'package:litetest/litetest.dart' show Expect, Matcher; import 'package:path/path.dart' as path; import 'package:platform/platform.dart'; import 'package:process_fakes/process_fakes.dart'; import 'package:process_runner/process_runner.dart'; +import 'package:test/test.dart'; /// Each CannedProcess has a command matcher and the result of an executed /// process. The matcher is used to determine when to use a registered @@ -211,48 +211,18 @@ io.ProcessResult _getCannedProcessResult( return io.ProcessResult(0, 0, '', ''); } -typedef CommandMatcher = bool Function(List command); +Matcher containsCommand(bool Function(List command) matcher) { + return predicate((List history) { + return history.any((ExecutedProcess process) { + return matcher(process.command); + }); + }, 'contains command'); +} -/// Returns a [Matcher] that fails the test if no process has a matching command. -/// -/// Usage: -/// expect(testEnv.processHistory, -/// containsCommand((List command) { -/// return command.length > 5 && -/// command[0].contains('ninja') && -/// command[2].endsWith('/host_debug') && -/// command[5] == 'flutter/fml:fml_arc_unittests'; -/// }) -/// ); -Matcher containsCommand(CommandMatcher commandMatcher) => (dynamic processes) { - Expect.type>(processes); - final List> commands = (processes as List) - .map((ExecutedProcess process) => process.command) - .toList(); - if (!commands.any(commandMatcher)) { - Expect.fail('No process found with matching command'); - } - }; - -/// Returns a [Matcher] that fails the test if any process has a matching -/// command. -/// -/// Usage: -/// expect(testEnv.processHistory, -/// doesNotContainCommand((List command) { -/// return command.length > 5 && -/// command[0].contains('ninja') && -/// command[2].endsWith('/host_debug') && -/// command[5] == 'flutter/fml:fml_arc_unittests'; -/// }) -/// ); -Matcher doesNotContainCommand(CommandMatcher commandMatcher) => - (dynamic processes) { - Expect.type>(processes); - final List> commands = (processes as List) - .map((ExecutedProcess process) => process.command) - .toList(); - if (commands.any(commandMatcher)) { - Expect.fail('Process found with matching command'); - } - }; +Matcher doesNotContainCommand(bool Function(List command) matcher) { + return predicate((List history) { + return !history.any((ExecutedProcess process) { + return matcher(process.command); + }); + }, 'does not contain command'); +} diff --git a/engine/src/flutter/tools/engine_tool/test/utils_test.dart b/engine/src/flutter/tools/engine_tool/test/utils_test.dart index 1ce186ced1..e376f7917f 100644 --- a/engine/src/flutter/tools/engine_tool/test/utils_test.dart +++ b/engine/src/flutter/tools/engine_tool/test/utils_test.dart @@ -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 'package:litetest/litetest.dart'; +import 'package:test/test.dart'; import 'utils.dart'; diff --git a/engine/src/flutter/tools/engine_tool/test/worker_pool_test.dart b/engine/src/flutter/tools/engine_tool/test/worker_pool_test.dart index 19752836fb..6e3e6159f9 100644 --- a/engine/src/flutter/tools/engine_tool/test/worker_pool_test.dart +++ b/engine/src/flutter/tools/engine_tool/test/worker_pool_test.dart @@ -9,10 +9,10 @@ import 'package:engine_repo_tools/engine_repo_tools.dart'; import 'package:engine_tool/src/environment.dart'; import 'package:engine_tool/src/logger.dart'; import 'package:engine_tool/src/worker_pool.dart'; -import 'package:litetest/litetest.dart'; import 'package:platform/platform.dart'; import 'package:process_fakes/process_fakes.dart'; import 'package:process_runner/process_runner.dart'; +import 'package:test/test.dart'; class TestWorkerPoolProgressReporter implements WorkerPoolProgressReporter { int _successCount = 0; diff --git a/engine/src/flutter/tools/githooks/pubspec.yaml b/engine/src/flutter/tools/githooks/pubspec.yaml index d16ff21117..f0c37a7273 100644 --- a/engine/src/flutter/tools/githooks/pubspec.yaml +++ b/engine/src/flutter/tools/githooks/pubspec.yaml @@ -19,7 +19,4 @@ dependencies: path: any dev_dependencies: - async_helper: any - expect: any - litetest: any - smith: any + test: any diff --git a/engine/src/flutter/tools/githooks/test/githooks_test.dart b/engine/src/flutter/tools/githooks/test/githooks_test.dart index 74639c2d54..d9e56b7484 100644 --- a/engine/src/flutter/tools/githooks/test/githooks_test.dart +++ b/engine/src/flutter/tools/githooks/test/githooks_test.dart @@ -5,7 +5,7 @@ import 'dart:io' as io; import 'package:githooks/githooks.dart'; -import 'package:litetest/litetest.dart'; +import 'package:test/test.dart'; void main() { test('Fails gracefully without a command', () async { diff --git a/engine/src/flutter/tools/licenses/pubspec.yaml b/engine/src/flutter/tools/licenses/pubspec.yaml index 5c5a6560c3..caa66d7557 100644 --- a/engine/src/flutter/tools/licenses/pubspec.yaml +++ b/engine/src/flutter/tools/licenses/pubspec.yaml @@ -21,4 +21,4 @@ dependencies: path: any dev_dependencies: - litetest: any + test: any diff --git a/engine/src/flutter/tools/licenses/test/formatter_test.dart b/engine/src/flutter/tools/licenses/test/formatter_test.dart index 39c4d86fb8..565763d18f 100644 --- a/engine/src/flutter/tools/licenses/test/formatter_test.dart +++ b/engine/src/flutter/tools/licenses/test/formatter_test.dart @@ -3,7 +3,7 @@ // found in the LICENSE file. import 'package:licenses/formatter.dart'; -import 'package:litetest/litetest.dart'; +import 'package:test/test.dart'; void main() { test('Block comments', () { diff --git a/engine/src/flutter/tools/pkg/engine_build_configs/pubspec.yaml b/engine/src/flutter/tools/pkg/engine_build_configs/pubspec.yaml index 2af0e6c7e3..369800c9d9 100644 --- a/engine/src/flutter/tools/pkg/engine_build_configs/pubspec.yaml +++ b/engine/src/flutter/tools/pkg/engine_build_configs/pubspec.yaml @@ -23,9 +23,6 @@ dependencies: yaml: any dev_dependencies: - async_helper: any - expect: any - litetest: any process_fakes: any - smith: any source_span: any + test: any diff --git a/engine/src/flutter/tools/pkg/engine_build_configs/test/build_config_loader_test.dart b/engine/src/flutter/tools/pkg/engine_build_configs/test/build_config_loader_test.dart index d0ba235ea2..27ab0dc4f5 100644 --- a/engine/src/flutter/tools/pkg/engine_build_configs/test/build_config_loader_test.dart +++ b/engine/src/flutter/tools/pkg/engine_build_configs/test/build_config_loader_test.dart @@ -6,7 +6,7 @@ import 'package:engine_build_configs/src/build_config.dart'; import 'package:engine_build_configs/src/build_config_loader.dart'; import 'package:file/file.dart'; import 'package:file/memory.dart'; -import 'package:litetest/litetest.dart'; +import 'package:test/test.dart'; import 'fixtures.dart' as fixtures; diff --git a/engine/src/flutter/tools/pkg/engine_build_configs/test/build_config_runner_test.dart b/engine/src/flutter/tools/pkg/engine_build_configs/test/build_config_runner_test.dart index 5304684f1b..b98474d91f 100644 --- a/engine/src/flutter/tools/pkg/engine_build_configs/test/build_config_runner_test.dart +++ b/engine/src/flutter/tools/pkg/engine_build_configs/test/build_config_runner_test.dart @@ -9,11 +9,11 @@ import 'dart:io' as io; import 'package:engine_build_configs/src/build_config.dart'; import 'package:engine_build_configs/src/build_config_runner.dart'; import 'package:engine_repo_tools/engine_repo_tools.dart'; -import 'package:litetest/litetest.dart'; import 'package:path/path.dart' as path; import 'package:platform/platform.dart'; import 'package:process_fakes/process_fakes.dart'; import 'package:process_runner/process_runner.dart'; +import 'package:test/test.dart'; import 'fixtures.dart' as fixtures; diff --git a/engine/src/flutter/tools/pkg/engine_build_configs/test/build_config_test.dart b/engine/src/flutter/tools/pkg/engine_build_configs/test/build_config_test.dart index 5bffa83748..98df7aae3d 100644 --- a/engine/src/flutter/tools/pkg/engine_build_configs/test/build_config_test.dart +++ b/engine/src/flutter/tools/pkg/engine_build_configs/test/build_config_test.dart @@ -5,8 +5,8 @@ import 'dart:convert' as convert; import 'package:engine_build_configs/src/build_config.dart'; -import 'package:litetest/litetest.dart'; import 'package:platform/platform.dart'; +import 'package:test/test.dart'; import 'fixtures.dart' as fixtures; diff --git a/engine/src/flutter/tools/pkg/engine_build_configs/test/ci_yaml_test.dart b/engine/src/flutter/tools/pkg/engine_build_configs/test/ci_yaml_test.dart index df5e4489ca..0286534ca9 100644 --- a/engine/src/flutter/tools/pkg/engine_build_configs/test/ci_yaml_test.dart +++ b/engine/src/flutter/tools/pkg/engine_build_configs/test/ci_yaml_test.dart @@ -6,9 +6,9 @@ import 'dart:io' as io; import 'package:engine_build_configs/src/ci_yaml.dart'; import 'package:engine_repo_tools/engine_repo_tools.dart'; -import 'package:litetest/litetest.dart'; import 'package:path/path.dart' as path; import 'package:source_span/source_span.dart'; +import 'package:test/test.dart'; import 'package:yaml/yaml.dart' as y; void main() { diff --git a/engine/src/flutter/tools/pkg/engine_repo_tools/pubspec.yaml b/engine/src/flutter/tools/pkg/engine_repo_tools/pubspec.yaml index 652f147148..02c8262090 100644 --- a/engine/src/flutter/tools/pkg/engine_repo_tools/pubspec.yaml +++ b/engine/src/flutter/tools/pkg/engine_repo_tools/pubspec.yaml @@ -17,7 +17,4 @@ dependencies: path: any dev_dependencies: - async_helper: any - expect: any - litetest: any - smith: any + test: any diff --git a/engine/src/flutter/tools/pkg/engine_repo_tools/test/engine_repo_tools_test.dart b/engine/src/flutter/tools/pkg/engine_repo_tools/test/engine_repo_tools_test.dart index 4b6a05becb..f0ccb14069 100644 --- a/engine/src/flutter/tools/pkg/engine_repo_tools/test/engine_repo_tools_test.dart +++ b/engine/src/flutter/tools/pkg/engine_repo_tools/test/engine_repo_tools_test.dart @@ -3,10 +3,10 @@ // found in the LICENSE file. import 'dart:io' as io; -import 'package:async_helper/async_helper.dart'; + import 'package:engine_repo_tools/engine_repo_tools.dart'; -import 'package:litetest/litetest.dart'; import 'package:path/path.dart' as p; +import 'package:test/test.dart'; void main() { late io.Directory emptyDir; @@ -25,9 +25,9 @@ void main() { setUp(); try { expect( - () => Engine.fromSrcPath(emptyDir.path), - _throwsInvalidEngineException, - ); + () => Engine.fromSrcPath(emptyDir.path), + throwsA(const TypeMatcher()), + ); } finally { tearDown(); } @@ -38,7 +38,7 @@ void main() { try { expect( () => Engine.fromSrcPath(p.join(emptyDir.path, 'src')), - _throwsInvalidEngineException, + throwsA(const TypeMatcher()), ); } finally { tearDown(); @@ -51,7 +51,7 @@ void main() { final io.Directory srcDir = io.Directory(p.join(emptyDir.path, 'src'))..createSync(); expect( () => Engine.fromSrcPath(srcDir.path), - _throwsInvalidEngineException, + throwsA(const TypeMatcher()), ); } finally { tearDown(); @@ -241,33 +241,3 @@ void main() { } }); } - -// This is needed because async_minitest and friends is not a proper testing -// library and is missing a lot of functionality that was exclusively added -// to pkg/test. -void _throwsInvalidEngineException(Object? o) { - _checkThrow(o, (_){}); -} - -// Mostly copied from async_minitest. -void _checkThrow(dynamic v, void Function(dynamic error) onError) { - if (v is Future) { - asyncStart(); - v.then((_) { - Expect.fail('Did not throw'); - }, onError: (Object e, StackTrace s) { - if (e is! T) { - // ignore: only_throw_errors - throw e; - } - onError(e); - asyncEnd(); - }); - return; - } - v as void Function(); - Expect.throws(v, (T e) { - onError(e); - return true; - }); -} diff --git a/engine/src/flutter/tools/pkg/git_repo_tools/pubspec.yaml b/engine/src/flutter/tools/pkg/git_repo_tools/pubspec.yaml index db6a697b9b..e01df70cf1 100644 --- a/engine/src/flutter/tools/pkg/git_repo_tools/pubspec.yaml +++ b/engine/src/flutter/tools/pkg/git_repo_tools/pubspec.yaml @@ -19,8 +19,5 @@ dependencies: process_runner: any dev_dependencies: - async_helper: any - expect: any - litetest: any process_fakes: any - smith: any + test: any diff --git a/engine/src/flutter/tools/pkg/git_repo_tools/test/git_repo_tools_test.dart b/engine/src/flutter/tools/pkg/git_repo_tools/test/git_repo_tools_test.dart index c404817445..7fe38ef290 100644 --- a/engine/src/flutter/tools/pkg/git_repo_tools/test/git_repo_tools_test.dart +++ b/engine/src/flutter/tools/pkg/git_repo_tools/test/git_repo_tools_test.dart @@ -5,13 +5,12 @@ import 'dart:io' as io; import 'package:git_repo_tools/git_repo_tools.dart'; -import 'package:litetest/litetest.dart'; import 'package:process_fakes/process_fakes.dart'; +import 'package:test/test.dart'; void main() { const String fakeShaHash = 'fake-sha-hash'; - test('returns non-deleted files which differ from merge-base with main', () async { final Fixture fixture = Fixture( processManager: FakeProcessManager(