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

Improve test coverage #13

Merged
merged 8 commits into from
Jan 13, 2024
Merged

Improve test coverage #13

merged 8 commits into from
Jan 13, 2024

Conversation

dfed
Copy link
Owner

@dfed dfed commented Jan 13, 2024

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.

@@ -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 }
Copy link
Owner Author

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.

Copy link

codecov bot commented Jan 13, 2024

Codecov Report

Attention: 2 lines in your changes are missing coverage. Please review.

Comparison is base (41bab0c) 97.71% compared to head (a2dcd57) 99.17%.

Additional details and impacted files

Impacted file tree graph

@@            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     
Files Coverage Δ
...re/Extensions/PatternBindingSyntaxExtensions.swift 100.00% <100.00%> (+16.66%) ⬆️
...afeDICore/Generators/DependencyTreeGenerator.swift 96.63% <100.00%> (ø)
...rces/SafeDICore/Visitors/InstantiableVisitor.swift 97.64% <100.00%> (-0.53%) ⬇️
Sources/SafeDITool/SafeDITool.swift 100.00% <100.00%> (+58.88%) ⬆️
Tests/SafeDIToolTests/SafeDIToolTests.swift 100.00% <100.00%> (ø)
Sources/SafeDICore/Models/TypeDescription.swift 96.73% <66.66%> (+3.13%) ⬆️
Tests/SafeDICoreTests/TypeDescriptionTests.swift 99.82% <94.11%> (-0.18%) ⬇️

... and 2 files with indirect coverage changes

@@ -57,9 +57,8 @@ public final class InstantiableVisitor: SyntaxVisitor {
let patterns = node
.bindings
.filter {
$0.initializer == nil
Copy link
Owner Author

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
Copy link
Owner Author

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() {
Copy link
Owner Author

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.

@dfed dfed marked this pull request as ready for review January 13, 2024 19:51
@dfed
Copy link
Owner Author

dfed commented Jan 13, 2024

Merging this without review since we aren't changing API – we're just improving coverage.

@dfed dfed merged commit 7968933 into main Jan 13, 2024
6 checks passed
@dfed dfed deleted the dfed--improve-coverage branch January 13, 2024 19:54
@dfed dfed self-assigned this Jan 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant