Skip to content

Commit

Permalink
Merge pull request #729 from Quick/8.x-fix-swiftpm-CwlPreconditionTes…
Browse files Browse the repository at this point in the history
…ting-linking-issue

[8.x] Fix CwlPreconditionTesting linking issue when used by SwiftPM
  • Loading branch information
ikesyo authored Mar 29, 2020
2 parents 827b2b1 + 6e04095 commit 3396b74
Show file tree
Hide file tree
Showing 8 changed files with 116 additions and 66 deletions.
2 changes: 2 additions & 0 deletions .swiftlint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ included:
- Tests

excluded:
- Package.swift
- Package@swift-4.2.swift
- Carthage/Checkouts
- Tests/NimbleTests/XCTestManifests.swift
- Tests/NimbleTests/Helpers/XCTestCaseProvider.swift
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@

import Foundation

#if SWIFT_PACKAGE
import CwlCatchExceptionSupport
#if canImport(NimbleCwlCatchExceptionSupport)
import NimbleCwlCatchExceptionSupport
#endif

private func catchReturnTypeConverter<T: NSException>(_ type: T.Type, block: @escaping () -> Void) -> T? {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@

import Foundation

#if SWIFT_PACKAGE
import CwlMachBadInstructionHandler
#if canImport(NimbleCwlMachBadInstructionHandler)
import NimbleCwlMachBadInstructionHandler
#endif

private func raiseBadInstructionException() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,9 @@
import Foundation
import Swift

#if SWIFT_PACKAGE
import CwlMachBadInstructionHandler
#if canImport(NimbleCwlCatchException) && canImport(NimbleCwlMachBadInstructionHandler)
import NimbleCwlCatchException
import NimbleCwlMachBadInstructionHandler
#endif

private enum PthreadError: Error { case code(Int32) }
Expand Down
19 changes: 1 addition & 18 deletions Package.resolved
Original file line number Diff line number Diff line change
@@ -1,24 +1,7 @@
{
"object": {
"pins": [
{
"package": "CwlCatchException",
"repositoryURL": "https://github.com/mattgallagher/CwlCatchException.git",
"state": {
"branch": null,
"revision": "7cd2f8cacc4d22f21bc0b2309c3b18acf7957b66",
"version": "1.2.0"
}
},
{
"package": "CwlPreconditionTesting",
"repositoryURL": "https://github.com/mattgallagher/CwlPreconditionTesting.git",
"state": {
"branch": null,
"revision": "c228db5d2ad1b01ebc84435e823e6cca4e3db98b",
"version": "1.2.0"
}
}

]
},
"version": 1
Expand Down
72 changes: 52 additions & 20 deletions Package.swift
Original file line number Diff line number Diff line change
@@ -1,6 +1,57 @@
// swift-tools-version:5.0
import PackageDescription

var targets: [Target] = [
.target(
name: "Nimble",
dependencies: {
#if os(macOS)
return [
"NimbleCwlPreconditionTesting",
"NimbleCwlMachBadInstructionHandler",
]
#else
return []
#endif
}()
),
.testTarget(
name: "NimbleTests",
dependencies: ["Nimble"],
exclude: ["objc"]
),
]
#if os(macOS)
targets.append(contentsOf: [
// https://github.com/Quick/Nimble/blob/8.x-branch/Carthage/Checkouts/CwlPreconditionTesting/Package.swift
.target(
name: "NimbleCwlPreconditionTesting",
dependencies: [
.target(name: "NimbleCwlMachBadInstructionHandler"),
.target(name: "NimbleCwlCatchException")
],
path: "Carthage/Checkouts/CwlPreconditionTesting/Sources/CwlPreconditionTesting",
exclude: [
"./CwlCatchBadInstructionPosix.swift"
]
),
.target(
name: "NimbleCwlMachBadInstructionHandler",
path: "Carthage/Checkouts/CwlPreconditionTesting/Sources/CwlMachBadInstructionHandler"
),
// https://github.com/Quick/Nimble/blob/8.x-branch/Carthage/Checkouts/CwlPreconditionTesting/Dependencies/CwlCatchException/Package.swift
.target(
name: "NimbleCwlCatchException",
dependencies: [.target(name: "NimbleCwlCatchExceptionSupport")],
path: "Carthage/Checkouts/CwlPreconditionTesting/Dependencies/CwlCatchException/Sources/CwlCatchException"
),
.target(
name: "NimbleCwlCatchExceptionSupport",
path: "Carthage/Checkouts/CwlPreconditionTesting/Dependencies/CwlCatchException/Sources/CwlCatchExceptionSupport"
),
])
#endif

let package = Package(
name: "Nimble",
platforms: [
Expand All @@ -9,25 +60,6 @@ let package = Package(
products: [
.library(name: "Nimble", targets: ["Nimble"]),
],
dependencies: [
.package(url: "https://github.com/mattgallagher/CwlPreconditionTesting.git", .exact("1.2.0")),
],
targets: [
.target(
name: "Nimble",
dependencies: {
#if os(macOS)
return ["CwlPreconditionTesting"]
#else
return []
#endif
}()
),
.testTarget(
name: "NimbleTests",
dependencies: ["Nimble"],
exclude: ["objc"]
),
],
targets: targets,
swiftLanguageVersions: [.v5]
)
72 changes: 52 additions & 20 deletions Package@swift-4.2.swift
Original file line number Diff line number Diff line change
@@ -1,30 +1,62 @@
// swift-tools-version:4.2
import PackageDescription

var targets: [Target] = [
.target(
name: "Nimble",
dependencies: {
#if os(macOS)
return [
"NimbleCwlPreconditionTesting",
"NimbleCwlMachBadInstructionHandler",
]
#else
return []
#endif
}()
),
.testTarget(
name: "NimbleTests",
dependencies: ["Nimble"],
exclude: ["objc"]
),
]
#if os(macOS)
targets.append(contentsOf: [
// https://github.com/Quick/Nimble/blob/8.x-branch/Carthage/Checkouts/CwlPreconditionTesting/Package.swift
.target(
name: "NimbleCwlPreconditionTesting",
dependencies: [
.target(name: "NimbleCwlMachBadInstructionHandler"),
.target(name: "NimbleCwlCatchException")
],
path: "Carthage/Checkouts/CwlPreconditionTesting/Sources/CwlPreconditionTesting",
exclude: [
"./CwlCatchBadInstructionPosix.swift"
]
),
.target(
name: "NimbleCwlMachBadInstructionHandler",
path: "Carthage/Checkouts/CwlPreconditionTesting/Sources/CwlMachBadInstructionHandler"
),
// https://github.com/Quick/Nimble/blob/8.x-branch/Carthage/Checkouts/CwlPreconditionTesting/Dependencies/CwlCatchException/Package.swift
.target(
name: "NimbleCwlCatchException",
dependencies: [.target(name: "NimbleCwlCatchExceptionSupport")],
path: "Carthage/Checkouts/CwlPreconditionTesting/Dependencies/CwlCatchException/Sources/CwlCatchException"
),
.target(
name: "NimbleCwlCatchExceptionSupport",
path: "Carthage/Checkouts/CwlPreconditionTesting/Dependencies/CwlCatchException/Sources/CwlCatchExceptionSupport"
),
])
#endif

let package = Package(
name: "Nimble",
products: [
.library(name: "Nimble", targets: ["Nimble"]),
],
dependencies: [
.package(url: "https://github.com/mattgallagher/CwlPreconditionTesting.git", .exact("1.2.0")),
],
targets: [
.target(
name: "Nimble",
dependencies: {
#if os(macOS)
return ["CwlPreconditionTesting"]
#else
return []
#endif
}()
),
.testTarget(
name: "NimbleTests",
dependencies: ["Nimble"],
exclude: ["objc"]
),
],
targets: targets,
swiftLanguageVersions: [.v4_2]
)
4 changes: 2 additions & 2 deletions Sources/Nimble/Matchers/ThrowAssertion.swift
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import Foundation

#if canImport(CwlPreconditionTesting)
import CwlPreconditionTesting
#if canImport(NimbleCwlPreconditionTesting)
import NimbleCwlPreconditionTesting
#endif

public func throwAssertion() -> Predicate<Void> {
Expand Down

0 comments on commit 3396b74

Please sign in to comment.