Skip to content

Commit 601bb79

Browse files
committed
Disable tests on WASM
This is due to us supporting Swift <5.5 and WASM XCTMain implementation requiring the await keyword.
1 parent 73e43e4 commit 601bb79

File tree

1 file changed

+19
-1
lines changed

1 file changed

+19
-1
lines changed

Tests/LinuxMain.swift

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
1+
import Foundation
12
import XCTest
23

34
@testable import CLTLoggerTests
45

6+
7+
58
var tests: [XCTestCaseEntry] = [
69
testCase([
710
("testFromDoc", CLTLoggerTests.testFromDoc),
@@ -38,6 +41,21 @@ var tests: [XCTestCaseEntry] = [
3841
XCTMain(tests)
3942

4043
#else
41-
await XCTMain(tests)
44+
/* Compilation fails for Swift <5.5… */
45+
//await XCTMain(tests)
46+
47+
/* Let’s print a message to inform the tests on WASI are disabled. */
48+
import struct CLTLogger.SGR
49+
try FileHandle.standardError.write(contentsOf: Data("""
50+
\(SGR(.fgColorTo4BitBrightRed, .bold).rawValue)Tests are disabled on WASI\(SGR.reset.rawValue):
51+
\(SGR(.fgColorTo256PaletteValue(245)).rawValue)CLTLogger is compatible with Swift <5.4, so we have to add a LinuxMain file in which we call XCTMain.
52+
On WASI the XCTMain function is async, so we have to #if the XCTMain call, one with the await keyword, the other without.
53+
However, on Swift <5.5 the LinuxMain setup like this does not compile because the old compiler does not know the await keyword
54+
(even though the whole code is ignored because we do not compile for WASI whe compiling with an old compiler).
55+
I also tried doing a #if swift(>=5.5) check, but that do not work either.\(SGR.reset.rawValue)
56+
57+
\(SGR(.fgColorTo4BitMagenta, .bold).rawValue)To temporarily enable the tests for WASI, uncomment the `await XCTMain(tests)` line in LinuxMain.swift.\(SGR.reset.rawValue)
58+
59+
""".utf8))
4260

4361
#endif

0 commit comments

Comments
 (0)