diff --git a/dev/automated_tests/flutter_test/exception_handling_expectation.txt b/dev/automated_tests/flutter_test/exception_handling_expectation.txt index 18da868e75..b5600cb3a4 100644 --- a/dev/automated_tests/flutter_test/exception_handling_expectation.txt +++ b/dev/automated_tests/flutter_test/exception_handling_expectation.txt @@ -5,8 +5,8 @@ Who lives, who dies, who tells your story\? When the exception was thrown, this was the stack: #0 main. \(.+[/\\]dev[/\\]automated_tests[/\\]flutter_test[/\\]exception_handling_test\.dart:10:5\) - #1 .+ \(package:flutter_test[/\\]src[/\\]widget_tester\.dart:[0-9]+:[0-9]+\) + <> ^\(elided [0-9]+ frames.+$ <> @@ -24,8 +24,8 @@ Who lives, who dies, who tells your story\? When the exception was thrown, this was the stack: #0 main. \(.+[/\\]dev[/\\]automated_tests[/\\]flutter_test[/\\]exception_handling_test\.dart:13:5\) - #1 .+ \(package:flutter_test[/\\]src[/\\]widget_tester\.dart:[0-9]+:[0-9]+\) + <> ^\(elided [0-9]+ .+$ <> @@ -43,6 +43,8 @@ Who lives, who dies, who tells your story\? When the exception was thrown, this was the stack: #[0-9]+ +main. \(.+[/\\]dev[/\\]automated_tests[/\\]flutter_test[/\\]exception_handling_test\.dart:15:105\) +#[0-9]+ +.+ \(package:flutter_test[/\\]src[/\\]widget_tester\.dart:[0-9]+:[0-9]+\) +#[0-9]+ +.+ \(package:flutter_test[/\\]src[/\\]binding.dart:[0-9]+:[0-9]+\) #[0-9]+ +.+ \(package:flutter_test[/\\]src[/\\]binding.dart:[0-9]+:[0-9]+\) #[0-9]+ +.+ \(package:flutter_test[/\\]src[/\\]binding.dart:[0-9]+:[0-9]+\) #[0-9]+ +.+ \(package:flutter_test[/\\]src[/\\]binding.dart:[0-9]+:[0-9]+\) diff --git a/packages/flutter_tools/test/commands.shard/permeable/test_test.dart b/packages/flutter_tools/test/commands.shard/permeable/test_test.dart index 1d4ba13e97..78924d829e 100644 --- a/packages/flutter_tools/test/commands.shard/permeable/test_test.dart +++ b/packages/flutter_tools/test/commands.shard/permeable/test_test.dart @@ -3,7 +3,7 @@ // found in the LICENSE file. import 'dart:async'; -import 'dart:io' as io; +import 'dart:convert'; import 'package:flutter_tools/src/base/file_system.dart'; import 'package:flutter_tools/src/base/io.dart'; @@ -18,124 +18,117 @@ import '../../src/context.dart'; Future _testExclusionLock; void main() { - group('flutter test should', () { + final String automatedTestsDirectory = fs.path.join('..', '..', 'dev', 'automated_tests'); + final String flutterTestDirectory = fs.path.join(automatedTestsDirectory, 'flutter_test'); - final String automatedTestsDirectory = fs.path.join('..', '..', 'dev', 'automated_tests'); - final String flutterTestDirectory = fs.path.join(automatedTestsDirectory, 'flutter_test'); + testUsingContext('flutter test should not have extraneous error messages', () async { + Cache.flutterRoot = '../..'; + return _testFile('trivial_widget', automatedTestsDirectory, flutterTestDirectory, exitCode: isZero); + }); - testUsingContext('not have extraneous error messages', () async { - Cache.flutterRoot = '../..'; - return _testFile('trivial_widget', automatedTestsDirectory, flutterTestDirectory, exitCode: isZero); - }, skip: io.Platform.isLinux); // Flutter on Linux sometimes has problems with font resolution (#7224) + testUsingContext('flutter test should report nice errors for exceptions thrown within testWidgets()', () async { + Cache.flutterRoot = '../..'; + return _testFile('exception_handling', automatedTestsDirectory, flutterTestDirectory); + }); - testUsingContext('report nice errors for exceptions thrown within testWidgets()', () async { - Cache.flutterRoot = '../..'; - return _testFile('exception_handling', automatedTestsDirectory, flutterTestDirectory); - }, skip: true); // https://github.com/flutter/flutter/issues/46142 - // Note: was skip: skip: io.Platform.isWindows - // TODO(chunhtai): Remove Skip https://github.com/flutter/flutter/issues/35425. + testUsingContext('flutter test should report a nice error when a guarded function was called without await', () async { + Cache.flutterRoot = '../..'; + return _testFile('test_async_utils_guarded', automatedTestsDirectory, flutterTestDirectory); + }); - testUsingContext('report a nice error when a guarded function was called without await', () async { - Cache.flutterRoot = '../..'; - return _testFile('test_async_utils_guarded', automatedTestsDirectory, flutterTestDirectory); - }, skip: io.Platform.isWindows); // TODO(chunhtai): Remove Skip https://github.com/flutter/flutter/issues/35425. + testUsingContext('flutter test should report a nice error when an async function was called without await', () async { + Cache.flutterRoot = '../..'; + return _testFile('test_async_utils_unguarded', automatedTestsDirectory, flutterTestDirectory); + }); - testUsingContext('report a nice error when an async function was called without await', () async { - Cache.flutterRoot = '../..'; - return _testFile('test_async_utils_unguarded', automatedTestsDirectory, flutterTestDirectory); - }, skip: io.Platform.isWindows); // TODO(chunhtai): Remove Skip https://github.com/flutter/flutter/issues/35425. + testUsingContext('flutter test should report a nice error when a Ticker is left running', () async { + Cache.flutterRoot = '../..'; + return _testFile('ticker', automatedTestsDirectory, flutterTestDirectory); + }); - testUsingContext('report a nice error when a Ticker is left running', () async { - Cache.flutterRoot = '../..'; - return _testFile('ticker', automatedTestsDirectory, flutterTestDirectory); - }, skip: io.Platform.isWindows); // TODO(chunhtai): Remove Skip https://github.com/flutter/flutter/issues/35425. + testUsingContext('flutter test should report a nice error when a pubspec.yaml is missing a flutter_test dependency', () async { + final String missingDependencyTests = fs.path.join('..', '..', 'dev', 'missing_dependency_tests'); + Cache.flutterRoot = '../..'; + return _testFile('trivial', missingDependencyTests, missingDependencyTests); + }); - testUsingContext('report a nice error when a pubspec.yaml is missing a flutter_test dependency', () async { - final String missingDependencyTests = fs.path.join('..', '..', 'dev', 'missing_dependency_tests'); - Cache.flutterRoot = '../..'; - return _testFile('trivial', missingDependencyTests, missingDependencyTests); - }, skip: io.Platform.isWindows); // TODO(chunhtai): Remove Skip https://github.com/flutter/flutter/issues/35425. - - testUsingContext('report which user created widget caused the error', () async { - Cache.flutterRoot = '../..'; - return _testFile('print_user_created_ancestor', automatedTestsDirectory, flutterTestDirectory, - extraArguments: const ['--track-widget-creation']); - }, skip: io.Platform.isWindows); // TODO(chunhtai): Remove Skip https://github.com/flutter/flutter/issues/35425. - - testUsingContext('report which user created widget caused the error - no flag', () async { - Cache.flutterRoot = '../..'; - return _testFile('print_user_created_ancestor_no_flag', automatedTestsDirectory, flutterTestDirectory, - extraArguments: const ['--no-track-widget-creation']); - }, skip: io.Platform.isWindows); // TODO(chunhtai): Remove Skip https://github.com/flutter/flutter/issues/35425. - - testUsingContext('report correct created widget caused the error', () async { - Cache.flutterRoot = '../..'; - return _testFile('print_correct_local_widget', automatedTestsDirectory, flutterTestDirectory, + testUsingContext('flutter test should report which user created widget caused the error', () async { + Cache.flutterRoot = '../..'; + return _testFile('print_user_created_ancestor', automatedTestsDirectory, flutterTestDirectory, extraArguments: const ['--track-widget-creation']); - }, skip: io.Platform.isWindows); // TODO(chunhtai): Remove Skip https://github.com/flutter/flutter/issues/35425. + }); - testUsingContext('can load assets within its own package', () async { - Cache.flutterRoot = '../..'; - return _testFile('package_assets', automatedTestsDirectory, flutterTestDirectory, exitCode: isZero); - }, skip: true); // https://github.com/flutter/flutter/issues/46142 - // Note, was skip: io.Platform.isWindows + testUsingContext('flutter test should report which user created widget caused the error - no flag', () async { + Cache.flutterRoot = '../..'; + return _testFile('print_user_created_ancestor_no_flag', automatedTestsDirectory, flutterTestDirectory, + extraArguments: const ['--no-track-widget-creation']); + }); - testUsingContext('run a test when its name matches a regexp', () async { - Cache.flutterRoot = '../..'; - final ProcessResult result = await _runFlutterTest('filtering', automatedTestsDirectory, flutterTestDirectory, - extraArguments: const ['--name', 'inc.*de']); - if (!(result.stdout as String).contains('+1: All tests passed')) { - fail('unexpected output from test:\n\n${result.stdout}\n-- end stdout --\n\n'); - } - expect(result.exitCode, 0); - }); + testUsingContext('flutter test should report correct created widget caused the error', () async { + Cache.flutterRoot = '../..'; + return _testFile('print_correct_local_widget', automatedTestsDirectory, flutterTestDirectory, + extraArguments: const ['--track-widget-creation']); + }); - testUsingContext('run a test when its name contains a string', () async { - Cache.flutterRoot = '../..'; - final ProcessResult result = await _runFlutterTest('filtering', automatedTestsDirectory, flutterTestDirectory, - extraArguments: const ['--plain-name', 'include']); - if (!(result.stdout as String).contains('+1: All tests passed')) { - fail('unexpected output from test:\n\n${result.stdout}\n-- end stdout --\n\n'); - } - expect(result.exitCode, 0); - }); + testUsingContext('flutter test should can load assets within its own package', () async { + Cache.flutterRoot = '../..'; + return _testFile('package_assets', automatedTestsDirectory, flutterTestDirectory, exitCode: isZero); + }); - testUsingContext('test runs to completion', () async { - Cache.flutterRoot = '../..'; - final ProcessResult result = await _runFlutterTest('trivial', automatedTestsDirectory, flutterTestDirectory, - extraArguments: const ['--verbose']); - final String stdout = result.stdout as String; - if ((!stdout.contains('+1: All tests passed')) || - (!stdout.contains('test 0: starting shell process')) || - (!stdout.contains('test 0: deleting temporary directory')) || - (!stdout.contains('test 0: finished')) || - (!stdout.contains('test package returned with exit code 0'))) { - fail('unexpected output from test:\n\n${result.stdout}\n-- end stdout --\n\n'); - } - if ((result.stderr as String).isNotEmpty) { - fail('unexpected error output from test:\n\n${result.stderr}\n-- end stderr --\n\n'); - } - expect(result.exitCode, 0); - }); + testUsingContext('flutter test should run a test when its name matches a regexp', () async { + Cache.flutterRoot = '../..'; + final ProcessResult result = await _runFlutterTest('filtering', automatedTestsDirectory, flutterTestDirectory, + extraArguments: const ['--name', 'inc.*de']); + if (!(result.stdout as String).contains('+1: All tests passed')) { + fail('unexpected output from test:\n\n${result.stdout}\n-- end stdout --\n\n'); + } + expect(result.exitCode, 0); + }); - testUsingContext('run all tests inside of a directory with no trailing slash', () async { - Cache.flutterRoot = '../..'; - final ProcessResult result = await _runFlutterTest(null, automatedTestsDirectory, flutterTestDirectory + '/child_directory', - extraArguments: const ['--verbose']); - final String stdout = result.stdout as String; - if ((!stdout.contains('+2: All tests passed')) || - (!stdout.contains('test 0: starting shell process')) || - (!stdout.contains('test 0: deleting temporary directory')) || - (!stdout.contains('test 0: finished')) || - (!stdout.contains('test package returned with exit code 0'))) { - fail('unexpected output from test:\n\n${result.stdout}\n-- end stdout --\n\n'); - } - if ((result.stderr as String).isNotEmpty) { - fail('unexpected error output from test:\n\n${result.stderr}\n-- end stderr --\n\n'); - } - expect(result.exitCode, 0); - }); + testUsingContext('flutter test should run a test when its name contains a string', () async { + Cache.flutterRoot = '../..'; + final ProcessResult result = await _runFlutterTest('filtering', automatedTestsDirectory, flutterTestDirectory, + extraArguments: const ['--plain-name', 'include']); + if (!(result.stdout as String).contains('+1: All tests passed')) { + fail('unexpected output from test:\n\n${result.stdout}\n-- end stdout --\n\n'); + } + expect(result.exitCode, 0); + }); + testUsingContext('flutter test should test runs to completion', () async { + Cache.flutterRoot = '../..'; + final ProcessResult result = await _runFlutterTest('trivial', automatedTestsDirectory, flutterTestDirectory, + extraArguments: const ['--verbose']); + final String stdout = result.stdout as String; + if ((!stdout.contains('+1: All tests passed')) || + (!stdout.contains('test 0: starting shell process')) || + (!stdout.contains('test 0: deleting temporary directory')) || + (!stdout.contains('test 0: finished')) || + (!stdout.contains('test package returned with exit code 0'))) { + fail('unexpected output from test:\n\n${result.stdout}\n-- end stdout --\n\n'); + } + if ((result.stderr as String).isNotEmpty) { + fail('unexpected error output from test:\n\n${result.stderr}\n-- end stderr --\n\n'); + } + expect(result.exitCode, 0); + }); + + testUsingContext('flutter test should run all tests inside of a directory with no trailing slash', () async { + Cache.flutterRoot = '../..'; + final ProcessResult result = await _runFlutterTest(null, automatedTestsDirectory, flutterTestDirectory + '/child_directory', + extraArguments: const ['--verbose']); + final String stdout = result.stdout as String; + if ((!stdout.contains('+2: All tests passed')) || + (!stdout.contains('test 0: starting shell process')) || + (!stdout.contains('test 0: deleting temporary directory')) || + (!stdout.contains('test 0: finished')) || + (!stdout.contains('test package returned with exit code 0'))) { + fail('unexpected output from test:\n\n${result.stdout}\n-- end stdout --\n\n'); + } + if ((result.stderr as String).isNotEmpty) { + fail('unexpected error output from test:\n\n${result.stderr}\n-- end stderr --\n\n'); + } + expect(result.exitCode, 0); }); } @@ -269,6 +262,8 @@ Future _runFlutterTest( fs.path.join(dartSdkPath, 'bin', 'dart'), args, workingDirectory: workingDirectory, + stdoutEncoding: utf8, + stderrEncoding: utf8, ); } finally { _testExclusionLock = null;