-
Notifications
You must be signed in to change notification settings - Fork 224
Configurable package folding #650
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
Conversation
nex3
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This also needs tests in configuration_test.dart.
CHANGELOG.md
Outdated
| @@ -1,3 +1,8 @@ | |||
| ## 0.12.23 | |||
|
|
|||
| * Add a `fold_stack_frame` field for `dart_test.yaml`. This will | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"frames"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
doc/configuration.md
Outdated
|
|
||
| This field indicates which packages will be folded when producing stack traces. | ||
| Packages contained in the `exclude` option will be folded. If `only` is provided, | ||
| all packages not contained in this list will be folded. If no options are provided, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Long line.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
doc/configuration.md
Outdated
|
|
||
| ### `fold_stack_frames` | ||
|
|
||
| This field indicates which packages will be folded when producing stack traces. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think it'll be clear to an unfamiliar user what "folding" means in this context. Maybe "This field controls which packages' stack frames will be folded away when displaying stack traces." It would also be good to include an example stack trace.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
doc/configuration.md
Outdated
| This field indicates which packages will be folded when producing stack traces. | ||
| Packages contained in the `exclude` option will be folded. If `only` is provided, | ||
| all packages not contained in this list will be folded. If no options are provided, | ||
| we fold `package:test` and `package:stream_channel` by default. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This document doesn't use the second person elsewhere, so it probably shouldn't do so here. Maybe "By default, frames from the test package and the stream_channel package are folded."
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
doc/configuration.md
Outdated
| ```yaml | ||
| fold_stack_frames: | ||
| only: | ||
| - some_package |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: To match other lists in this doc, the -s should be aligned with the beginning of the keys.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
test/frontend/test_chain_test.dart
Outdated
| @@ -0,0 +1,103 @@ | |||
| // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
2017
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
| @@ -0,0 +1,25 @@ | |||
| import 'package:stack_trace/stack_trace.dart'; | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't forget the copyright header.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
test/frontend/test_chain_test.dart
Outdated
| throw "oh no"; | ||
| }); | ||
| } | ||
| """; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just create this file in a setUp() call.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
| ["Invalid option for fold_stack_frames value", "^^^^^^"])); | ||
| await test.shouldExit(exit_codes.data); | ||
| }); | ||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Test what happens if both only and except keys are set.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
test/frontend/test_chain_test.dart
Outdated
| var test = await runTest(["test.dart"]); | ||
| var testOutput = (await test.stdoutStream().toList()); | ||
| for (var output in testOutput) { | ||
| expect(output.contains('package:stream_channel'), isFalse); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd use the neverEmits() matcher for this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good call. Done.
| /// Converts [stackTrace] to a [Chain] following the test's configuration. | ||
| Chain testChain(StackTrace stackTrace, {bool verbose: false}) { | ||
| var testTrace = currentMapper(stackTrace); | ||
| void configureTestChaining( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Document this.
| if (onlyPackages != null) _onlyPackages = onlyPackages; | ||
| } | ||
|
|
||
| Chain terseChain(StackTrace stackTrace, {bool verbose: false}) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Document this as well.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
| }, value: (valueNode) { | ||
| if (valueNode is! YamlList || | ||
| (valueNode as YamlList).firstWhere((value) => value is! String, | ||
| orElse: () => null) != |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See section 16.33 of the spec. We don't have to worry about built-in identifiers, but we should enforce the syntactic requirements.
| 'Must be a list of strings.', | ||
| valueNode.span, | ||
| _source); | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The if statement that throws an exception if valueNode isn't correct.
lib/src/runner/remote_listener.dart
Outdated
| channel.sink.add({ | ||
| "type": "error", | ||
| "error": RemoteException.serialize(error, stackTrace) | ||
| "error": RemoteException.serialize(error, testChain(stackTrace)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You'll need to access the verboseTrace flag on the suite-level metadata that was passed in as part of the initial message.
| if (keyNode.value != "only" && keyNode.value != "except") { | ||
| throw new SourceSpanFormatException( | ||
| 'Must be "only" or "except".', keyNode.span, _source); | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Any statement of the form if (something about value) { throw } should probably be a call to _validate() instead.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
lib/src/runner/remote_listener.dart
Outdated
| } | ||
|
|
||
| /// Returns a [Set] from a JSON serialized list. | ||
| static Set<String> _setFromSerializedList(List<String> list) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: I'd call this _deserializeSet() to match other serialization functions.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
lib/src/util/stack_trace_mapper.dart
Outdated
|
|
||
| import 'dart:async'; | ||
| import 'package:collection/collection.dart'; | ||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This isn't where the newline should go. See Effective Dart.
| class StackTraceMapper { | ||
| /// The parsed source map. | ||
| final Mapping _mapping; | ||
| Mapping _mapping; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Mention in the documentation that this is initialized lazily in mapStackTrace().
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
| static Map<String, String> _serializablePackageConfigMap( | ||
| /// Converts a [packageConfigMap] into a format suitable for JSON | ||
| /// serialization. | ||
| static Map<String, String> _serializePackageConfigMap( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These shouldn't be static. Generally, don't make helpers static unless they need to be used in other static methods.
| Set<String> onlyPackages}) { | ||
| if (mapper != null) _mapper = mapper; | ||
| if (exceptPackages != null) _exceptPackages = exceptPackages; | ||
| if (onlyPackages != null) _onlyPackages = onlyPackages; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These != null checks are unnecessary.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The null check is necessary since we don't check for nullness in terseChain.
lib/src/runner/configuration.dart
Outdated
| _foldTraceExcept = _list(foldTraceExcept), | ||
| _foldTraceOnly = _list(foldTraceOnly), | ||
| _foldTraceExcept = foldTraceExcept != null | ||
| ? new Set.from(_list(foldTraceExcept)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just add a _set() helper method.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
| foldTraceExcept = new Set.from(other._foldTraceExcept) | ||
| .union(new Set.from(_foldTraceExcept)) | ||
| .toList(); | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I still think nested ifs would be clearer. Broken out, the differences between each condition get lost especially when some conditions duplicate logic in others.
| /// | ||
| /// The key `except` will correspond to the list of packages to fold. | ||
| /// The key `only` will correspond to the list of packages to keep in a | ||
| /// test [Chain]. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If the map only has string keys, the type annotation should indicate that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
| 'Must be a list of strings.', | ||
| valueNode.span, | ||
| _source); | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This still needs to be done.
|
@nex3 I think I have addressed all open comments. This UI is kind of terrible though. |
| foldTraceOnly = other._foldTraceOnly.intersection(_foldTraceOnly); | ||
| } | ||
|
|
||
| var foldTraceExcept = other._foldTraceExcept ?? _foldTraceExcept; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
At this point, I don't think it makes sense to set these by default since they'll always either be overridden or end up as null.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Discussed offline. There is a case where we want to default.
|
|
||
| _validate( | ||
| valueNode, | ||
| "Invalid package identifier", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"identifier" -> "name"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
| } | ||
| _validate( | ||
| valueNode, | ||
| "Folded packages must be strings", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These messages need trailing periods.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
| "Folded packages must be strings", | ||
| (valueList) => | ||
| valueList is YamlList && | ||
| !(valueList).any((value) => value is! String)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
valueList.every((value) => value is String)
Same below.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
| (valueList) => | ||
| valueList is YamlList && | ||
| !(valueList).any((value) => value is! String)); | ||
| (valueList).every((value) => value is String)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The parentheses around valueList are unnecessary.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Originally was casting. Fixed.
These constructors became identical in #650 so we can drop the private copy altogether.
These constructors became identical in #650 so we can drop the private copy altogether.
These constructors became identical in #650 so we can drop the private copy altogether.
This will close #416