Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in
Toggle navigation
F
Front-End
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
abdullh.alsoleman
Front-End
Commits
868c4d8c
Unverified
Commit
868c4d8c
authored
Jun 23, 2020
by
Dan Field
Committed by
GitHub
Jun 23, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix issue with stack traces getting mangled (#59900)
parent
2a573a32
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
79 additions
and
0 deletions
+79
-0
assertions.dart
packages/flutter/lib/src/foundation/assertions.dart
+22
-0
binding.dart
packages/flutter_test/lib/src/binding.dart
+5
-0
bindings_async_gap_test.dart
packages/flutter_test/test/bindings_async_gap_test.dart
+52
-0
No files found.
packages/flutter/lib/src/foundation/assertions.dart
View file @
868c4d8c
...
...
@@ -389,6 +389,28 @@ class FlutterErrorDetails with Diagnosticable {
this
.
silent
=
false
,
});
/// Creates a copy of the error details but with the given fields replaced
/// with new values.
FlutterErrorDetails
copyWith
({
DiagnosticsNode
context
,
dynamic
exception
,
InformationCollector
informationCollector
,
String
library
,
bool
silent
,
StackTrace
stack
,
IterableFilter
<
String
>
stackFilter
,
})
{
return
FlutterErrorDetails
(
context:
context
??
this
.
context
,
exception:
exception
??
this
.
exception
,
informationCollector:
informationCollector
??
this
.
informationCollector
,
library
:
library
??
this
.
library
,
silent:
silent
??
this
.
silent
,
stack:
stack
??
this
.
stack
,
stackFilter:
stackFilter
??
this
.
stackFilter
,
);
}
/// Transformers to transform [DiagnosticsNode] in [DiagnosticPropertiesBuilder]
/// into a more descriptive form.
///
...
...
packages/flutter_test/lib/src/binding.dart
View file @
868c4d8c
...
...
@@ -579,6 +579,10 @@ abstract class TestWidgetsFlutterBinding extends BindingBase
// our main future completing.
assert
(
Zone
.
current
==
_parentZone
);
if
(
_pendingExceptionDetails
!=
null
)
{
assert
(
_unmangle
(
_pendingExceptionDetails
.
stack
)
==
_pendingExceptionDetails
.
stack
,
'The test binding presented an unmangled stack trace to the framework.'
,
);
debugPrint
=
debugPrintOverride
;
// just in case the test overrides it -- otherwise we won't see the error!
reportTestException
(
_pendingExceptionDetails
,
testDescription
);
_pendingExceptionDetails
=
null
;
...
...
@@ -611,6 +615,7 @@ abstract class TestWidgetsFlutterBinding extends BindingBase
_oldExceptionHandler
=
FlutterError
.
onError
;
int
_exceptionCount
=
0
;
// number of un-taken exceptions
FlutterError
.
onError
=
(
FlutterErrorDetails
details
)
{
details
=
details
.
copyWith
(
stack:
_unmangle
(
details
.
stack
));
if
(
_pendingExceptionDetails
!=
null
)
{
debugPrint
=
debugPrintOverride
;
// just in case the test overrides it -- otherwise we won't see the errors!
if
(
_exceptionCount
==
0
)
{
...
...
packages/flutter_test/test/bindings_async_gap_test.dart
0 → 100644
View file @
868c4d8c
// Copyright 2014 The Flutter 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
'dart:async'
;
import
'package:flutter/foundation.dart'
;
import
'package:flutter_test/flutter_test.dart'
;
import
'package:stack_trace/stack_trace.dart'
as
stack_trace
;
Future
<
void
>
main
()
async
{
test
(
'demangles stacks'
,
()
async
{
// Test that the tester bindings unmangle stacks that come in as
// package:stack_trace types.
// Uses runTest directly so that the test does not get hung up waiting for
// the error reporter to be reset to the original one.
final
Completer
<
FlutterErrorDetails
>
errorCompleter
=
Completer
<
FlutterErrorDetails
>();
final
TestExceptionReporter
oldReporter
=
reportTestException
;
reportTestException
=
(
FlutterErrorDetails
details
,
String
testDescription
)
{
errorCompleter
.
complete
(
details
);
reportTestException
=
oldReporter
;
};
final
AutomatedTestWidgetsFlutterBinding
binding
=
AutomatedTestWidgetsFlutterBinding
();
await
binding
.
runTest
(()
async
{
final
Completer
<
String
>
completer
=
Completer
<
String
>();
completer
.
future
.
then
(
(
String
value
)
{},
onError:
(
dynamic
error
,
StackTrace
stack
)
{
assert
(
stack
is
stack_trace
.
Chain
);
FlutterError
.
reportError
(
FlutterErrorDetails
(
exception:
error
,
stack:
stack
,
));
}
);
completer
.
completeError
(
const
CustomException
());
},
null
);
final
FlutterErrorDetails
details
=
await
errorCompleter
.
future
;
expect
(
details
,
isNotNull
);
expect
(
details
.
exception
,
isA
<
CustomException
>());
reportTestException
=
oldReporter
;
});
}
class
CustomException
implements
Exception
{
const
CustomException
();
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment