Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't log stack traces to console on build failures #44966

Merged
merged 2 commits into from
Nov 18, 2019
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/flutter_tools/lib/src/commands/assemble.dart
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ class AssembleCommand extends FlutterCommand {
));
if (!result.success) {
for (MapEntry<String, ExceptionMeasurement> data in result.exceptions.entries) {
printError('Target ${data.key} failed: ${data.value.exception}', stackTrace: data.value.stackTrace);
printError('Target ${data.key} failed: ${data.value.exception}');
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Two comments:

  • I'm seeing a few other potentially similar cases in aot.dart, bundle.dart, and web/compile.dart.
  • Is there any way that an ExceptionMeasurement can indicate whether the stack trace should be printed?

}
throwToolExit('build failed.');
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,22 @@ void main() {
expect(commandRunner.run(<String>['assemble', '-o Output', 'undefined']), throwsA(isInstanceOf<ToolExit>()));
});

testbed.test('Does not log stack traces during build failure', () async {
final BufferLogger bufferLogger = logger;
final StackTrace testStackTrace = StackTrace.current;
when(buildSystem.build(any, any, buildSystemConfig: anyNamed('buildSystemConfig')))
.thenAnswer((Invocation invocation) async {
return BuildResult(success: false, exceptions: <String, ExceptionMeasurement>{
'hello': ExceptionMeasurement('hello', 'bar', testStackTrace),
});
});
final CommandRunner<void> commandRunner = createTestCommandRunner(AssembleCommand());

await expectLater(commandRunner.run(<String>['assemble', '-o Output', 'debug_macos_bundle_flutter_assets']), throwsA(isInstanceOf<ToolExit>()));
expect(bufferLogger.errorText, contains('bar'));
expect(bufferLogger.errorText, isNot(contains(testStackTrace.toString())));
});

testbed.test('Only writes input and output files when the values change', () async {
when(buildSystem.build(any, any, buildSystemConfig: anyNamed('buildSystemConfig')))
.thenAnswer((Invocation invocation) async {
Expand Down