Skip to content

Commit b7500c3

Browse files
authored
Add CI for SwiftWASM (#55)
* Add WASM to CI * wip * wip * wip * wip * wip * wip
1 parent 3737fae commit b7500c3

File tree

4 files changed

+204
-171
lines changed

4 files changed

+204
-171
lines changed

.github/workflows/ci.yml

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,14 +36,29 @@ jobs:
3636
strategy:
3737
matrix:
3838
swift:
39-
- 5.3
40-
- 5.4
4139
- 5.5
40+
- 5.6
41+
#- 5.7
4242
steps:
4343
- uses: actions/checkout@v2
4444
- name: Run tests
4545
run: make test-linux SWIFT_VERSION=${{ matrix.swift }}
4646

47+
wasm:
48+
name: SwiftWASM
49+
runs-on: ubuntu-latest
50+
strategy:
51+
matrix:
52+
include:
53+
- { toolchain: wasm-5.6.0-RELEASE }
54+
55+
steps:
56+
- uses: actions/checkout@v2
57+
- run: echo "${{ matrix.toolchain }}" > .swift-version
58+
- uses: swiftwasm/[email protected]
59+
with:
60+
shell-action: carton test --environment node
61+
4762
#windows:
4863
# name: Windows
4964
# runs-on: windows-latest

Sources/CustomDump/Conformances/Foundation.swift

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -31,17 +31,19 @@ extension Calendar: CustomDumpReflectable {
3131
}
3232
}
3333

34-
extension Data: CustomDumpStringConvertible {
35-
public var customDumpDescription: String {
36-
"Data(\(Self.formatter.string(fromByteCount: .init(self.count))))"
37-
}
34+
#if !os(WASI)
35+
extension Data: CustomDumpStringConvertible {
36+
public var customDumpDescription: String {
37+
"Data(\(Self.formatter.string(fromByteCount: .init(self.count))))"
38+
}
3839

39-
private static let formatter: ByteCountFormatter = {
40-
let formatter = ByteCountFormatter()
41-
formatter.allowedUnits = .useBytes
42-
return formatter
43-
}()
44-
}
40+
private static let formatter: ByteCountFormatter = {
41+
let formatter = ByteCountFormatter()
42+
formatter.allowedUnits = .useBytes
43+
return formatter
44+
}()
45+
}
46+
#endif
4547

4648
#if !os(WASI)
4749
extension Date: CustomDumpStringConvertible {

Tests/CustomDumpTests/Conformances/FoundationTests.swift

Lines changed: 119 additions & 107 deletions
Original file line numberDiff line numberDiff line change
@@ -42,33 +42,35 @@ final class FoundationTests: XCTestCase {
4242
#endif
4343
}
4444

45-
func testDate() {
46-
var dump = ""
47-
customDump(
48-
Date(timeIntervalSince1970: 0),
49-
to: &dump
50-
)
51-
XCTAssertNoDifference(
52-
dump,
53-
"""
54-
Date(1970-01-01T00:00:00.000Z)
55-
"""
56-
)
57-
58-
#if compiler(>=5.4)
59-
dump = ""
45+
#if !os(WASI)
46+
func testDate() {
47+
var dump = ""
6048
customDump(
61-
NestedDate(date: Date(timeIntervalSince1970: 0)),
49+
Date(timeIntervalSince1970: 0),
6250
to: &dump
6351
)
6452
XCTAssertNoDifference(
6553
dump,
6654
"""
67-
NestedDate(date: Date(1970-01-01T00:00:00.000Z))
55+
Date(1970-01-01T00:00:00.000Z)
6856
"""
6957
)
70-
#endif
71-
}
58+
59+
#if compiler(>=5.4)
60+
dump = ""
61+
customDump(
62+
NestedDate(date: Date(timeIntervalSince1970: 0)),
63+
to: &dump
64+
)
65+
XCTAssertNoDifference(
66+
dump,
67+
"""
68+
NestedDate(date: Date(1970-01-01T00:00:00.000Z))
69+
"""
70+
)
71+
#endif
72+
}
73+
#endif
7274

7375
func testDecimal() {
7476
var dump = ""
@@ -167,33 +169,37 @@ final class FoundationTests: XCTestCase {
167169
)
168170
}
169171

170-
func testNSData() {
171-
var dump = ""
172-
customDump(
173-
NSData(data: .init(repeating: 0, count: 4)),
174-
to: &dump
175-
)
176-
XCTAssertNoDifference(
177-
dump,
178-
"""
179-
Data(4 bytes)
180-
"""
181-
)
182-
}
172+
#if !os(WASI)
173+
func testNSData() {
174+
var dump = ""
175+
customDump(
176+
NSData(data: .init(repeating: 0, count: 4)),
177+
to: &dump
178+
)
179+
XCTAssertNoDifference(
180+
dump,
181+
"""
182+
Data(4 bytes)
183+
"""
184+
)
185+
}
186+
#endif
183187

184-
func testNSDate() {
185-
var dump = ""
186-
customDump(
187-
NSDate(timeIntervalSince1970: 0),
188-
to: &dump
189-
)
190-
XCTAssertNoDifference(
191-
dump,
192-
"""
193-
Date(1970-01-01T00:00:00.000Z)
194-
"""
195-
)
196-
}
188+
#if !os(WASI)
189+
func testNSDate() {
190+
var dump = ""
191+
customDump(
192+
NSDate(timeIntervalSince1970: 0),
193+
to: &dump
194+
)
195+
XCTAssertNoDifference(
196+
dump,
197+
"""
198+
Date(1970-01-01T00:00:00.000Z)
199+
"""
200+
)
201+
}
202+
#endif
197203

198204
func testNSDictionary() {
199205
var dump = ""
@@ -238,7 +244,7 @@ final class FoundationTests: XCTestCase {
238244
"""
239245
)
240246

241-
#if !os(Windows)
247+
#if !os(Windows) && !os(WASI)
242248
class SubclassedError: NSError {}
243249

244250
dump = ""
@@ -401,19 +407,21 @@ final class FoundationTests: XCTestCase {
401407
)
402408
}
403409

404-
func testNSNotification() {
405-
var dump = ""
406-
customDump(
407-
NSNotification(name: .init(rawValue: "co.pointfree"), object: nil, userInfo: nil),
408-
to: &dump
409-
)
410-
XCTAssertNoDifference(
411-
dump,
412-
"""
413-
Notification(name: "co.pointfree")
414-
"""
415-
)
416-
}
410+
#if !os(WASI)
411+
func testNSNotification() {
412+
var dump = ""
413+
customDump(
414+
NSNotification(name: .init(rawValue: "co.pointfree"), object: nil, userInfo: nil),
415+
to: &dump
416+
)
417+
XCTAssertNoDifference(
418+
dump,
419+
"""
420+
Notification(name: "co.pointfree")
421+
"""
422+
)
423+
}
424+
#endif
417425

418426
func testNSNull() {
419427
var dump = ""
@@ -507,32 +515,34 @@ final class FoundationTests: XCTestCase {
507515
)
508516
}
509517

510-
func testNSTimeZone() {
511-
var dump = ""
512-
customDump(
513-
NSTimeZone(forSecondsFromGMT: 0),
514-
to: &dump
515-
)
516-
XCTAssertNoDifference(
517-
dump,
518-
"""
519-
TimeZone(
520-
identifier: "GMT",
521-
abbreviation: "GMT",
522-
secondsFromGMT: 0,
523-
isDaylightSavingTime: false
518+
#if !os(WASI)
519+
func testNSTimeZone() {
520+
var dump = ""
521+
customDump(
522+
NSTimeZone(forSecondsFromGMT: 0),
523+
to: &dump
524524
)
525-
"""
526-
)
527-
}
525+
XCTAssertNoDifference(
526+
dump,
527+
"""
528+
TimeZone(
529+
identifier: "GMT",
530+
abbreviation: "GMT",
531+
secondsFromGMT: 0,
532+
isDaylightSavingTime: false
533+
)
534+
"""
535+
)
536+
}
537+
#endif
528538

529539
func testNSURL() {
530540
var dump = ""
531541
customDump(
532542
NSURL(fileURLWithPath: "/tmp"),
533543
to: &dump
534544
)
535-
#if os(Windows)
545+
#if os(Windows) || os(WASI)
536546
XCTAssertNoDifference(
537547
dump,
538548
"""
@@ -590,37 +600,39 @@ final class FoundationTests: XCTestCase {
590600
)
591601
}
592602

593-
func testNSURLRequest() {
594-
var dump = ""
595-
let request = NSMutableURLRequest(url: URL(string: "https://www.pointfree.co")!)
596-
request.addValue("text/html", forHTTPHeaderField: "Accept")
597-
request.httpShouldUsePipelining = false
598-
customDump(
599-
request,
600-
to: &dump
601-
)
602-
XCTAssertNoDifference(
603-
dump,
604-
"""
605-
URLRequest(
606-
url: URL(https://www.pointfree.co),
607-
cachePolicy: 0,
608-
timeoutInterval: 60.0,
609-
mainDocumentURL: nil,
610-
networkServiceType: URLRequest.NetworkServiceType.default,
611-
allowsCellularAccess: true,
612-
httpMethod: "GET",
613-
allHTTPHeaderFields: [
614-
"Accept": "text/html"
615-
],
616-
httpBody: nil,
617-
httpBodyStream: nil,
618-
httpShouldHandleCookies: true,
619-
httpShouldUsePipelining: false
603+
#if !os(WASI)
604+
func testNSURLRequest() {
605+
var dump = ""
606+
let request = NSMutableURLRequest(url: URL(string: "https://www.pointfree.co")!)
607+
request.addValue("text/html", forHTTPHeaderField: "Accept")
608+
request.httpShouldUsePipelining = false
609+
customDump(
610+
request,
611+
to: &dump
620612
)
621-
"""
622-
)
623-
}
613+
XCTAssertNoDifference(
614+
dump,
615+
"""
616+
URLRequest(
617+
url: URL(https://www.pointfree.co),
618+
cachePolicy: 0,
619+
timeoutInterval: 60.0,
620+
mainDocumentURL: nil,
621+
networkServiceType: URLRequest.NetworkServiceType.default,
622+
allowsCellularAccess: true,
623+
httpMethod: "GET",
624+
allHTTPHeaderFields: [
625+
"Accept": "text/html"
626+
],
627+
httpBody: nil,
628+
httpBodyStream: nil,
629+
httpShouldHandleCookies: true,
630+
httpShouldUsePipelining: false
631+
)
632+
"""
633+
)
634+
}
635+
#endif
624636

625637
func testNSUUID() {
626638
var dump = ""

0 commit comments

Comments
 (0)