-
-
Notifications
You must be signed in to change notification settings - Fork 6
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
Improve test coverage #13
Conversation
@@ -128,6 +111,7 @@ struct SafeDITool: AsyncParsableCommand { | |||
let swiftFilePaths = try String(contentsOfFile: swiftSourcesFilePath) | |||
.components(separatedBy: CharacterSet(arrayLiteral: ",")) | |||
for filePath in swiftFilePaths { | |||
guard !filePath.isEmpty else { continue } |
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.
Found this bug while increasing coverage! We had previously failed when building against an empty file list.
Codecov ReportAttention:
Additional details and impacted files@@ Coverage Diff @@
## main #13 +/- ##
==========================================
+ Coverage 97.71% 99.17% +1.46%
==========================================
Files 37 37
Lines 7909 7924 +15
==========================================
+ Hits 7728 7859 +131
+ Misses 181 65 -116
|
@@ -57,9 +57,8 @@ public final class InstantiableVisitor: SyntaxVisitor { | |||
let patterns = node | |||
.bindings | |||
.filter { | |||
$0.initializer == nil |
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 check was duplicative with isOptionalOrInitialized
below
@@ -57,9 +57,8 @@ public final class InstantiableVisitor: SyntaxVisitor { | |||
let patterns = node | |||
.bindings | |||
.filter { | |||
$0.initializer == nil | |||
&& $0.accessorBlock == nil | |||
&& !$0.isOptionalAndUninitialized |
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.
isOptionalAndUninitialized
was named incorrectly. It was really checking whether something was optional or uninitialized
@@ -542,9 +542,9 @@ final class TypeDescriptionTests: XCTestCase { | |||
XCTAssertEqual(typeDescription.asSource, "() async throws -> ()") | |||
} | |||
|
|||
func test_asSource_whenDescribingAnUnknownCase_returnsTheProvidedStringWithWhitespaceStripped() { |
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.
turns out we're not stripping leading whitespace. But that's honestly fine since we have no valid, compiling cases that result in an .unknown
type.
This test wasn't previously testing the .unknown
case, but rather the .simple
case.
Merging this without review since we aren't changing API – we're just improving coverage. |
Exercises more of the SafeDI library via tests, and discovers/fixes an issue where an source empty file list in the CSV would cause an error.
There's also a little code cleanup along the way here.