Skip to content

Commit

Permalink
Guard tests and targets that require Swift 5.9
Browse files Browse the repository at this point in the history
  • Loading branch information
ncooke3 committed Jul 25, 2023
1 parent 393cd7e commit 67709e3
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 8 deletions.
25 changes: 17 additions & 8 deletions Fixtures/MixedTargets/BasicMixedTargets/Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -88,12 +88,6 @@ let package = Package(
dependencies: ["MixedTargetWithCustomModuleMapAndResources"]
),

// MARK: - MixedTargetWithCXX_CXXInteropEnabled
.target(
name: "MixedTargetWithCXX_CXXInteropEnabled",
swiftSettings: [.interoperabilityMode(.Cxx)]
),

// MARK: - MixedTargetWithCXX
.target(
name: "MixedTargetWithCXX"
Expand Down Expand Up @@ -265,10 +259,25 @@ let package = Package(
// The below two targets are used for testing the above targets.
.target(name: "SwiftTarget"),
.target(name: "ClangTarget")

],
] + targetsWithCxxInteropEnabled(),
// TODO(ncooke3): Is the below note behavior that we want to be intended?
// This is needed for targets with that have
// `swiftSettings: [.interoperabilityMode(.Cxx)]` set.
cxxLanguageStandard: .cxx11
)

func targetsWithCxxInteropEnabled() -> [Target] {
// The below targets have C++ interoperability mode enabled, a feature that
// requires Swift 5.9 or greater.
#if swift(>=5.9)
// MARK: - MixedTargetWithCXX_CXXInteropEnabled
return [
.target(
name: "MixedTargetWithCXX_CXXInteropEnabled",
swiftSettings: [.interoperabilityMode(.Cxx)]
)
]
#else
return []
#endif // swift(>=5.9)
}
4 changes: 4 additions & 0 deletions Tests/FunctionalTests/MixedTargetTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,9 @@ final class MixedTargetTests: XCTestCase {
}
}

// The below tests build targets with C++ interoperability mode enabled, a
// feature that requires Swift 5.9 or greater.
#if swift(>=5.9)
func testMixedTargetWithCXX_CXXInteropEnabled() throws {
try fixture(name: "MixedTargets/BasicMixedTargets") { fixturePath in
XCTAssertBuilds(
Expand All @@ -146,6 +149,7 @@ final class MixedTargetTests: XCTestCase {
)
}
}
#endif // swift(>=5.9)

func testMixedTargetWithCXX() throws {
try fixture(name: "MixedTargets/BasicMixedTargets") { fixturePath in
Expand Down

0 comments on commit 67709e3

Please sign in to comment.