Skip to content

Commit

Permalink
Change assertLint helper to run via the pipeline only.
Browse files Browse the repository at this point in the history
Standalone lint visitors don't check for swift-format-ignore markers,
so any test cases that use those markers will return different
results between standalone vs full pipeline. Since the app uses
the pipeline only, there is no value in running the rule standalone.
  • Loading branch information
shawnhyam committed Aug 2, 2024
1 parent f0d1167 commit 01ac894
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -75,4 +75,22 @@ final class DontRepeatTypeInStaticPropertiesTests: LintOrFormatRuleTestCase {
]
)
}


func testIgnoreSingleDecl() {
assertLint(
DontRepeatTypeInStaticProperties.self,
"""
struct Foo {
// swift-format-ignore: DontRepeatTypeInStaticProperties
static let defaultFoo: Int
static let 1️⃣alternateFoo: Int
}
""",
findings: [
FindingSpec("1️⃣", message: "remove the suffix 'Foo' from the name of the variable 'alternateFoo'"),
]
)
}

}
12 changes: 1 addition & 11 deletions Tests/SwiftFormatTests/Rules/LintOrFormatRuleTestCase.swift
Original file line number Diff line number Diff line change
Expand Up @@ -42,16 +42,6 @@ class LintOrFormatRuleTestCase: DiagnosingTestCase {
configuration: configuration,
selection: .infinite,
findingConsumer: { emittedFindings.append($0) })
let linter = type.init(context: context)
linter.walk(sourceFileSyntax)

assertFindings(
expected: findings,
markerLocations: markedText.markers,
emittedFindings: emittedFindings,
context: context,
file: file,
line: line)

var emittedPipelineFindings = [Finding]()
// Disable default rules, so only select rule runs in pipeline
Expand All @@ -66,7 +56,7 @@ class LintOrFormatRuleTestCase: DiagnosingTestCase {
operatorTable: OperatorTable.standardOperators,
assumingFileURL: URL(string: file.description)!)

// Check that pipeline produces the same findings as the isolated linter rule
// Check that pipeline produces the expected findings
assertFindings(
expected: findings,
markerLocations: markedText.markers,
Expand Down

0 comments on commit 01ac894

Please sign in to comment.