Unverified Commit dc5a5c18 authored by Danny Tuppeny's avatar Danny Tuppeny Committed by GitHub

Start logger in startProgress to avoid assertion failure (#20814)

* Start logger in startProgress to avoid assertion failure

There are lots of places that create a Status() and all but two of them call ..start() immediately. This is one of the places that doesn't, which causes an assertion failure when running with --enable-asserts and the other is in the same file (I suspect it's also incorrect, but possibly it's never used - I'll look at that separately when I can trace some code that calls it).

Fixes #20812.

* Enable asserts for tools tests

* Fix lint

* Rename enableAsserts -> enableFlutterToolAsserts

To make it clearer that it only enables asserts for flutter_tools when set.
parent 1ba16d55
...@@ -294,7 +294,10 @@ Future<Null> _runSmokeTests() async { ...@@ -294,7 +294,10 @@ Future<Null> _runSmokeTests() async {
Future<Null> _runToolTests() async { Future<Null> _runToolTests() async {
await _runSmokeTests(); await _runSmokeTests();
await _pubRunTest(path.join(flutterRoot, 'packages', 'flutter_tools')); await _pubRunTest(
path.join(flutterRoot, 'packages', 'flutter_tools'),
enableFlutterToolAsserts: true,
);
print('${bold}DONE: All tests successful.$reset'); print('${bold}DONE: All tests successful.$reset');
} }
...@@ -346,6 +349,7 @@ Future<Null> _runCoverage() async { ...@@ -346,6 +349,7 @@ Future<Null> _runCoverage() async {
Future<Null> _pubRunTest( Future<Null> _pubRunTest(
String workingDirectory, { String workingDirectory, {
String testPath, String testPath,
bool enableFlutterToolAsserts = false
}) { }) {
final List<String> args = <String>['run', 'test', '-j1', '-rcompact']; final List<String> args = <String>['run', 'test', '-j1', '-rcompact'];
if (!hasColor) if (!hasColor)
...@@ -356,6 +360,14 @@ Future<Null> _pubRunTest( ...@@ -356,6 +360,14 @@ Future<Null> _pubRunTest(
if (new Directory(pubCache).existsSync()) { if (new Directory(pubCache).existsSync()) {
pubEnvironment['PUB_CACHE'] = pubCache; pubEnvironment['PUB_CACHE'] = pubCache;
} }
if (enableFlutterToolAsserts) {
// If an existing env variable exists append to it, but only if
// it doesn't appear to already include enable-asserts.
String toolsArgs = Platform.environment['FLUTTER_TOOL_ARGS'] ?? '';
if (!toolsArgs.contains('--enable-asserts'))
toolsArgs += ' --enable-asserts';
pubEnvironment['FLUTTER_TOOL_ARGS'] = toolsArgs.trim();
}
return _runCommand( return _runCommand(
pub, args, pub, args,
workingDirectory: workingDirectory, workingDirectory: workingDirectory,
......
...@@ -908,7 +908,7 @@ class _AppRunLogger extends Logger { ...@@ -908,7 +908,7 @@ class _AppRunLogger extends Logger {
'progressId': progressId, 'progressId': progressId,
'finished': true 'finished': true
}); });
}); })..start();
return _status; return _status;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment