Make automated_tests mostly ignore extraneous error messages (#14170)

* Ignore extraneous error messages outside of one skipped test

* Fix analysis error
This commit is contained in:
jcollins-g 2018-01-18 14:06:35 -08:00 committed by GitHub
parent f77826c5ee
commit 460dd00b72
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 23 additions and 5 deletions

View File

@ -1,4 +1,4 @@
[^═]*(this line contains the test framework's output with the clock and so forth)?
<<skip until matching line>>
══╡ EXCEPTION CAUGHT BY FLUTTER TEST FRAMEWORK ╞════════════════════════════════════════════════════
The following message was thrown running a test:
Who lives, who dies, who tells your story\?

View File

@ -1,4 +1,4 @@
[^═]*(this line contains the test framework's output with the clock and so forth)?
<<skip until matching line>>
══╡ 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\.

View File

@ -1,4 +1,5 @@
[^═]*(this line contains the test framework's output with the clock and so forth)?
<<skip until matching line>>
══╡ 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\.

View File

@ -1,4 +1,4 @@
[^═]*(this line contains the test framework's output with the clock and so forth)?
<<skip until matching line>>
══╡ EXCEPTION CAUGHT BY SCHEDULER LIBRARY ╞═════════════════════════════════════════════════════════
The following message was thrown:
An animation is still running even after the widget tree was disposed.

View File

@ -0,0 +1,2 @@
[0-9]+:[0-9]+ [+]0: - A trivial widget test
[0-9]+:[0-9]+ [+]1: All tests passed!

View File

@ -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 {});
}

View File

@ -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<Null> _testFile(String testName, String workingDirectory, String testDirectory) async {
Future<Null> _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<Null> _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<String> output = exec.stdout.split('\n');
if (output.first == 'Waiting for another flutter command to release the startup lock...')
output.removeAt(0);