Navigation Menu

Skip to content

Commit

Permalink
Merged by Peril
Browse files Browse the repository at this point in the history
Support danger swift options and don't pass them to danger ci
  • Loading branch information
peril-staging[bot] committed Mar 26, 2019
2 parents 0456d98 + f908359 commit e156cea
Show file tree
Hide file tree
Showing 6 changed files with 227 additions and 269 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Expand Up @@ -13,6 +13,7 @@

## Master

- Support danger swift options and don't pass them to danger ci [@f-meloni][] - [#215](https://github.com/danger/swift/pull/215)
- Support swift 5.0 on OSX [@f-meloni][] - [#210](https://github.com/danger/swift/pull/210)

## 1.5.0
Expand Down
15 changes: 13 additions & 2 deletions Sources/Runner/Commands/RunDangerJS.swift
Expand Up @@ -18,8 +18,19 @@ func runDangerJSCommandToRunDangerSwift(_ command: DangerCommand, logger: Logger
proc.environment = ProcessInfo.processInfo.environment
proc.launchPath = dangerJS

let unusedArgs = CommandLine.arguments.filter { arg in
!arg.contains("danger-swift") && arg != command.rawValue
let dangerOptionsIndexes = DangerSwiftOptions.allCases
.compactMap { ($0, CommandLine.arguments.firstIndex(of: $0.rawValue)) }

let unusedArgs = CommandLine.arguments.enumerated().compactMap { index, arg -> String? in
if dangerOptionsIndexes.contains(where: { index == $0.1 || ($0.0.hasParameter && index + 1 == $0.1) }) {
return nil
}

if arg.contains("danger-swift"), arg == command.rawValue {
return nil
}

return arg
}

var dangerSwiftCommand = "danger-swift"
Expand Down
12 changes: 12 additions & 0 deletions Sources/RunnerLib/DangerSwiftOptions.swift
@@ -0,0 +1,12 @@
// Options handled directly by Danger swift and not sent back to Danger JS

public enum DangerSwiftOptions: String, CaseIterable {
case dangerJSPath = "--danger-js-path"

public var hasParameter: Bool {
switch self {
case .dangerJSPath:
return true
}
}
}
2 changes: 1 addition & 1 deletion Sources/RunnerLib/GetDangerJSPath.swift
Expand Up @@ -3,7 +3,7 @@ import Logger
import ShellOut

public func getDangerCommandPath(logger: Logger, args: [String] = CommandLine.arguments, shellOutExecutor: ShellOutExecuting = ShellOutExecutor()) throws -> String {
if let dangerJSPathOptionIndex = args.firstIndex(of: "--danger-js-path"),
if let dangerJSPathOptionIndex = args.firstIndex(of: DangerSwiftOptions.dangerJSPath.rawValue),
dangerJSPathOptionIndex + 1 < args.count {
return args[dangerJSPathOptionIndex + 1]
} else {
Expand Down
282 changes: 123 additions & 159 deletions Tests/DangerTests/XCTestManifests.swift
@@ -1,177 +1,141 @@
#if !canImport(ObjectiveC)
import XCTest
import XCTest

extension BitBucketServerTests {
// DO NOT MODIFY: This is autogenerated, use:
// `swift test --generate-linuxmain`
// to regenerate.
static let __allTests__BitBucketServerTests = [
("testItParsesTheBitBucketActivities", testItParsesTheBitBucketActivities),
("testItParsesTheBitBucketComments", testItParsesTheBitBucketComments),
("testItParsesTheBitBucketCommits", testItParsesTheBitBucketCommits),
("testItParsesTheBitBucketMetadata", testItParsesTheBitBucketMetadata),
("testItParsesTheBitBucketPullRequest", testItParsesTheBitBucketPullRequest),
]
}
extension BitBucketServerTests {
static let __allTests = [
("testItParsesTheBitBucketActivities", testItParsesTheBitBucketActivities),
("testItParsesTheBitBucketComments", testItParsesTheBitBucketComments),
("testItParsesTheBitBucketCommits", testItParsesTheBitBucketCommits),
("testItParsesTheBitBucketMetadata", testItParsesTheBitBucketMetadata),
("testItParsesTheBitBucketPullRequest", testItParsesTheBitBucketPullRequest),
]
}

extension DangerDSLTests {
// DO NOT MODIFY: This is autogenerated, use:
// `swift test --generate-linuxmain`
// to regenerate.
static let __allTests__DangerDSLTests = [
("testDangerfileResults", testDangerfileResults),
("testFileMapWorksCorrectly", testFileMapWorksCorrectly),
("testGithubFixtureDSL", testGithubFixtureDSL),
("testItParsesCorrectlyTheDangerDSLWhenThePRIsOnBitBucketServer", testItParsesCorrectlyTheDangerDSLWhenThePRIsOnBitBucketServer),
("testItParsesCorrectlyTheDangerDSLWhenThePRIsOnGithubEnterprise", testItParsesCorrectlyTheDangerDSLWhenThePRIsOnGithubEnterprise),
]
}
extension DangerDSLTests {
static let __allTests = [
("testDangerfileResults", testDangerfileResults),
("testFileMapWorksCorrectly", testFileMapWorksCorrectly),
("testGithubFixtureDSL", testGithubFixtureDSL),
("testItParsesCorrectlyTheDangerDSLWhenThePRIsOnBitBucketServer", testItParsesCorrectlyTheDangerDSLWhenThePRIsOnBitBucketServer),
("testItParsesCorrectlyTheDangerDSLWhenThePRIsOnGithubEnterprise", testItParsesCorrectlyTheDangerDSLWhenThePRIsOnGithubEnterprise),
]
}

extension DangerSwiftLintTests {
// DO NOT MODIFY: This is autogenerated, use:
// `swift test --generate-linuxmain`
// to regenerate.
static let __allTests__DangerSwiftLintTests = [
("testDoNotExecuteSwiftlintWhenNoFilesToCheck", testDoNotExecuteSwiftlintWhenNoFilesToCheck),
("testExecutesSwiftLintWhenLintingAllFiles", testExecutesSwiftLintWhenLintingAllFiles),
("testExecutesSwiftLintWhenLintingAllFilesWithDirectoryPassed", testExecutesSwiftLintWhenLintingAllFilesWithDirectoryPassed),
("testExecutesSwiftLintWithConfigWhenPassed", testExecutesSwiftLintWithConfigWhenPassed),
("testExecutesSwiftLintWithDirectoryPassed", testExecutesSwiftLintWithDirectoryPassed),
("testExecutesTheShell", testExecutesTheShell),
("testExecutesTheShellWithCustomSwiftLintPath", testExecutesTheShellWithCustomSwiftLintPath),
("testExecuteSwiftLintInInlineMode", testExecuteSwiftLintInInlineMode),
("testExecuteSwiftWithStructAndInlineMode", testExecuteSwiftWithStructAndInlineMode),
("testFiltersOnSwiftFiles", testFiltersOnSwiftFiles),
("testMarkdownReporting", testMarkdownReporting),
("testMarkdownReportingInStrictMode", testMarkdownReportingInStrictMode),
("testPrintsNoMarkdownIfNoViolations", testPrintsNoMarkdownIfNoViolations),
("testQuotesPathArguments", testQuotesPathArguments),
("testViolations", testViolations),
]
}
extension DangerSwiftLintTests {
static let __allTests = [
("testDoNotExecuteSwiftlintWhenNoFilesToCheck", testDoNotExecuteSwiftlintWhenNoFilesToCheck),
("testExecutesSwiftLintWhenLintingAllFiles", testExecutesSwiftLintWhenLintingAllFiles),
("testExecutesSwiftLintWhenLintingAllFilesWithDirectoryPassed", testExecutesSwiftLintWhenLintingAllFilesWithDirectoryPassed),
("testExecutesSwiftLintWithConfigWhenPassed", testExecutesSwiftLintWithConfigWhenPassed),
("testExecutesSwiftLintWithDirectoryPassed", testExecutesSwiftLintWithDirectoryPassed),
("testExecutesTheShell", testExecutesTheShell),
("testExecutesTheShellWithCustomSwiftLintPath", testExecutesTheShellWithCustomSwiftLintPath),
("testExecuteSwiftLintInInlineMode", testExecuteSwiftLintInInlineMode),
("testExecuteSwiftWithStructAndInlineMode", testExecuteSwiftWithStructAndInlineMode),
("testFiltersOnSwiftFiles", testFiltersOnSwiftFiles),
("testMarkdownReporting", testMarkdownReporting),
("testMarkdownReportingInStrictMode", testMarkdownReportingInStrictMode),
("testPrintsNoMarkdownIfNoViolations", testPrintsNoMarkdownIfNoViolations),
("testQuotesPathArguments", testQuotesPathArguments),
("testViolations", testViolations),
]
}

extension DangerUtilsLineSearchTests {
// DO NOT MODIFY: This is autogenerated, use:
// `swift test --generate-linuxmain`
// to regenerate.
static let __allTests__DangerUtilsLineSearchTests = [
("testItReturnsAnEmptyArrayIfNoResultsAreFound", testItReturnsAnEmptyArrayIfNoResultsAreFound),
("testItReturnsTheCorrectResultsIfTheSearchedStringIsPresent", testItReturnsTheCorrectResultsIfTheSearchedStringIsPresent),
]
}
extension DangerUtilsLineSearchTests {
static let __allTests = [
("testItReturnsAnEmptyArrayIfNoResultsAreFound", testItReturnsAnEmptyArrayIfNoResultsAreFound),
("testItReturnsTheCorrectResultsIfTheSearchedStringIsPresent", testItReturnsTheCorrectResultsIfTheSearchedStringIsPresent),
]
}

extension DateFormatterExtensionTests {
// DO NOT MODIFY: This is autogenerated, use:
// `swift test --generate-linuxmain`
// to regenerate.
static let __allTests__DateFormatterExtensionTests = [
("test_DateFormatter_dateFromString", test_DateFormatter_dateFromString),
("test_DateFormatter_nilFromInvalidString", test_DateFormatter_nilFromInvalidString),
]
}
extension DateFormatterExtensionTests {
static let __allTests = [
("test_DateFormatter_dateFromString", test_DateFormatter_dateFromString),
("test_DateFormatter_nilFromInvalidString", test_DateFormatter_nilFromInvalidString),
]
}

extension FileTests {
// DO NOT MODIFY: This is autogenerated, use:
// `swift test --generate-linuxmain`
// to regenerate.
static let __allTests__FileTests = [
("test_fileType_forHFile", test_fileType_forHFile),
("test_fileType_forJSON", test_fileType_forJSON),
("test_fileType_forM", test_fileType_forM),
("test_fileType_forMarkdown", test_fileType_forMarkdown),
("test_fileType_forMM", test_fileType_forMM),
("test_fileType_forPbxproj", test_fileType_forPbxproj),
("test_fileType_forPlist", test_fileType_forPlist),
("test_fileType_forStoryboard", test_fileType_forStoryboard),
("test_fileType_forSwift", test_fileType_forSwift),
("test_fileType_forXCScheme", test_fileType_forXCScheme),
("test_fileType_forYAML", test_fileType_forYAML),
("test_fileType_forYML", test_fileType_forYML),
("test_fileType_withMultipleDots", test_fileType_withMultipleDots),
]
}
extension FileTests {
static let __allTests = [
("test_fileType_forHFile", test_fileType_forHFile),
("test_fileType_forJSON", test_fileType_forJSON),
("test_fileType_forM", test_fileType_forM),
("test_fileType_forMarkdown", test_fileType_forMarkdown),
("test_fileType_forMM", test_fileType_forMM),
("test_fileType_forPbxproj", test_fileType_forPbxproj),
("test_fileType_forPlist", test_fileType_forPlist),
("test_fileType_forStoryboard", test_fileType_forStoryboard),
("test_fileType_forSwift", test_fileType_forSwift),
("test_fileType_forXCScheme", test_fileType_forXCScheme),
("test_fileType_forYAML", test_fileType_forYAML),
("test_fileType_forYML", test_fileType_forYML),
("test_fileType_withMultipleDots", test_fileType_withMultipleDots),
]
}

extension FileTypeTests {
// DO NOT MODIFY: This is autogenerated, use:
// `swift test --generate-linuxmain`
// to regenerate.
static let __allTests__FileTypeTests = [
("test_extension_matchesRawValue", test_extension_matchesRawValue),
]
}
extension FileTypeTests {
static let __allTests = [
("test_extension_matchesRawValue", test_extension_matchesRawValue),
]
}

extension GitHubTests {
// DO NOT MODIFY: This is autogenerated, use:
// `swift test --generate-linuxmain`
// to regenerate.
static let __allTests__GitHubTests = [
("test_GitHub_decode", test_GitHub_decode),
("test_GitHubCommit_decode", test_GitHubCommit_decode),
("test_GitHubIssue_decode", test_GitHubIssue_decode),
("test_GitHubIssueLabel_decode", test_GitHubIssueLabel_decode),
("test_GitHubMergeRef_decode", test_GitHubMergeRef_decode),
("test_GitHubMilestone_decodeWithAllParameters", test_GitHubMilestone_decodeWithAllParameters),
("test_GitHubMilestone_decodeWithSomeParameters", test_GitHubMilestone_decodeWithSomeParameters),
("test_GitHubPR_decode", test_GitHubPR_decode),
("test_GitHubRepo_decode", test_GitHubRepo_decode),
("test_GitHubReview_decode", test_GitHubReview_decode),
("test_GitHubTeam_decode", test_GitHubTeam_decode),
("test_GitHubUser_decode", test_GitHubUser_decode),
]
}
extension GitHubTests {
static let __allTests = [
("test_GitHub_decode", test_GitHub_decode),
("test_GitHubCommit_decode", test_GitHubCommit_decode),
("test_GitHubIssue_decode", test_GitHubIssue_decode),
("test_GitHubIssueLabel_decode", test_GitHubIssueLabel_decode),
("test_GitHubMergeRef_decode", test_GitHubMergeRef_decode),
("test_GitHubMilestone_decodeWithAllParameters", test_GitHubMilestone_decodeWithAllParameters),
("test_GitHubMilestone_decodeWithSomeParameters", test_GitHubMilestone_decodeWithSomeParameters),
("test_GitHubPR_decode", test_GitHubPR_decode),
("test_GitHubRepo_decode", test_GitHubRepo_decode),
("test_GitHubReview_decode", test_GitHubReview_decode),
("test_GitHubTeam_decode", test_GitHubTeam_decode),
("test_GitHubUser_decode", test_GitHubUser_decode),
]
}

extension GitTests {
// DO NOT MODIFY: This is autogenerated, use:
// `swift test --generate-linuxmain`
// to regenerate.
static let __allTests__GitTests = [
("test", test),
]
}
extension GitTests {
static let __allTests = [
("test", test),
]
}

extension NSRegularExpressionExtensionsTests {
// DO NOT MODIFY: This is autogenerated, use:
// `swift test --generate-linuxmain`
// to regenerate.
static let __allTests__NSRegularExpressionExtensionsTests = [
("test_firstMatchingString_failingRegex", test_firstMatchingString_failingRegex),
("test_firstMatchingString_passingRegex", test_firstMatchingString_passingRegex),
]
}
extension NSRegularExpressionExtensionsTests {
static let __allTests = [
("test_firstMatchingString_failingRegex", test_firstMatchingString_failingRegex),
("test_firstMatchingString_passingRegex", test_firstMatchingString_passingRegex),
]
}

extension SwiftlintDefaultPathTests {
// DO NOT MODIFY: This is autogenerated, use:
// `swift test --generate-linuxmain`
// to regenerate.
static let __allTests__SwiftlintDefaultPathTests = [
("testItReturnsTheSPMCommandIfThePackageContainsTheSwiftlintDependency", testItReturnsTheSPMCommandIfThePackageContainsTheSwiftlintDependency),
("testItReturnsTheSwiftlintCLICommandIfThePackageContainsTheSwiftlintDependency", testItReturnsTheSwiftlintCLICommandIfThePackageContainsTheSwiftlintDependency),
]
}
extension SwiftlintDefaultPathTests {
static let __allTests = [
("testItReturnsTheSPMCommandIfThePackageContainsTheSwiftlintDependency", testItReturnsTheSPMCommandIfThePackageContainsTheSwiftlintDependency),
("testItReturnsTheSwiftlintCLICommandIfThePackageContainsTheSwiftlintDependency", testItReturnsTheSwiftlintCLICommandIfThePackageContainsTheSwiftlintDependency),
]
}

extension ViolnationTests {
// DO NOT MODIFY: This is autogenerated, use:
// `swift test --generate-linuxmain`
// to regenerate.
static let __allTests__ViolnationTests = [
("testDecoding", testDecoding),
]
}
extension ViolnationTests {
static let __allTests = [
("testDecoding", testDecoding),
]
}

#if !os(macOS)
public func __allTests() -> [XCTestCaseEntry] {
return [
testCase(BitBucketServerTests.__allTests__BitBucketServerTests),
testCase(DangerDSLTests.__allTests__DangerDSLTests),
testCase(DangerSwiftLintTests.__allTests__DangerSwiftLintTests),
testCase(DangerUtilsLineSearchTests.__allTests__DangerUtilsLineSearchTests),
testCase(DateFormatterExtensionTests.__allTests__DateFormatterExtensionTests),
testCase(FileTests.__allTests__FileTests),
testCase(FileTypeTests.__allTests__FileTypeTests),
testCase(GitHubTests.__allTests__GitHubTests),
testCase(GitTests.__allTests__GitTests),
testCase(NSRegularExpressionExtensionsTests.__allTests__NSRegularExpressionExtensionsTests),
testCase(SwiftlintDefaultPathTests.__allTests__SwiftlintDefaultPathTests),
testCase(ViolnationTests.__allTests__ViolnationTests),
testCase(BitBucketServerTests.__allTests),
testCase(DangerDSLTests.__allTests),
testCase(DangerSwiftLintTests.__allTests),
testCase(DangerUtilsLineSearchTests.__allTests),
testCase(DateFormatterExtensionTests.__allTests),
testCase(FileTests.__allTests),
testCase(FileTypeTests.__allTests),
testCase(GitHubTests.__allTests),
testCase(GitTests.__allTests),
testCase(NSRegularExpressionExtensionsTests.__allTests),
testCase(SwiftlintDefaultPathTests.__allTests),
testCase(ViolnationTests.__allTests),
]
}
#endif

0 comments on commit e156cea

Please sign in to comment.