From e81326f1784fa5fbd39f0c2fb996613c72700940 Mon Sep 17 00:00:00 2001 From: Dimitri Bouniol Date: Wed, 29 Jul 2026 02:45:12 -0700 Subject: [PATCH] Fixed an issue where exit tests would prevent builds on some apple platforms --- Tests/BytesTests/AsyncByteIteratorTests.swift | 24 +++++++++++++++++++ Tests/BytesTests/AsyncChunkedBytesTests.swift | 2 ++ Tests/BytesTests/ByteIteratorTests.swift | 12 ++++++++++ Tests/BytesTests/StringTests.swift | 24 +++++++++++++++++++ 4 files changed, 62 insertions(+) diff --git a/Tests/BytesTests/AsyncByteIteratorTests.swift b/Tests/BytesTests/AsyncByteIteratorTests.swift index 9e271ea..b2c03fd 100644 --- a/Tests/BytesTests/AsyncByteIteratorTests.swift +++ b/Tests/BytesTests/AsyncByteIteratorTests.swift @@ -12,6 +12,7 @@ import Testing #if canImport(Darwin) @Suite struct LegacyAsyncByteIteratorTests { + #if !os(iOS) && !os(tvOS) && !os(watchOS) && !os(visionOS) @Test func nextCountInvalidInput() async throws { await #expect(processExitsWith: .failure) { var iterator = AsyncTestIterator([0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07]) @@ -22,6 +23,7 @@ import Testing _ = try await iterator.next(Bytes.self, count: -1) } } + #endif @Test func nextCount() async throws { var iterator = AsyncTestIterator([0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07]) @@ -53,6 +55,7 @@ import Testing #expect(try await iterator.next(Bytes.self, count: 0) == []) } + #if !os(iOS) && !os(tvOS) && !os(watchOS) && !os(visionOS) @Test func nextMinMaxInvalidInput() async throws { await #expect(processExitsWith: .failure) { var iterator = AsyncTestIterator([0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07]) @@ -79,6 +82,7 @@ import Testing _ = try await iterator.next(Bytes.self, min: 1, max: 0) } } + #endif @Test func nextMinMax() async throws { var iterator = AsyncTestIterator([0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07]) @@ -106,6 +110,7 @@ import Testing } } + #if !os(iOS) && !os(tvOS) && !os(watchOS) && !os(visionOS) @Test func nextMaxInvalidInput() async throws { await #expect(processExitsWith: .failure) { var iterator = AsyncTestIterator([0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07]) @@ -116,6 +121,7 @@ import Testing _ = try await iterator.next(Bytes.self, max: -1) } } + #endif @Test func nextMax() async throws { var iterator = AsyncTestIterator([0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07]) @@ -139,6 +145,7 @@ import Testing } } + #if !os(iOS) && !os(tvOS) && !os(watchOS) && !os(visionOS) @Test func nextIfPresentCountInvalidInput() async throws { await #expect(processExitsWith: .failure) { var iterator = AsyncTestIterator([0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07]) @@ -149,6 +156,7 @@ import Testing _ = try await iterator.nextIfPresent(Bytes.self, count: -1) } } + #endif @Test func nextIfPresentCount() async throws { var iterator = AsyncTestIterator([0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07]) @@ -194,6 +202,7 @@ import Testing #expect(try await iterator.nextIfPresent(Bytes.self, count: 0) == []) } + #if !os(iOS) && !os(tvOS) && !os(watchOS) && !os(visionOS) @Test func nextIfPresentMinMaxInvalidInput() async throws { await #expect(processExitsWith: .failure) { var iterator = AsyncTestIterator([0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07]) @@ -220,6 +229,7 @@ import Testing _ = try await iterator.nextIfPresent(Bytes.self, min: 1, max: 0) } } + #endif @Test func nextIfPresentMinMax() async throws { var iterator = AsyncTestIterator([0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07]) @@ -260,6 +270,7 @@ import Testing #expect(try await iterator.nextIfPresent(Bytes.self, min: 0, max: 3) == nil) } + #if !os(iOS) && !os(tvOS) && !os(watchOS) && !os(visionOS) @Test func nextIfPresentMaxInvalidInput() async throws { await #expect(processExitsWith: .failure) { var iterator = AsyncTestIterator([0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07]) @@ -270,6 +281,7 @@ import Testing _ = try await iterator.nextIfPresent(Bytes.self, max: -1) } } + #endif @Test func nextIfPresentMax() async throws { var iterator = AsyncTestIterator([0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07]) @@ -462,6 +474,7 @@ import Testing #endif @Suite struct AsyncByteIteratorTests { + #if !os(iOS) && !os(tvOS) && !os(watchOS) && !os(visionOS) @available(macOS 15.0, iOS 18.0, watchOS 11.0, tvOS 18.0, visionOS 2.0, *) @Test func nextCountInvalidInput() async throws { await #expect(processExitsWith: .failure) { @@ -473,6 +486,7 @@ import Testing _ = try await iterator.next(Bytes.self, count: -1) } } + #endif @available(macOS 15.0, iOS 18.0, watchOS 11.0, tvOS 18.0, visionOS 2.0, *) @Test func nextCount() async throws { @@ -506,6 +520,7 @@ import Testing #expect(try await iterator.next(Bytes.self, count: 0) == []) } + #if !os(iOS) && !os(tvOS) && !os(watchOS) && !os(visionOS) @available(macOS 15.0, iOS 18.0, watchOS 11.0, tvOS 18.0, visionOS 2.0, *) @Test func nextMinMaxInvalidInput() async throws { await #expect(processExitsWith: .failure) { @@ -533,6 +548,7 @@ import Testing _ = try await iterator.next(Bytes.self, min: 1, max: 0) } } + #endif @available(macOS 15.0, iOS 18.0, watchOS 11.0, tvOS 18.0, visionOS 2.0, *) @Test func nextMinMax() async throws { @@ -562,6 +578,7 @@ import Testing } } + #if !os(iOS) && !os(tvOS) && !os(watchOS) && !os(visionOS) @available(macOS 15.0, iOS 18.0, watchOS 11.0, tvOS 18.0, visionOS 2.0, *) @Test func nextMaxInvalidInput() async throws { await #expect(processExitsWith: .failure) { @@ -573,6 +590,7 @@ import Testing _ = try await iterator.next(Bytes.self, max: -1) } } + #endif @available(macOS 15.0, iOS 18.0, watchOS 11.0, tvOS 18.0, visionOS 2.0, *) @Test func nextMax() async throws { @@ -598,6 +616,7 @@ import Testing } } + #if !os(iOS) && !os(tvOS) && !os(watchOS) && !os(visionOS) @available(macOS 15.0, iOS 18.0, watchOS 11.0, tvOS 18.0, visionOS 2.0, *) @Test func nextIfPresentCountInvalidInput() async throws { await #expect(processExitsWith: .failure) { @@ -609,6 +628,7 @@ import Testing _ = try await iterator.nextIfPresent(Bytes.self, count: -1) } } + #endif @available(macOS 15.0, iOS 18.0, watchOS 11.0, tvOS 18.0, visionOS 2.0, *) @Test func nextIfPresentCount() async throws { @@ -657,6 +677,7 @@ import Testing #expect(try await iterator.nextIfPresent(Bytes.self, count: 0) == []) } + #if !os(iOS) && !os(tvOS) && !os(watchOS) && !os(visionOS) @available(macOS 15.0, iOS 18.0, watchOS 11.0, tvOS 18.0, visionOS 2.0, *) @Test func nextIfPresentMinMaxInvalidInput() async throws { await #expect(processExitsWith: .failure) { @@ -684,6 +705,7 @@ import Testing _ = try await iterator.nextIfPresent(Bytes.self, min: 1, max: 0) } } + #endif @available(macOS 15.0, iOS 18.0, watchOS 11.0, tvOS 18.0, visionOS 2.0, *) @Test func nextIfPresentMinMax() async throws { @@ -727,6 +749,7 @@ import Testing #expect(try await iterator.nextIfPresent(Bytes.self, min: 0, max: 3) == nil) } + #if !os(iOS) && !os(tvOS) && !os(watchOS) && !os(visionOS) @available(macOS 15.0, iOS 18.0, watchOS 11.0, tvOS 18.0, visionOS 2.0, *) @Test func nextIfPresentMaxInvalidInput() async throws { await #expect(processExitsWith: .failure) { @@ -738,6 +761,7 @@ import Testing _ = try await iterator.nextIfPresent(Bytes.self, max: -1) } } + #endif @available(macOS 15.0, iOS 18.0, watchOS 11.0, tvOS 18.0, visionOS 2.0, *) @Test func nextIfPresentMax() async throws { diff --git a/Tests/BytesTests/AsyncChunkedBytesTests.swift b/Tests/BytesTests/AsyncChunkedBytesTests.swift index c9ee43b..993e04f 100644 --- a/Tests/BytesTests/AsyncChunkedBytesTests.swift +++ b/Tests/BytesTests/AsyncChunkedBytesTests.swift @@ -11,6 +11,7 @@ import Bytes import Testing @Suite struct AsyncChunkedBytesTests { + #if !os(iOS) && !os(tvOS) && !os(watchOS) && !os(visionOS) @Test func chunkedInvalidInput() async throws { await #expect(processExitsWith: .failure) { let sequence = AsyncTestSequence() @@ -29,6 +30,7 @@ import Testing _ = sequence.chuncked(0) } } + #endif @Test func chunked() async throws { let sequence = AsyncTestSequence() diff --git a/Tests/BytesTests/ByteIteratorTests.swift b/Tests/BytesTests/ByteIteratorTests.swift index e757e16..5215b62 100644 --- a/Tests/BytesTests/ByteIteratorTests.swift +++ b/Tests/BytesTests/ByteIteratorTests.swift @@ -13,6 +13,7 @@ import Testing @Suite struct ByteIteratorTests { let bytes: Bytes = [0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07] + #if !os(iOS) && !os(tvOS) && !os(watchOS) && !os(visionOS) @Test func nextCountInvalidInput() async throws { await #expect(processExitsWith: .failure) { let bytes: Bytes = [0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07] @@ -20,6 +21,7 @@ import Testing _ = try iterator.next(Bytes.self, count: -1) } } + #endif @Test func nextCount() async throws { var iterator = bytes.makeIterator() @@ -36,6 +38,7 @@ import Testing #expect(try iterator.next(Bytes.self, count: 0) == []) } + #if !os(iOS) && !os(tvOS) && !os(watchOS) && !os(visionOS) @Test func nextMinMaxInvalidInput() async throws { await #expect(processExitsWith: .failure) { let bytes: Bytes = [0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07] @@ -53,6 +56,7 @@ import Testing _ = try iterator.next(Bytes.self, min: 1, max: 0) } } + #endif @Test func nextMinMax() async throws { var iterator = bytes.makeIterator() @@ -68,6 +72,7 @@ import Testing } } + #if !os(iOS) && !os(tvOS) && !os(watchOS) && !os(visionOS) @Test func nextMaxInvalidInput() async throws { await #expect(processExitsWith: .failure) { let bytes: Bytes = [0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07] @@ -75,6 +80,7 @@ import Testing _ = iterator.next(Bytes.self, max: -1) } } + #endif @Test func nextMax() async throws { var iterator = bytes.makeIterator() @@ -86,6 +92,7 @@ import Testing #expect(iterator.next(Bytes.self, max: 3) == []) } + #if !os(iOS) && !os(tvOS) && !os(watchOS) && !os(visionOS) @Test func nextIfPresentCountInvalidInput() async throws { await #expect(processExitsWith: .failure) { let bytes: Bytes = [0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07] @@ -93,6 +100,7 @@ import Testing _ = try iterator.nextIfPresent(Bytes.self, count: -1) } } + #endif @Test func nextIfPresentCount() async throws { var iterator = bytes.makeIterator() @@ -122,6 +130,7 @@ import Testing #expect(try iterator.nextIfPresent(Bytes.self, count: 0) == []) } + #if !os(iOS) && !os(tvOS) && !os(watchOS) && !os(visionOS) @Test func nextIfPresentMinMaxInvalidInput() async throws { await #expect(processExitsWith: .failure) { let bytes: Bytes = [0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07] @@ -139,6 +148,7 @@ import Testing _ = try iterator.nextIfPresent(Bytes.self, min: 1, max: 0) } } + #endif @Test func nextIfPresentMinMax() async throws { var iterator = bytes.makeIterator() @@ -165,6 +175,7 @@ import Testing #expect(try iterator.nextIfPresent(Bytes.self, min: 0, max: 3) == nil) } + #if !os(iOS) && !os(tvOS) && !os(watchOS) && !os(visionOS) @Test func nextIfPresentMaxInvalidInput() async throws { await #expect(processExitsWith: .failure) { let bytes: Bytes = [0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07] @@ -172,6 +183,7 @@ import Testing _ = iterator.nextIfPresent(Bytes.self, max: -1) } } + #endif @Test func nextIfPresentMax() async throws { var iterator = bytes.makeIterator() diff --git a/Tests/BytesTests/StringTests.swift b/Tests/BytesTests/StringTests.swift index a9be530..205df4d 100644 --- a/Tests/BytesTests/StringTests.swift +++ b/Tests/BytesTests/StringTests.swift @@ -48,6 +48,7 @@ import Testing } @Suite struct StringByteIteratorTests { + #if !os(iOS) && !os(tvOS) && !os(watchOS) && !os(visionOS) @Test func nextUTF8StringCountInvalidInput() async throws { await #expect(processExitsWith: .failure) { let bytes: Bytes = [72, 101, 108, 108, 111, 44, 32, 87, 111, 114, 108, 100, 33] @@ -55,6 +56,7 @@ import Testing _ = try iterator.next(utf8: String.self, count: -1) } } + #endif @Test func nextUTF8StringCount() async throws { let bytes: Bytes = [72, 101, 108, 108, 111, 44, 32, 87, 111, 114, 108, 100, 33] @@ -69,6 +71,7 @@ import Testing } } + #if !os(iOS) && !os(tvOS) && !os(watchOS) && !os(visionOS) @Test func nextUTF8StringMinMaxInvalidInput() async throws { await #expect(processExitsWith: .failure) { let bytes: Bytes = [72, 101, 108, 108, 111, 44, 32, 87, 111, 114, 108, 100, 33] @@ -86,6 +89,7 @@ import Testing _ = try iterator.next(utf8: String.self, min: 1, max: 0) } } + #endif @Test func nextUTF8StringMinMax() async throws { let bytes: Bytes = [72, 101, 108, 108, 111, 44, 32, 87, 111, 114, 108, 100, 33] @@ -101,6 +105,7 @@ import Testing } } + #if !os(iOS) && !os(tvOS) && !os(watchOS) && !os(visionOS) @Test func nextIfPresentUTF8StringCountInvalidInput() async throws { await #expect(processExitsWith: .failure) { let bytes: Bytes = [72, 101, 108, 108, 111, 44, 32, 87, 111, 114, 108, 100, 33] @@ -108,6 +113,7 @@ import Testing _ = try iterator.nextIfPresent(utf8: String.self, count: -1) } } + #endif @Test func nextIfPresentUTF8StringCount() async throws { let bytes: Bytes = [72, 101, 108, 108, 111, 44, 32, 87, 111, 114, 108, 100, 33] @@ -138,6 +144,7 @@ import Testing #expect(try iterator.nextIfPresent(utf8: String.self, count: 0) == "") } + #if !os(iOS) && !os(tvOS) && !os(watchOS) && !os(visionOS) @Test func nextIfPresentUTF8StringMinMaxInvalidInput() async throws { await #expect(processExitsWith: .failure) { let bytes: Bytes = [72, 101, 108, 108, 111, 44, 32, 87, 111, 114, 108, 100, 33] @@ -155,6 +162,7 @@ import Testing _ = try iterator.nextIfPresent(utf8: String.self, min: 1, max: 0) } } + #endif @Test func nextIfPresentUTF8StringMinMax() async throws { let bytes: Bytes = [72, 101, 108, 108, 111, 44, 32, 87, 111, 114, 108, 100, 33] @@ -292,6 +300,7 @@ import Testing #if canImport(Darwin) @Suite struct StringLegacyAsyncByteIteratorTests { + #if !os(iOS) && !os(tvOS) && !os(watchOS) && !os(visionOS) @Test func nextUTF8StringCountInvalidInput() async throws { await #expect(processExitsWith: .failure) { var iterator = AsyncTestIterator([72, 101, 108, 108, 111, 44, 32, 87, 111, 114, 108, 100, 33]) @@ -302,6 +311,7 @@ import Testing _ = try await iterator.next(utf8: String.self, count: -1) } } + #endif @Test func nextUTF8StringCount() async throws { var iterator = AsyncTestIterator([72, 101, 108, 108, 111, 44, 32, 87, 111, 114, 108, 100, 33]) @@ -327,6 +337,7 @@ import Testing } } + #if !os(iOS) && !os(tvOS) && !os(watchOS) && !os(visionOS) @Test func nextUTF8StringMinMaxInvalidInput() async throws { await #expect(processExitsWith: .failure) { var iterator = AsyncTestIterator([72, 101, 108, 108, 111, 44, 32, 87, 111, 114, 108, 100, 33]) @@ -353,6 +364,7 @@ import Testing _ = try await iterator.next(utf8: String.self, min: 1, max: 0) } } + #endif @Test func nextUTF8StringMinMax() async throws { var iterator = AsyncTestIterator([72, 101, 108, 108, 111, 44, 32, 87, 111, 114, 108, 100, 33]) @@ -379,6 +391,7 @@ import Testing } } + #if !os(iOS) && !os(tvOS) && !os(watchOS) && !os(visionOS) @Test func nextIfPresentUTF8StringCountInvalidInput() async throws { await #expect(processExitsWith: .failure) { var iterator = AsyncTestIterator([72, 101, 108, 108, 111, 44, 32, 87, 111, 114, 108, 100, 33]) @@ -389,6 +402,7 @@ import Testing _ = try await iterator.nextIfPresent(utf8: String.self, count: -1) } } + #endif @Test func nextIfPresentUTF8StringCount() async throws { var iterator = AsyncTestIterator([72, 101, 108, 108, 111, 44, 32, 87, 111, 114, 108, 100, 33]) @@ -433,6 +447,7 @@ import Testing #expect(try await iterator.nextIfPresent(utf8: String.self, count: 0) == "") } + #if !os(iOS) && !os(tvOS) && !os(watchOS) && !os(visionOS) @Test func nextIfPresentUTF8StringMinMaxInvalidInput() async throws { await #expect(processExitsWith: .failure) { var iterator = AsyncTestIterator([72, 101, 108, 108, 111, 44, 32, 87, 111, 114, 108, 100, 33]) @@ -459,6 +474,7 @@ import Testing _ = try await iterator.nextIfPresent(utf8: String.self, min: 1, max: 0) } } + #endif @Test func nextIfPresentUTF8StringMinMax() async throws { var iterator = AsyncTestIterator([72, 101, 108, 108, 111, 44, 32, 87, 111, 114, 108, 100, 33]) @@ -709,6 +725,7 @@ import Testing #endif @Suite struct StringAsyncByteIteratorTests { + #if !os(iOS) && !os(tvOS) && !os(watchOS) && !os(visionOS) @available(macOS 15.0, iOS 18.0, watchOS 11.0, tvOS 18.0, visionOS 2.0, *) @Test func nextUTF8StringCountInvalidInput() async throws { await #expect(processExitsWith: .failure) { @@ -720,6 +737,7 @@ import Testing _ = try await iterator.next(utf8: String.self, count: -1) } } + #endif @available(macOS 15.0, iOS 18.0, watchOS 11.0, tvOS 18.0, visionOS 2.0, *) @Test func nextUTF8StringCount() async throws { @@ -747,6 +765,7 @@ import Testing } } + #if !os(iOS) && !os(tvOS) && !os(watchOS) && !os(visionOS) @available(macOS 15.0, iOS 18.0, watchOS 11.0, tvOS 18.0, visionOS 2.0, *) @Test func nextUTF8StringMinMaxInvalidInput() async throws { await #expect(processExitsWith: .failure) { @@ -774,6 +793,7 @@ import Testing _ = try await iterator.next(utf8: String.self, min: 1, max: 0) } } + #endif @available(macOS 15.0, iOS 18.0, watchOS 11.0, tvOS 18.0, visionOS 2.0, *) @Test func nextUTF8StringMinMax() async throws { @@ -802,6 +822,7 @@ import Testing } } + #if !os(iOS) && !os(tvOS) && !os(watchOS) && !os(visionOS) @available(macOS 15.0, iOS 18.0, watchOS 11.0, tvOS 18.0, visionOS 2.0, *) @Test func nextIfPresentUTF8StringCountInvalidInput() async throws { await #expect(processExitsWith: .failure) { @@ -813,6 +834,7 @@ import Testing _ = try await iterator.nextIfPresent(utf8: String.self, count: -1) } } + #endif @available(macOS 15.0, iOS 18.0, watchOS 11.0, tvOS 18.0, visionOS 2.0, *) @Test func nextIfPresentUTF8StringCount() async throws { @@ -860,6 +882,7 @@ import Testing #expect(try await iterator.nextIfPresent(utf8: String.self, count: 0) == "") } + #if !os(iOS) && !os(tvOS) && !os(watchOS) && !os(visionOS) @available(macOS 15.0, iOS 18.0, watchOS 11.0, tvOS 18.0, visionOS 2.0, *) @Test func nextIfPresentUTF8StringMinMaxInvalidInput() async throws { await #expect(processExitsWith: .failure) { @@ -887,6 +910,7 @@ import Testing _ = try await iterator.nextIfPresent(utf8: String.self, min: 1, max: 0) } } + #endif @available(macOS 15.0, iOS 18.0, watchOS 11.0, tvOS 18.0, visionOS 2.0, *) @Test func nextIfPresentUTF8StringMinMax() async throws {