diff --git a/engine/src/flutter/flutter_frontend_server/test/to_string_test.dart b/engine/src/flutter/flutter_frontend_server/test/to_string_test.dart index 6fb106dd23d..bf735b6a08b 100644 --- a/engine/src/flutter/flutter_frontend_server/test/to_string_test.dart +++ b/engine/src/flutter/flutter_frontend_server/test/to_string_test.dart @@ -19,7 +19,7 @@ Future main(List args) async { final String buildDir = args[0]; final String frontendServer = args[1]; final String sdkRoot = args[2]; - final String basePath = path.canonicalize(path.join(path.dirname(Platform.script.path), '..')); + final String basePath = path.canonicalize(path.join(path.dirname(Platform.script.toFilePath()), '..')); final String fixtures = path.join(basePath, 'test', 'fixtures'); final String mainDart = path.join(fixtures, 'lib', 'main.dart'); final String packageConfig = path.join(fixtures, '.dart_tool', 'package_config.json'); diff --git a/engine/src/flutter/lib/spirv/test/spirv_assembler.cc b/engine/src/flutter/lib/spirv/test/spirv_assembler.cc index da51aca19f9..f5bb0467482 100644 --- a/engine/src/flutter/lib/spirv/test/spirv_assembler.cc +++ b/engine/src/flutter/lib/spirv/test/spirv_assembler.cc @@ -41,7 +41,8 @@ int main(int argc, const char* argv[]) { } std::fstream output; - output.open(argv[2], std::fstream::out | std::fstream::trunc); + output.open(argv[2], + std::fstream::out | std::fstream::trunc | std::fstream::binary); if (!output.is_open()) { output.close(); std::cerr << "failed to open output file" << std::endl; diff --git a/engine/src/flutter/shell/testing/tester_main.cc b/engine/src/flutter/shell/testing/tester_main.cc index 2416a61289f..155e2f071d6 100644 --- a/engine/src/flutter/shell/testing/tester_main.cc +++ b/engine/src/flutter/shell/testing/tester_main.cc @@ -27,6 +27,10 @@ #include "third_party/dart/runtime/include/bin/dart_io_api.h" #include "third_party/dart/runtime/include/dart_api.h" +#if defined(FML_OS_WIN) +#include +#endif // defined(FML_OS_WIN) + #if defined(FML_OS_POSIX) #include #endif // defined(FML_OS_POSIX) @@ -414,6 +418,10 @@ int main(int argc, char* argv[]) { return true; }; +#if defined(FML_OS_WIN) + CoInitializeEx(nullptr, COINIT_MULTITHREADED); +#endif // defined(FML_OS_WIN) + return flutter::RunTester(settings, command_line.HasOption(flutter::FlagForSwitch( flutter::Switch::RunForever)), diff --git a/engine/src/flutter/testing/litetest/lib/src/matchers.dart b/engine/src/flutter/testing/litetest/lib/src/matchers.dart index 431ebcd9feb..7e040d1db9c 100644 --- a/engine/src/flutter/testing/litetest/lib/src/matchers.dart +++ b/engine/src/flutter/testing/litetest/lib/src/matchers.dart @@ -112,3 +112,24 @@ Matcher startsWith(String s) => (dynamic d) { Expect.fail('Expected "$h" to start with "$s"'); } }; + +/// Gives a matcher that asserts that the value being matched is a [String] that +/// ends with `s`. +Matcher endsWith(String s) => (dynamic d) { + expect(d, isInstanceOf()); + final String h = d as String; + if (!h.endsWith(s)) { + Expect.fail('Expected "$h" to end with "$s"'); + } +}; + +/// Gives a matcher that asserts that the value being matched is a [String] that +/// regexp matches with `pattern`. +Matcher hasMatch(String pattern) => (dynamic d) { + expect(d, isInstanceOf()); + final String h = d as String; + final RegExp regExp = RegExp(pattern); + if (!regExp.hasMatch(h)) { + Expect.fail('Expected "$h" to match with "$pattern"'); + } +}; diff --git a/engine/src/flutter/testing/run_tests.py b/engine/src/flutter/testing/run_tests.py index 0096abf6bbf..5ccf6dc3797 100755 --- a/engine/src/flutter/testing/run_tests.py +++ b/engine/src/flutter/testing/run_tests.py @@ -1049,8 +1049,6 @@ def main(): ) if 'dart' in types: - assert not IsWindows( - ), "Dart tests can't be run on windows. https://github.com/flutter/flutter/issues/36301." dart_filter = args.dart_filter.split(',') if args.dart_filter else None tasks = list(GatherDartSmokeTest(build_dir, args.verbose_dart_snapshot)) tasks += list(GatherLitetestTests(build_dir)) diff --git a/engine/src/flutter/tools/api_check/test/apicheck_test.dart b/engine/src/flutter/tools/api_check/test/apicheck_test.dart index 11e73dd45ee..c129f60f964 100644 --- a/engine/src/flutter/tools/api_check/test/apicheck_test.dart +++ b/engine/src/flutter/tools/api_check/test/apicheck_test.dart @@ -8,6 +8,7 @@ import 'package:analyzer/dart/ast/ast.dart'; import 'package:analyzer/dart/ast/visitor.dart'; import 'package:apicheck/apicheck.dart'; import 'package:litetest/litetest.dart'; +import 'package:path/path.dart' as path; main(List arguments) { if (arguments.length < 1) { @@ -38,27 +39,28 @@ main(List arguments) { checkApiConsistency(String flutterRoot) { test('AccessibilityFeatures enums match', () { // Dart values: _kFooBarIndex = 1 << N - List uiFields = getDartClassFields( - sourcePath:'$flutterRoot/lib/ui/window.dart', - className:'AccessibilityFeatures', + final List uiFields = getDartClassFields( + sourcePath: path.join(flutterRoot, 'lib', 'ui', 'window.dart'), + className: 'AccessibilityFeatures', ); - List webuiFields = getDartClassFields( - sourcePath:'$flutterRoot/lib/ui/window.dart', - className:'AccessibilityFeatures', + final List webuiFields = getDartClassFields( + sourcePath: path.join(flutterRoot, 'lib', 'ui', 'window.dart'), + className: 'AccessibilityFeatures', ); // C values: kFlutterAccessibilityFeatureFooBar = 1 << N, - List embedderEnumValues = getCppEnumValues( - sourcePath: '$flutterRoot/shell/platform/embedder/embedder.h', + final List embedderEnumValues = getCppEnumValues( + sourcePath: path.join(flutterRoot, 'shell', 'platform', 'embedder', 'embedder.h'), enumName: 'FlutterAccessibilityFeature', ); // C++ values: kFooBar = 1 << N, - List internalEnumValues = getCppEnumClassValues( - sourcePath: '$flutterRoot/lib/ui/window/platform_configuration.h', + final List internalEnumValues = getCppEnumClassValues( + sourcePath: path.join(flutterRoot, 'lib','ui', 'window', 'platform_configuration.h'), enumName: 'AccessibilityFeatureFlag', ); // Java values: FOO_BAR(1 << N). - List javaEnumValues = getJavaEnumValues( - sourcePath: '$flutterRoot/shell/platform/android/io/flutter/view/AccessibilityBridge.java', + final List javaEnumValues = getJavaEnumValues( + sourcePath: path.join(flutterRoot, 'shell', 'platform', 'android', 'io', + 'flutter', 'view', 'AccessibilityBridge.java'), enumName: 'AccessibilityFeature', ).map(allCapsToCamelCase).toList(); @@ -70,27 +72,28 @@ checkApiConsistency(String flutterRoot) { test('SemanticsAction enums match', () { // Dart values: _kFooBarIndex = 1 << N. - List uiFields = getDartClassFields( - sourcePath:'$flutterRoot/lib/ui/semantics.dart', - className:'SemanticsAction', + final List uiFields = getDartClassFields( + sourcePath: path.join(flutterRoot, 'lib', 'ui', 'semantics.dart'), + className: 'SemanticsAction', ); - List webuiFields = getDartClassFields( - sourcePath:'$flutterRoot/lib/ui/semantics.dart', - className:'SemanticsAction', + final List webuiFields = getDartClassFields( + sourcePath: path.join(flutterRoot, 'lib', 'ui', 'semantics.dart'), + className: 'SemanticsAction', ); // C values: kFlutterSemanticsActionFooBar = 1 << N. - List embedderEnumValues = getCppEnumValues( - sourcePath: '$flutterRoot/shell/platform/embedder/embedder.h', + final List embedderEnumValues = getCppEnumValues( + sourcePath: path.join(flutterRoot, 'shell', 'platform', 'embedder', 'embedder.h'), enumName: 'FlutterSemanticsAction', ); // C++ values: kFooBar = 1 << N. - List internalEnumValues = getCppEnumClassValues( - sourcePath: '$flutterRoot/lib/ui/semantics/semantics_node.h', + final List internalEnumValues = getCppEnumClassValues( + sourcePath: path.join(flutterRoot, 'lib', 'ui', 'semantics', 'semantics_node.h'), enumName: 'SemanticsAction', ); // Java values: FOO_BAR(1 << N). - List javaEnumValues = getJavaEnumValues( - sourcePath: '$flutterRoot/shell/platform/android/io/flutter/view/AccessibilityBridge.java', + final List javaEnumValues = getJavaEnumValues( + sourcePath: path.join(flutterRoot, 'shell', 'platform', 'android', 'io', + 'flutter', 'view', 'AccessibilityBridge.java'), enumName: 'Action', ).map(allCapsToCamelCase).toList(); @@ -102,27 +105,28 @@ checkApiConsistency(String flutterRoot) { test('SemanticsFlag enums match', () { // Dart values: _kFooBarIndex = 1 << N. - List uiFields = getDartClassFields( - sourcePath:'$flutterRoot/lib/ui/semantics.dart', - className:'SemanticsFlag', + final List uiFields = getDartClassFields( + sourcePath: path.join(flutterRoot, 'lib', 'ui', 'semantics.dart'), + className: 'SemanticsFlag', ); - List webuiFields = getDartClassFields( - sourcePath:'$flutterRoot/lib/ui/semantics.dart', - className:'SemanticsFlag', + final List webuiFields = getDartClassFields( + sourcePath: path.join(flutterRoot, 'lib', 'ui', 'semantics.dart'), + className: 'SemanticsFlag', ); // C values: kFlutterSemanticsFlagFooBar = 1 << N. - List embedderEnumValues = getCppEnumValues( - sourcePath: '$flutterRoot/shell/platform/embedder/embedder.h', + final List embedderEnumValues = getCppEnumValues( + sourcePath: path.join(flutterRoot, 'shell', 'platform', 'embedder', 'embedder.h'), enumName: 'FlutterSemanticsFlag', ); // C++ values: kFooBar = 1 << N. - List internalEnumValues = getCppEnumClassValues( - sourcePath: '$flutterRoot/lib/ui/semantics/semantics_node.h', + final List internalEnumValues = getCppEnumClassValues( + sourcePath: path.join(flutterRoot, 'lib', 'ui', 'semantics', 'semantics_node.h'), enumName: 'SemanticsFlags', ); // Java values: FOO_BAR(1 << N). - List javaEnumValues = getJavaEnumValues( - sourcePath: '$flutterRoot/shell/platform/android/io/flutter/view/AccessibilityBridge.java', + final List javaEnumValues = getJavaEnumValues( + sourcePath: path.join(flutterRoot, 'shell', 'platform', 'android', 'io', + 'flutter', 'view', 'AccessibilityBridge.java'), enumName: 'Flag', ).map(allCapsToCamelCase).toList(); diff --git a/engine/src/flutter/tools/clang_tidy/test/clang_tidy_test.dart b/engine/src/flutter/tools/clang_tidy/test/clang_tidy_test.dart index 76e0e7c775f..b96c5a307a2 100644 --- a/engine/src/flutter/tools/clang_tidy/test/clang_tidy_test.dart +++ b/engine/src/flutter/tools/clang_tidy/test/clang_tidy_test.dart @@ -98,8 +98,8 @@ Future main(List args) async { expect(clangTidy.options.help, isFalse); expect(result, equals(1)); - expect(errBuffer.toString(), contains( - "ERROR: Build commands path /does/not/exist doesn't exist.", + expect(errBuffer.toString().split('\n')[0], hasMatch( + r"ERROR: Build commands path .*/does/not/exist doesn't exist.", )); }); @@ -121,8 +121,10 @@ Future main(List args) async { expect(clangTidy.options.help, isFalse); expect(result, equals(1)); - expect(errBuffer.toString(), contains( - "ERROR: Build commands path /does/not/exist/out/ios_debug_unopt/compile_commands.json doesn't exist.", + expect(errBuffer.toString().split('\n')[0], hasMatch( + r'ERROR: Build commands path .*/does/not/exist' + r'[/\\]out[/\\]ios_debug_unopt[/\\]compile_commands.json' + r" doesn't exist.", )); }); @@ -187,7 +189,7 @@ Future main(List args) async { ); // This file needs to exist, and be UTF8 line-parsable. - final String filePath = io.Platform.script.path; + final String filePath = io.Platform.script.toFilePath(); final List buildCommandsData = >[ { 'directory': '/unused', @@ -204,24 +206,20 @@ Future main(List args) async { final Command command = commands.first; expect(command.tidyPath, contains('clang/bin/clang-tidy')); final WorkerJob jobNoFix = command.createLintJob(null, false); - expect(jobNoFix.command, [ - '../../buildtools/mac-x64/clang/bin/clang-tidy', - filePath, - '--', - '', - filePath, - ]); + expect(jobNoFix.command[0], endsWith('../../buildtools/mac-x64/clang/bin/clang-tidy')); + expect(jobNoFix.command[1], endsWith(filePath.replaceAll('/', io.Platform.pathSeparator))); + expect(jobNoFix.command[2], '--'); + expect(jobNoFix.command[3], ''); + expect(jobNoFix.command[4], endsWith(filePath)); final WorkerJob jobWithFix = command.createLintJob(null, true); - expect(jobWithFix.command, [ - '../../buildtools/mac-x64/clang/bin/clang-tidy', - filePath, - '--fix', - '--format-style=file', - '--', - '', - filePath, - ]); + expect(jobWithFix.command[0], endsWith('../../buildtools/mac-x64/clang/bin/clang-tidy')); + expect(jobWithFix.command[1], endsWith(filePath.replaceAll('/', io.Platform.pathSeparator))); + expect(jobWithFix.command[2], '--fix'); + expect(jobWithFix.command[3], '--format-style=file'); + expect(jobWithFix.command[4], '--'); + expect(jobWithFix.command[5], ''); + expect(jobWithFix.command[6], endsWith(filePath)); }); test('Command getLintAction flags third_party files', () async { diff --git a/engine/src/flutter/tools/const_finder/test/const_finder_test.dart b/engine/src/flutter/tools/const_finder/test/const_finder_test.dart index 94b153d2c21..4289c584fb3 100644 --- a/engine/src/flutter/tools/const_finder/test/const_finder_test.dart +++ b/engine/src/flutter/tools/const_finder/test/const_finder_test.dart @@ -34,7 +34,7 @@ void expectInstances(dynamic value, dynamic expected) { } final String basePath = - path.canonicalize(path.join(path.dirname(Platform.script.path), '..')); + path.canonicalize(path.join(path.dirname(Platform.script.toFilePath()), '..')); final String fixtures = path.join(basePath, 'test', 'fixtures'); final String box = path.join(fixtures, 'lib', 'box.dart'); final String consts = path.join(fixtures, 'lib', 'consts.dart'); @@ -119,6 +119,9 @@ void _checkNonConsts() { classLibraryUri: 'package:const_finder_fixtures/target.dart', className: 'Target', ); + final String fixturesUrl = Platform.isWindows + ? '/$fixtures'.replaceAll(Platform.pathSeparator, '/') + : fixtures; expectInstances( finder.findInstances(), @@ -134,27 +137,27 @@ void _checkNonConsts() { ], 'nonConstantLocations': [ { - 'file': 'file://$fixtures/lib/consts_and_non.dart', + 'file': 'file://$fixturesUrl/lib/consts_and_non.dart', 'line': 14, 'column': 26, }, { - 'file': 'file://$fixtures/lib/consts_and_non.dart', + 'file': 'file://$fixturesUrl/lib/consts_and_non.dart', 'line': 16, 'column': 26, }, { - 'file': 'file://$fixtures/lib/consts_and_non.dart', + 'file': 'file://$fixturesUrl/lib/consts_and_non.dart', 'line': 16, 'column': 41, }, { - 'file': 'file://$fixtures/lib/consts_and_non.dart', + 'file': 'file://$fixturesUrl/lib/consts_and_non.dart', 'line': 17, 'column': 26, }, { - 'file': 'file://$fixtures/pkg/package.dart', + 'file': 'file://$fixturesUrl/pkg/package.dart', 'line': 14, 'column': 25, }