Skip to content

Commit 96e8415

Browse files
committed
Remove tests that are not compatible with old Swift versions when needed
1 parent 3763bf6 commit 96e8415

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

Tests/JSONLoggerTests/JSONLoggerTests.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ final class JSONLoggerTests : XCTestCase {
6969
XCTAssertEqual(data.first, 0x0a)
7070
}
7171

72+
#if swift(>=5.7)
7273
func testEncodeMetadataAsJSON() throws {
7374
struct BestStruct : Encodable, CustomStringConvertible {
7475
var val: Int
@@ -87,6 +88,7 @@ final class JSONLoggerTests : XCTestCase {
8788
line.date = ref.date
8889
XCTAssertEqual(line, ref)
8990
}
91+
#endif
9092

9193
func testFallbackOnLogLineEncodeFailure() throws {
9294
struct BestStruct : Encodable, CustomStringConvertible {

Tests/LinuxMain.swift

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,23 @@ import XCTest
55

66

77

8+
let testWhenAvailable1: [(String, (XCTestCase) -> () -> Void)]
9+
#if swift(>=5.7)
10+
testWhenAvailable1 = [
11+
("testEncodeMetadataAsJSON", JSONLoggerTests.testEncodeMetadataAsJSON),
12+
]
13+
#else
14+
testWhenAvailable1 = []
15+
#endif
816
var tests: [XCTestCaseEntry] = [
917
testCase([
1018
("test0NoSeparatorForFirstLog", JSONLoggerTests.test0NoSeparatorForFirstLog),
1119
("testFromDoc", JSONLoggerTests.testFromDoc),
1220
("testSeparatorForNotFirstLog", JSONLoggerTests.testSeparatorForNotFirstLog),
13-
("testEncodeMetadataAsJSON", JSONLoggerTests.testEncodeMetadataAsJSON),
1421
("testFallbackOnLogLineEncodeFailure", JSONLoggerTests.testFallbackOnLogLineEncodeFailure),
1522
("testDecodeLogLineWithBothValidDateAndMangledDate", JSONLoggerTests.testDecodeLogLineWithBothValidDateAndMangledDate),
1623
("testDecodeLogLineWithBothInvalidDateAndMangledDate", JSONLoggerTests.testDecodeLogLineWithBothInvalidDateAndMangledDate),
17-
]),
24+
] + testWhenAvailable1),
1825
]
1926
#if !os(WASI)
2027
XCTMain(tests)

0 commit comments

Comments
 (0)