-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added
lenient
command line option (#5801)
- Loading branch information
1 parent
f410ea5
commit 23d6a7c
Showing
8 changed files
with
119 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
72 changes: 72 additions & 0 deletions
72
Tests/SwiftLintFrameworkTests/LintOrAnalyzeOptionsTests.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
@testable import SwiftLintFramework | ||
import XCTest | ||
|
||
final class LintOrAnalyzeOptionsTests: XCTestCase { | ||
private typealias Leniency = LintOrAnalyzeOptions.Leniency | ||
|
||
func testLeniency() { | ||
let parameters = [ | ||
Leniency(strict: false, lenient: false), | ||
Leniency(strict: true, lenient: true), | ||
Leniency(strict: true, lenient: false), | ||
Leniency(strict: false, lenient: true), | ||
] | ||
|
||
for commandLine in parameters { | ||
let options = LintOrAnalyzeOptions(leniency: commandLine) | ||
for configuration in parameters { | ||
let leniency = options.leniency(strict: configuration.strict, lenient: configuration.lenient) | ||
if commandLine.strict { | ||
// Command line takes precedence. | ||
XCTAssertTrue(leniency.strict) | ||
if !commandLine.lenient { | ||
// `--strict` should disable configuration lenience. | ||
XCTAssertFalse(leniency.lenient) | ||
} | ||
} else if commandLine.lenient { | ||
// Command line takes precedence, and should override | ||
// `strict` in the configuration. | ||
XCTAssertTrue(leniency.lenient) | ||
XCTAssertFalse(leniency.strict) | ||
} else if configuration.strict { | ||
XCTAssertTrue(leniency.strict) | ||
} else if configuration.lenient { | ||
XCTAssertTrue(leniency.lenient) | ||
} | ||
} | ||
} | ||
} | ||
} | ||
|
||
private extension LintOrAnalyzeOptions { | ||
init(leniency: Leniency) { | ||
self.init(mode: .lint, | ||
paths: [], | ||
useSTDIN: true, | ||
configurationFiles: [], | ||
strict: leniency.strict, | ||
lenient: leniency.lenient, | ||
forceExclude: false, | ||
useExcludingByPrefix: false, | ||
useScriptInputFiles: false, | ||
useScriptInputFileLists: false, | ||
benchmark: false, | ||
reporter: nil, | ||
baseline: nil, | ||
writeBaseline: nil, | ||
workingDirectory: nil, | ||
quiet: false, | ||
output: nil, | ||
progress: false, | ||
cachePath: nil, | ||
ignoreCache: false, | ||
enableAllRules: false, | ||
onlyRule: [], | ||
autocorrect: false, | ||
format: false, | ||
compilerLogPath: nil, | ||
compileCommands: nil, | ||
checkForUpdates: false | ||
) | ||
} | ||
} |