-
Notifications
You must be signed in to change notification settings - Fork 2.2k
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
Inline test failure messages #3040
Merged
PaulTaykalo
merged 28 commits into
realm:master
from
ZevEisenberg:feature/zeveisenberg/3035-improve-test-with-inline-failure-messages
Feb 2, 2020
Merged
Changes from all commits
Commits
Show all changes
28 commits
Select commit
Hold shift + click to select a range
77ddb0b
Add Example wrapper in order to display test failures inline when run…
ZevEisenberg 16ae3e4
Stop using Swift 5.1-only features so we can compile on Xcode 10.2.
ZevEisenberg c8ae950
Add workaround to make test valid.
ZevEisenberg d450701
Wrap strings in Example.
ZevEisenberg 4cb9cf3
Add Changelog entry.
ZevEisenberg 3349b4d
Delete typo'd quote mark.
ZevEisenberg ef7c1f0
Cleanup.
ZevEisenberg 53d3eb1
Fix incorrect examples.
ZevEisenberg 4d98c0b
Fix incorrect quote.
ZevEisenberg b1d7df1
Fix incorrect use of description in interpolated string.
ZevEisenberg e9ca45a
Add comment.
ZevEisenberg e9401c2
Wrap all examples in Example struct.
ZevEisenberg c2b5a84
Better and more complete capturing of line numbers.
ZevEisenberg 9b6c100
Fix broken test.
ZevEisenberg ee82639
Better test traceability.
ZevEisenberg dd45e24
Fix typo.
ZevEisenberg 312fd3a
Address or disable linting warnings.
ZevEisenberg e165d96
Fix failing tests.
ZevEisenberg 49eec02
Simplify.
ZevEisenberg 27e2e31
Remove unused import.
ZevEisenberg a474d26
Add documentation comments.
ZevEisenberg 4b9482c
Fix line lengths.
ZevEisenberg 6cd264c
Remove requirement that Example be Codable.
ZevEisenberg 44a7ebe
Remove optionals now that we do not need Codable conformance.
ZevEisenberg 80f97c8
Disable linter for a few cases.
ZevEisenberg dace1f2
Fix typo.
ZevEisenberg 0ec30db
Limit mutability and add copy-and-mutate utility functions.
ZevEisenberg f1f613b
Limit scope of mutability.
ZevEisenberg File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
/// Captures code and context information for an example of a triggering or | ||
/// non-triggering style | ||
public struct Example { | ||
/// The contents of the example | ||
public private(set) var code: String | ||
/// The path to the file where the example was created | ||
public private(set) var file: StaticString | ||
/// The line in the file where the example was created | ||
public var line: UInt | ||
} | ||
|
||
public extension Example { | ||
/// Create a new Example with the specified code, file, and line | ||
/// - Parameters: | ||
/// - code: The contents of the example | ||
/// - file: The path to the file where the example is located. | ||
/// Defaults to the file where this initializer is called. | ||
/// - line: The line in the file where the example is located. | ||
/// Defaults to the line where this initializer is called. | ||
init(_ code: String, file: StaticString = #file, line: UInt = #line) { | ||
self.code = code | ||
self.file = file | ||
self.line = line | ||
} | ||
|
||
/// Returns the same example, but with the `code` that is passed in | ||
/// - Parameter code: the new code to use in the modified example | ||
func with(code: String) -> Example { | ||
var new = self | ||
new.code = code | ||
return new | ||
} | ||
|
||
/// Returns a copy of the Example with all instances of the "↓" character removed. | ||
func removingViolationMarkers() -> Example { | ||
return with(code: code.replacingOccurrences(of: "↓", with: "")) | ||
} | ||
} | ||
|
||
extension Example: Hashable { | ||
public static func == (lhs: Example, rhs: Example) -> Bool { | ||
// Ignoring file/line metadata because two Examples could represent | ||
// the same idea, but captured at two different points in the code | ||
return lhs.code == rhs.code | ||
} | ||
|
||
public func hash(into hasher: inout Hasher) { | ||
// Ignoring file/line metadata because two Examples could represent | ||
// the same idea, but captured at two different points in the code | ||
hasher.combine(code) | ||
} | ||
} | ||
|
||
extension Example: Comparable { | ||
public static func < (lhs: Example, rhs: Example) -> Bool { | ||
return lhs.code < rhs.code | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Can just drop this line completely: https://github.com/realm/SwiftLint/blob/master/CONTRIBUTING.md#tracking-changes
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'm confused. That page says:
Many other changelog entries link to the issue or PR. Why drop this line?