Skip to content

Commit 87d5fb2

Browse files
authored
Merge pull request #788 from shawnhyam/swift-format-ignore
Modify assertLint test helper to run via pipeline only.
2 parents b60a4ee + 01ac894 commit 87d5fb2

File tree

2 files changed

+19
-11
lines changed

2 files changed

+19
-11
lines changed

Tests/SwiftFormatTests/Rules/DontRepeatTypeInStaticPropertiesTests.swift

+18
Original file line numberDiff line numberDiff line change
@@ -75,4 +75,22 @@ final class DontRepeatTypeInStaticPropertiesTests: LintOrFormatRuleTestCase {
7575
]
7676
)
7777
}
78+
79+
80+
func testIgnoreSingleDecl() {
81+
assertLint(
82+
DontRepeatTypeInStaticProperties.self,
83+
"""
84+
struct Foo {
85+
// swift-format-ignore: DontRepeatTypeInStaticProperties
86+
static let defaultFoo: Int
87+
static let 1️⃣alternateFoo: Int
88+
}
89+
""",
90+
findings: [
91+
FindingSpec("1️⃣", message: "remove the suffix 'Foo' from the name of the variable 'alternateFoo'"),
92+
]
93+
)
94+
}
95+
7896
}

Tests/SwiftFormatTests/Rules/LintOrFormatRuleTestCase.swift

+1-11
Original file line numberDiff line numberDiff line change
@@ -42,16 +42,6 @@ class LintOrFormatRuleTestCase: DiagnosingTestCase {
4242
configuration: configuration,
4343
selection: .infinite,
4444
findingConsumer: { emittedFindings.append($0) })
45-
let linter = type.init(context: context)
46-
linter.walk(sourceFileSyntax)
47-
48-
assertFindings(
49-
expected: findings,
50-
markerLocations: markedText.markers,
51-
emittedFindings: emittedFindings,
52-
context: context,
53-
file: file,
54-
line: line)
5545

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

69-
// Check that pipeline produces the same findings as the isolated linter rule
59+
// Check that pipeline produces the expected findings
7060
assertFindings(
7161
expected: findings,
7262
markerLocations: markedText.markers,

0 commit comments

Comments
 (0)