Skip to content

Commit

Permalink
Fix watchOS and tvOS CI build issue
Browse files Browse the repository at this point in the history
  • Loading branch information
Kyle-Ye committed Dec 27, 2023
1 parent e5b9693 commit 365da17
Show file tree
Hide file tree
Showing 101 changed files with 318 additions and 206 deletions.
114 changes: 114 additions & 0 deletions [email protected]
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
// swift-tools-version:5.9

import Foundation
import PackageDescription

// This list should be updated whenever SwiftPM adds support for a new platform.
// See: https://bugs.swift.org/browse/SR-13814
let supportedPlatforms: [Platform] = [
.macOS,
.macCatalyst,
.iOS,
.watchOS,
.tvOS,
.driverKit,
.linux,
.android,
.windows,
.wasi,
.visionOS,
]

let openCombineTarget: Target = .target(
name: "OpenCombine",
dependencies: [
.target(
name: "COpenCombineHelpers",
condition: .when(platforms: supportedPlatforms.except([.wasi]))
)
],
exclude: [
"Concurrency/Publisher+Concurrency.swift.gyb",
"Publishers/Publishers.Encode.swift.gyb",
"Publishers/Publishers.MapKeyPath.swift.gyb",
"Publishers/Publishers.Catch.swift.gyb"
]
)
let openCombineFoundationTarget: Target = .target(
name: "OpenCombineFoundation",
dependencies: [
"OpenCombine",
.target(
name: "COpenCombineHelpers",
condition: .when(platforms: supportedPlatforms.except([.wasi]))
)
]
)
let openCombineDispatchTarget: Target = .target(
name: "OpenCombineDispatch",
dependencies: ["OpenCombine"]
)

let openCombineTestsTarget: Target = .testTarget(
name: "OpenCombineTests",
dependencies: [
"OpenCombine",
.target(name: "OpenCombineDispatch",
condition: .when(platforms: supportedPlatforms.except([.wasi]))),
.target(name: "OpenCombineFoundation",
condition: .when(platforms: supportedPlatforms.except([.wasi]))),
],
swiftSettings: [
.unsafeFlags(["-enable-testing"]),
]
)

let package = Package(
name: "OpenCombine",
products: [
.library(name: "OpenCombine", targets: ["OpenCombine"]),
.library(name: "OpenCombineDispatch", targets: ["OpenCombineDispatch"]),
.library(name: "OpenCombineFoundation", targets: ["OpenCombineFoundation"]),
.library(name: "OpenCombineShim", targets: ["OpenCombineShim"]),
],
targets: [
.target(name: "COpenCombineHelpers"),
.target(
name: "OpenCombineShim",
dependencies: [
"OpenCombine",
.target(name: "OpenCombineDispatch",
condition: .when(platforms: supportedPlatforms.except([.wasi]))),
.target(name: "OpenCombineFoundation",
condition: .when(platforms: supportedPlatforms.except([.wasi])))
]
),
openCombineTarget,
openCombineFoundationTarget,
openCombineDispatchTarget,
openCombineTestsTarget,
],
cxxLanguageStandard: .cxx17
)

// MARK: Helpers

extension Array where Element == Platform {
func except(_ exceptions: [Platform]) -> [Platform] {
return filter { !exceptions.contains($0) }
}
}

func envEnable(_ key: String) -> Bool {
guard let value = ProcessInfo.processInfo.environment[key] else {
return false
}
return value == "1"
}

let enableCompatibilityTest = envEnable("OPENCOMBINE_COMPATIBILITY_TEST")
if enableCompatibilityTest {
var settings = openCombineTestsTarget.swiftSettings ?? []
settings.append(.define("OPENCOMBINE_COMPATIBILITY_TEST"))
openCombineTestsTarget.swiftSettings = settings
}
2 changes: 1 addition & 1 deletion Tests/OpenCombineTests/AnyCancellableTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import Combine
import OpenCombine
#endif

@available(macOS 10.15, iOS 13.0, *)
@available(macOS 10.15, iOS 13.0, tvOS 13.0, watchOS 6.0, *)
final class AnyCancellableTests: XCTestCase {

func testClosureInitialized() {
Expand Down
4 changes: 2 additions & 2 deletions Tests/OpenCombineTests/AnyPublisherTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import Combine
import OpenCombine
#endif

@available(macOS 10.15, iOS 13.0, *)
@available(macOS 10.15, iOS 13.0, tvOS 13.0, watchOS 6.0, *)
final class AnyPublisherTests: XCTestCase {

private typealias Sut = AnyPublisher<Int, TestingError>
Expand All @@ -32,7 +32,7 @@ final class AnyPublisherTests: XCTestCase {
XCTAssertEqual(publisher.history, [.subscriber])
}

@available(macOS 11.0, iOS 14.0, *)
@available(macOS 11.0, iOS 14.0, tvOS 14.0, watchOS 7.0, *)
func testDoubleErasure() {
let introspection = TrackingIntrospection()
let subscriber = TrackingSubscriber()
Expand Down
16 changes: 8 additions & 8 deletions Tests/OpenCombineTests/AnySubscriberTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ import Combine
import OpenCombine
#endif

@available(macOS 10.15, iOS 13.0, *)
@available(macOS 10.15, iOS 13.0, tvOS 13.0, watchOS 6.0, *)
private typealias Sut = AnySubscriber<Int, TestingError>

@available(macOS 10.15, iOS 13.0, *)
@available(macOS 10.15, iOS 13.0, tvOS 13.0, watchOS 6.0, *)
final class AnySubscriberTests: XCTestCase {

func testCombineIdentifier() {
Expand Down Expand Up @@ -163,7 +163,7 @@ final class AnySubscriberTests: XCTestCase {
.completion(.finished)])
}

@available(macOS 11.0, iOS 14.0, *)
@available(macOS 11.0, iOS 14.0, tvOS 14.0, watchOS 7.0, *)
func testErasingTwice() {
let introspection = TrackingIntrospection()
let subscriber = TrackingSubscriber()
Expand All @@ -185,7 +185,7 @@ final class AnySubscriberTests: XCTestCase {
}
}

@available(macOS 10.15, iOS 13.0, *)
@available(macOS 10.15, iOS 13.0, tvOS 13.0, watchOS 6.0, *)
private let events: [TrackingSubscriber.Event] = [
.subscription("1"),
.subscription("2"),
Expand All @@ -199,7 +199,7 @@ private let events: [TrackingSubscriber.Event] = [
.completion(.failure("failure"))
]

@available(macOS 10.15, iOS 13.0, *)
@available(macOS 10.15, iOS 13.0, tvOS 13.0, watchOS 6.0, *)
private func publishEvents(_ events: [TrackingSubscriber.Event], _ erased: Sut) {
for event in events {
switch event {
Expand All @@ -213,7 +213,7 @@ private func publishEvents(_ events: [TrackingSubscriber.Event], _ erased: Sut)
}
}

@available(macOS 10.15, iOS 13.0, *)
@available(macOS 10.15, iOS 13.0, tvOS 13.0, watchOS 6.0, *)
private func publishEvents(
_ events: [TrackingSubscriber.Event],
_ publisher: PassthroughSubject<Int, TestingError>
Expand All @@ -230,7 +230,7 @@ private func publishEvents(
}
}

@available(macOS 10.15, iOS 13.0, *)
@available(macOS 10.15, iOS 13.0, tvOS 13.0, watchOS 6.0, *)
private func subscriberEventToSubjectEvent(
_ from: TrackingSubscriber.Event
) -> TrackingSubject<Int>.Event? {
Expand All @@ -244,7 +244,7 @@ private func subscriberEventToSubjectEvent(
}
}

@available(macOS 10.15, iOS 13.0, *)
@available(macOS 10.15, iOS 13.0, tvOS 13.0, watchOS 6.0, *)
extension Array {
func throughFirstCompletion<SubjectOutput>() -> Array
where Element == TrackingSubject<SubjectOutput>.Event
Expand Down
2 changes: 1 addition & 1 deletion Tests/OpenCombineTests/CombineIdentifierTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import Combine
import OpenCombine
#endif

@available(macOS 10.15, iOS 13.0, *)
@available(macOS 10.15, iOS 13.0, tvOS 13.0, watchOS 6.0, *)
final class CombineIdentifierTests: XCTestCase {

func testDefaultInitialized() {
Expand Down
2 changes: 1 addition & 1 deletion Tests/OpenCombineTests/CurrentValueSubjectTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import Combine
import OpenCombine
#endif

@available(macOS 10.15, iOS 13.0, *)
@available(macOS 10.15, iOS 13.0, tvOS 13.0, watchOS 6.0, *)
final class CurrentValueSubjectTests: XCTestCase {

private typealias Sut = CurrentValueSubject<Int, TestingError>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import OpenCombine
import OpenCombineDispatch
#endif

@available(macOS 10.15, iOS 13.0, *)
@available(macOS 10.15, iOS 13.0, tvOS 13.0, watchOS 6.0, *)
final class DispatchQueueSchedulerTests: XCTestCase {

// MARK: - Scheduler.SchedulerTimeType
Expand Down Expand Up @@ -590,7 +590,7 @@ final class DispatchQueueSchedulerTests: XCTestCase {

#if OPENCOMBINE_COMPATIBILITY_TEST || !canImport(Combine)

@available(macOS 10.15, iOS 13.0, *)
@available(macOS 10.15, iOS 13.0, tvOS 13.0, watchOS 6.0, *)
private typealias Scheduler = DispatchQueue

private let mainScheduler = DispatchQueue.main
Expand All @@ -605,7 +605,7 @@ private let backgroundScheduler = DispatchQueue.global(qos: .background).ocombin

#endif // OPENCOMBINE_COMPATIBILITY_TEST || !canImport(Combine)

@available(macOS 10.15, iOS 13.0, *)
@available(macOS 10.15, iOS 13.0, tvOS 13.0, watchOS 6.0, *)
private typealias Stride = Scheduler.SchedulerTimeType.Stride

private struct KeyedWrapper<Value: Codable & Equatable>: Codable, Equatable {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import OpenCombine
import OpenCombineFoundation
#endif

@available(macOS 10.15, iOS 13.0, *)
@available(macOS 10.15, iOS 13.0, tvOS 13.0, watchOS 6.0, *)
final class JSONDecoderTests: XCTestCase {
func testSuccessfullyDecode() {
let decoder = JSONDecoder()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import OpenCombine
import OpenCombineFoundation
#endif

@available(macOS 10.15, iOS 13.0, *)
@available(macOS 10.15, iOS 13.0, tvOS 13.0, watchOS 6.0, *)
final class JSONEncoderTests: XCTestCase {

func testSuccessfullyEncode() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import OpenCombine
import OpenCombineFoundation
#endif

@available(macOS 10.15, iOS 13.0, *)
@available(macOS 10.15, iOS 13.0, tvOS 13.0, watchOS 6.0, *)
final class NotificationCenterTests: XCTestCase {

func testRequestingDemand() {
Expand Down Expand Up @@ -456,7 +456,7 @@ final class NotificationCenterTests: XCTestCase {
}

#if OPENCOMBINE_COMPATIBILITY_TEST || !canImport(Combine)
@available(macOS 10.15, iOS 13.0, *)
@available(macOS 10.15, iOS 13.0, tvOS 13.0, watchOS 6.0, *)
private func makePublisher(
_ center: NotificationCenter,
for name: Notification.Name,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import OpenCombine
import OpenCombineFoundation
#endif

@available(macOS 10.15, iOS 13.0, *)
@available(macOS 10.15, iOS 13.0, tvOS 13.0, watchOS 6.0, *)
final class OperationQueueSchedulerTests: XCTestCase {

// MARK: - Scheduler.SchedulerTimeType
Expand Down Expand Up @@ -321,15 +321,15 @@ private func makeScheduler(_ queue: OperationQueue) -> OperationQueueScheduler {

#endif

@available(macOS 10.15, iOS 13.0, *)
@available(macOS 10.15, iOS 13.0, tvOS 13.0, watchOS 6.0, *)
extension OperationQueueScheduler.SchedulerTimeType.Stride
: TimeIntervalBackedSchedulerStride
{}

@available(macOS 10.15, iOS 13.0, *)
@available(macOS 10.15, iOS 13.0, tvOS 13.0, watchOS 6.0, *)
extension OperationQueueScheduler.SchedulerTimeType: DateBackedSchedulerTimeType {}

@available(macOS 10.15, iOS 13.0, *)
@available(macOS 10.15, iOS 13.0, tvOS 13.0, watchOS 6.0, *)
extension OperationQueueScheduler: RunLoopLikeScheduler {}

private final class TestOperationQueue: OperationQueue {
Expand Down Expand Up @@ -358,7 +358,7 @@ private final class TestOperationQueue: OperationQueue {

private(set) var history = [Event]()

@available(macOS 10.15, iOS 13.0, *)
@available(macOS 10.15, iOS 13.0, tvOS 13.0, watchOS 6.0, *)
override var progress: Progress {
history.append(.progress)
return super.progress
Expand All @@ -379,7 +379,7 @@ private final class TestOperationQueue: OperationQueue {
super.addOperation(block)
}

@available(macOS 10.15, iOS 13.0, *)
@available(macOS 10.15, iOS 13.0, tvOS 13.0, watchOS 6.0, *)
override func addBarrierBlock(_ barrier: @escaping () -> Void) {
history.append(.addBarrierBlock(barrier))
super.addBarrierBlock(barrier)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import OpenCombine
import OpenCombineFoundation
#endif

@available(macOS 10.15, iOS 13.0, *)
@available(macOS 10.15, iOS 13.0, tvOS 13.0, watchOS 6.0, *)
final class PropertyListDecoderTests: XCTestCase {
func testSuccessfullyDecode() {
let decoder = PropertyListDecoder()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import OpenCombine
import OpenCombineFoundation
#endif

@available(macOS 10.15, iOS 13.0, *)
@available(macOS 10.15, iOS 13.0, tvOS 13.0, watchOS 6.0, *)
final class PropertyListEncoderTests: XCTestCase {

func testSuccessfullyEncode() {
Expand Down
Loading

0 comments on commit 365da17

Please sign in to comment.