Rendering errors with root causes in the widget layer should have a reference to the widget (#32511)

This commit is contained in:
chunhtai
2019-07-09 10:18:30 -07:00
committed by GitHub
parent 97b2c98642
commit a76e39f984
15 changed files with 506 additions and 37 deletions

View File

@@ -31,33 +31,44 @@ void main() {
testUsingContext('report nice errors for exceptions thrown within testWidgets()', () async {
Cache.flutterRoot = '../..';
return _testFile('exception_handling', automatedTestsDirectory, flutterTestDirectory);
}, skip: io.Platform.isWindows); // Dart on Windows has trouble with unicode characters in output
}, skip: io.Platform.isWindows); // TODO(chunhtai): Dart on Windows has trouble with unicode characters in output (#35425).
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); // Dart on Windows has trouble with unicode characters in output
}, skip: io.Platform.isWindows); // TODO(chunhtai): Dart on Windows has trouble with unicode characters in output (#35425).
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); // Dart on Windows has trouble with unicode characters in output
}, skip: io.Platform.isWindows); // TODO(chunhtai): Dart on Windows has trouble with unicode characters in output (#35425).
testUsingContext('report a nice error when a Ticker is left running', () async {
Cache.flutterRoot = '../..';
return _testFile('ticker', automatedTestsDirectory, flutterTestDirectory);
}, skip: io.Platform.isWindows); // Dart on Windows has trouble with unicode characters in output
}, skip: io.Platform.isWindows); // TODO(chunhtai): Dart on Windows has trouble with unicode characters in output (#35425).
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); // Dart on Windows has trouble with unicode characters in output
}, skip: io.Platform.isWindows); // TODO(chunhtai): Dart on Windows has trouble with unicode characters in output (#35425).
testUsingContext('report which user created widget caused the error', () async {
Cache.flutterRoot = '../..';
return _testFile('print_user_created_ancestor', automatedTestsDirectory, flutterTestDirectory,
extraArguments: const <String>['--track-widget-creation']);
}, skip: io.Platform.isWindows); // TODO(chunhtai): Dart on Windows has trouble with unicode characters in output (#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);
}, skip: io.Platform.isWindows); // TODO(chunhtai): Dart on Windows has trouble with unicode characters in output (#35425).
testUsingContext('run a test when its name matches a regexp', () async {
Cache.flutterRoot = '../..';
final ProcessResult result = await _runFlutterTest('filtering', automatedTestsDirectory, flutterTestDirectory,
extraArgs: const <String>['--name', 'inc.*de']);
extraArguments: const <String>['--name', 'inc.*de']);
if (!result.stdout.contains('+1: All tests passed'))
fail('unexpected output from test:\n\n${result.stdout}\n-- end stdout --\n\n');
expect(result.exitCode, 0);
@@ -66,7 +77,7 @@ void main() {
testUsingContext('run a test when its name contains a string', () async {
Cache.flutterRoot = '../..';
final ProcessResult result = await _runFlutterTest('filtering', automatedTestsDirectory, flutterTestDirectory,
extraArgs: const <String>['--plain-name', 'include']);
extraArguments: const <String>['--plain-name', 'include']);
if (!result.stdout.contains('+1: All tests passed'))
fail('unexpected output from test:\n\n${result.stdout}\n-- end stdout --\n\n');
expect(result.exitCode, 0);
@@ -75,7 +86,7 @@ void main() {
testUsingContext('test runs to completion', () async {
Cache.flutterRoot = '../..';
final ProcessResult result = await _runFlutterTest('trivial', automatedTestsDirectory, flutterTestDirectory,
extraArgs: const <String>['--verbose']);
extraArguments: const <String>['--verbose']);
if ((!result.stdout.contains('+1: All tests passed')) ||
(!result.stdout.contains('test 0: starting shell process')) ||
(!result.stdout.contains('test 0: deleting temporary directory')) ||
@@ -90,7 +101,13 @@ void main() {
});
}
Future<void> _testFile(String testName, String workingDirectory, String testDirectory, { Matcher exitCode }) async {
Future<void> _testFile(
String testName,
String workingDirectory,
String testDirectory, {
Matcher exitCode,
List<String> extraArguments = const <String>[],
}) async {
exitCode ??= isNonZero;
final String fullTestExpectation = fs.path.join(testDirectory, '${testName}_expectation.txt');
final File expectationFile = fs.file(fullTestExpectation);
@@ -100,7 +117,12 @@ Future<void> _testFile(String testName, String workingDirectory, String testDire
while (_testExclusionLock != null)
await _testExclusionLock;
final ProcessResult exec = await _runFlutterTest(testName, workingDirectory, testDirectory);
final ProcessResult exec = await _runFlutterTest(
testName,
workingDirectory,
testDirectory,
extraArguments: extraArguments,
);
expect(exec.exitCode, exitCode);
final List<String> output = exec.stdout.split('\n');
@@ -164,7 +186,7 @@ Future<ProcessResult> _runFlutterTest(
String testName,
String workingDirectory,
String testDirectory, {
List<String> extraArgs = const <String>[],
List<String> extraArguments = const <String>[],
}) async {
final String testFilePath = fs.path.join(testDirectory, '${testName}_test.dart');
@@ -177,7 +199,7 @@ Future<ProcessResult> _runFlutterTest(
fs.path.absolute(fs.path.join('bin', 'flutter_tools.dart')),
'test',
'--no-color',
...extraArgs,
...extraArguments,
testFilePath
];