diff --git a/Sources/_CollectionsTestSupport/AssertionContexts/CollectionTestCase.swift b/Sources/_CollectionsTestSupport/AssertionContexts/CollectionTestCase.swift index 044a2c08..94eb6e3d 100644 --- a/Sources/_CollectionsTestSupport/AssertionContexts/CollectionTestCase.swift +++ b/Sources/_CollectionsTestSupport/AssertionContexts/CollectionTestCase.swift @@ -17,12 +17,22 @@ open class CollectionTestCase: XCTestCase { public var context: TestContext { _context! } - public override func setUp() { + open var isAvailable: Bool { true } + + public override func invokeTest() { + guard isAvailable else { + print("\(Self.self) unavailable; skipping") + return + } + return super.invokeTest() + } + + open override func setUp() { super.setUp() _context = TestContext.pushNew() } - public override func tearDown() { + open override func tearDown() { TestContext.pop(context) _context = nil super.tearDown() diff --git a/Tests/RopeModuleTests/Availability.swift b/Tests/RopeModuleTests/Availability.swift new file mode 100644 index 00000000..3587f8d3 --- /dev/null +++ b/Tests/RopeModuleTests/Availability.swift @@ -0,0 +1,17 @@ +//===----------------------------------------------------------------------===// +// +// This source file is part of the Swift Collections open source project +// +// Copyright (c) 2023 Apple Inc. and the Swift project authors +// Licensed under Apache License v2.0 with Runtime Library Exception +// +// See https://swift.org/LICENSE.txt for license information +// +//===----------------------------------------------------------------------===// + +var isRunningOnSwiftStdlib5_8: Bool { + if #available(macOS 13.3, iOS 16.4, watchOS 9.4, tvOS 16.4, *) { + return true + } + return false +} diff --git a/Tests/RopeModuleTests/TestBString.swift b/Tests/RopeModuleTests/TestBString.swift index 87449066..228463c2 100644 --- a/Tests/RopeModuleTests/TestBString.swift +++ b/Tests/RopeModuleTests/TestBString.swift @@ -10,11 +10,14 @@ //===----------------------------------------------------------------------===// #if swift(>=5.8) +import _CollectionsTestSupport import _RopeModule import XCTest @available(macOS 13.3, iOS 16.4, watchOS 9.4, tvOS 16.4, *) -class TestBString: XCTestCase { +class TestBString: CollectionTestCase { + override var isAvailable: Bool { isRunningOnSwiftStdlib5_8 } + override class func setUp() { // Turn off output buffering. setbuf(stdout, nil) diff --git a/Tests/RopeModuleTests/TestBString2.swift b/Tests/RopeModuleTests/TestBString2.swift index 3ea05308..86971857 100644 --- a/Tests/RopeModuleTests/TestBString2.swift +++ b/Tests/RopeModuleTests/TestBString2.swift @@ -16,6 +16,8 @@ import XCTest @available(macOS 13.3, iOS 16.4, watchOS 9.4, tvOS 16.4, *) class TestBString2: CollectionTestCase { + override var isAvailable: Bool { isRunningOnSwiftStdlib5_8 } + func testUTF8View() { let str = _BString(shortSample) checkBidirectionalCollection(str.utf8, expectedContents: shortSample.utf8) diff --git a/Tests/RopeModuleTests/TestBigString.swift b/Tests/RopeModuleTests/TestBigString.swift index 8549c3e7..f6fd27e1 100644 --- a/Tests/RopeModuleTests/TestBigString.swift +++ b/Tests/RopeModuleTests/TestBigString.swift @@ -10,11 +10,14 @@ //===----------------------------------------------------------------------===// #if swift(>=5.8) +import _CollectionsTestSupport import _RopeModule import XCTest @available(macOS 13.3, iOS 16.4, watchOS 9.4, tvOS 16.4, *) -class TestBigString: XCTestCase { +class TestBigString: CollectionTestCase { + override var isAvailable: Bool { isRunningOnSwiftStdlib5_8 } + override class func setUp() { // Turn off output buffering. setbuf(stdout, nil)