Skip to content

Modify assertLint test helper to run via pipeline only. #788

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

Merged
merged 1 commit into from
Aug 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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