diff --git a/dev/automated_tests/flutter_test/exception_handling_expectation.txt b/dev/automated_tests/flutter_test/exception_handling_expectation.txt index abd98ec274..3a1c4c595d 100644 --- a/dev/automated_tests/flutter_test/exception_handling_expectation.txt +++ b/dev/automated_tests/flutter_test/exception_handling_expectation.txt @@ -1,4 +1,4 @@ -[^═]*(this line contains the test framework's output with the clock and so forth)? +<> ══╡ EXCEPTION CAUGHT BY FLUTTER TEST FRAMEWORK ╞════════════════════════════════════════════════════ The following message was thrown running a test: Who lives, who dies, who tells your story\? diff --git a/dev/automated_tests/flutter_test/test_async_utils_guarded_expectation.txt b/dev/automated_tests/flutter_test/test_async_utils_guarded_expectation.txt index c4e73d1d19..6cb6a93b63 100644 --- a/dev/automated_tests/flutter_test/test_async_utils_guarded_expectation.txt +++ b/dev/automated_tests/flutter_test/test_async_utils_guarded_expectation.txt @@ -1,4 +1,4 @@ -[^═]*(this line contains the test framework's output with the clock and so forth)? +<> ══╡ EXCEPTION CAUGHT BY FLUTTER TEST FRAMEWORK ╞════════════════════════════════════════════════════ The following assertion was thrown running a test: Guarded function conflict\. You must use "await" with all Future-returning test APIs\. diff --git a/dev/automated_tests/flutter_test/test_async_utils_unguarded_expectation.txt b/dev/automated_tests/flutter_test/test_async_utils_unguarded_expectation.txt index 2ecb5d078c..85362545bc 100644 --- a/dev/automated_tests/flutter_test/test_async_utils_unguarded_expectation.txt +++ b/dev/automated_tests/flutter_test/test_async_utils_unguarded_expectation.txt @@ -1,4 +1,5 @@ [^═]*(this line contains the test framework's output with the clock and so forth)? +<> ══╡ EXCEPTION CAUGHT BY FLUTTER TEST FRAMEWORK ╞════════════════════════════════════════════════════ The following assertion was thrown running a test: Guarded function conflict\. You must use "await" with all Future-returning test APIs\. diff --git a/dev/automated_tests/flutter_test/ticker_expectation.txt b/dev/automated_tests/flutter_test/ticker_expectation.txt index e75d5dadde..bb7495929e 100644 --- a/dev/automated_tests/flutter_test/ticker_expectation.txt +++ b/dev/automated_tests/flutter_test/ticker_expectation.txt @@ -1,4 +1,4 @@ -[^═]*(this line contains the test framework's output with the clock and so forth)? +<> ══╡ EXCEPTION CAUGHT BY SCHEDULER LIBRARY ╞═════════════════════════════════════════════════════════ The following message was thrown: An animation is still running even after the widget tree was disposed. diff --git a/dev/automated_tests/flutter_test/trivial_widget_expectation.txt b/dev/automated_tests/flutter_test/trivial_widget_expectation.txt new file mode 100644 index 0000000000..4661cd4000 --- /dev/null +++ b/dev/automated_tests/flutter_test/trivial_widget_expectation.txt @@ -0,0 +1,2 @@ +[0-9]+:[0-9]+ [+]0: - A trivial widget test +[0-9]+:[0-9]+ [+]1: All tests passed! diff --git a/dev/automated_tests/flutter_test/trivial_widget_test.dart b/dev/automated_tests/flutter_test/trivial_widget_test.dart new file mode 100644 index 0000000000..bfb1856608 --- /dev/null +++ b/dev/automated_tests/flutter_test/trivial_widget_test.dart @@ -0,0 +1,9 @@ +// Copyright 2017 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter_test/flutter_test.dart'; + +void main() { + testWidgets('A trivial widget test', (WidgetTester tester) async {}); +} diff --git a/packages/flutter_tools/test/commands/test_test.dart b/packages/flutter_tools/test/commands/test_test.dart index 1177096d18..3b6ef1c28b 100644 --- a/packages/flutter_tools/test/commands/test_test.dart +++ b/packages/flutter_tools/test/commands/test_test.dart @@ -23,6 +23,11 @@ void main() { final String automatedTestsDirectory = fs.path.join('..', '..', 'dev', 'automated_tests'); final String flutterTestDirectory = fs.path.join(automatedTestsDirectory, 'flutter_test'); + 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('report nice errors for exceptions thrown within testWidgets()', () async { Cache.flutterRoot = '../..'; return _testFile('exception_handling', automatedTestsDirectory, flutterTestDirectory); @@ -85,7 +90,8 @@ void main() { }); } -Future _testFile(String testName, String workingDirectory, String testDirectory) async { +Future _testFile(String testName, String workingDirectory, String testDirectory, {Matcher exitCode}) async { + exitCode ??= isNonZero; final String fullTestExpectation = fs.path.join(testDirectory, '${testName}_expectation.txt'); final File expectationFile = fs.file(fullTestExpectation); if (!expectationFile.existsSync()) @@ -96,7 +102,7 @@ Future _testFile(String testName, String workingDirectory, String testDire final ProcessResult exec = await _runFlutterTest(testName, workingDirectory, testDirectory); - expect(exec.exitCode, isNonZero); + expect(exec.exitCode, exitCode); final List output = exec.stdout.split('\n'); if (output.first == 'Waiting for another flutter command to release the startup lock...') output.removeAt(0);