Skip to content

Commit 8f60c99

Browse files
Update wasi-testsuite to 2fec29ea6de1244c124f7fe3bfe9f2946113f66e
Update the testsuite to the latest version even though our implementation doesn't pass all the tests yet just for the sake of keeping the dependencies up to date.
1 parent 0bda9f6 commit 8f60c99

File tree

2 files changed

+102
-30
lines changed

2 files changed

+102
-30
lines changed

Tests/WASITests/IntegrationTests.swift

Lines changed: 101 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -9,46 +9,101 @@ final class IntegrationTests: XCTestCase {
99
let testDir = URL(fileURLWithPath: #filePath)
1010
.deletingLastPathComponent().deletingLastPathComponent().deletingLastPathComponent()
1111
.appendingPathComponent("Vendor/wasi-testsuite")
12+
var failedTests: [String: [String]] = [:]
1213
for testSuitePath in ["tests/assemblyscript/testsuite", "tests/c/testsuite", "tests/rust/testsuite"] {
1314
let suitePath = testDir.appendingPathComponent(testSuitePath)
14-
try runTestSuite(path: suitePath)
15+
try runTestSuite(path: suitePath, failedTests: &failedTests)
16+
}
17+
if !failedTests.isEmpty {
18+
print("Failed tests:")
19+
for (suite, cases) in failedTests {
20+
print(" \(suite):")
21+
for caseName in cases {
22+
print(" \(caseName)")
23+
}
24+
}
1525
}
1626
}
1727

1828
struct SuiteManifest: Codable {
1929
let name: String
2030
}
2131

22-
static var skipTests: [String: [String: String]] {
32+
static var skipTests: [String: Set<String>] {
2333
#if os(Windows)
2434
return [
25-
"WASI Assemblyscript tests": [:],
35+
"WASI Assemblyscript tests": [],
2636
"WASI C tests": [
27-
"fdopendir-with-access": "Not implemented",
28-
"fopen-with-access": "Not implemented",
29-
"lseek": "Not implemented",
30-
"pread-with-access": "Not implemented",
31-
"pwrite-with-access": "Not implemented",
32-
"stat-dev-ino": "Not implemented",
37+
"fdopendir-with-access",
38+
"fopen-with-access",
39+
"lseek",
40+
"pread-with-access",
41+
"pwrite-with-access",
42+
"stat-dev-ino",
43+
"sock_shutdown-not_sock",
44+
"sock_shutdown-invalid_fd",
3345
],
3446
"WASI Rust tests": [
35-
"close_preopen": "Not implemented",
36-
"dangling_fd": "Not implemented",
37-
"dangling_symlink": "Not implemented",
38-
"directory_seek": "Not implemented",
39-
"fd_advise": "Not implemented",
40-
"fd_filestat_set": "Not implemented",
41-
"fd_flags_set": "Not implemented",
42-
"fd_readdir": "Not implemented",
43-
"interesting_paths": "Not implemented",
47+
"close_preopen",
48+
"dangling_fd",
49+
"dangling_symlink",
50+
"directory_seek",
51+
"fd_advise",
52+
"fd_filestat_set",
53+
"fd_flags_set",
54+
"fd_readdir",
55+
"interesting_paths",
56+
"dir_fd_op_failures",
57+
"symlink_create",
58+
"sched_yield",
59+
"overwrite_preopen",
60+
"path_link",
61+
"poll_oneoff_stdio",
62+
"readlink",
63+
"renumber",
64+
"path_filestat",
65+
"remove_directory_trailing_slashes",
66+
"path_rename",
67+
"stdio",
68+
"symlink_filestat",
69+
"path_open_read_write",
70+
"fd_fdstat_set_rights",
71+
"file_allocate",
72+
"path_rename_dir_trailing_slashes",
73+
"path_open_preopen",
4474
],
4575
]
4676
#else
47-
return [:]
77+
return [
78+
"WASI C tests": [
79+
"sock_shutdown-not_sock",
80+
"sock_shutdown-invalid_fd",
81+
],
82+
"WASI Rust tests": [
83+
"dir_fd_op_failures",
84+
"symlink_create",
85+
"sched_yield",
86+
"overwrite_preopen",
87+
"path_link",
88+
"poll_oneoff_stdio",
89+
"readlink",
90+
"renumber",
91+
"path_filestat",
92+
"remove_directory_trailing_slashes",
93+
"path_rename",
94+
"stdio",
95+
"symlink_filestat",
96+
"path_open_read_write",
97+
"fd_fdstat_set_rights",
98+
"file_allocate",
99+
"path_rename_dir_trailing_slashes",
100+
"path_open_preopen",
101+
]
102+
]
48103
#endif
49104
}
50105

51-
func runTestSuite(path: URL) throws {
106+
func runTestSuite(path: URL, failedTests: inout [String: [String]]) throws {
52107
let manifestPath = path.appendingPathComponent("manifest.json")
53108
let manifest = try JSONDecoder().decode(SuiteManifest.self, from: Data(contentsOf: manifestPath))
54109

@@ -65,16 +120,23 @@ final class IntegrationTests: XCTestCase {
65120
print("Running test suite: \(manifest.name)")
66121
let tests = try FileManager.default.contentsOfDirectory(at: path, includingPropertiesForKeys: nil, options: [])
67122

68-
let skipTests = Self.skipTests[manifest.name] ?? [:]
123+
let skipTests = Self.skipTests[manifest.name] ?? []
69124

70125
for test in tests {
71126
guard test.pathExtension == "wasm" else { continue }
72127
let testName = test.deletingPathExtension().lastPathComponent
73-
if let reason = skipTests[testName] {
74-
print("Skipping test \(testName): \(reason)")
128+
if skipTests.contains(testName) {
129+
print("Test \(testName) skipped")
75130
continue
76131
}
77-
try runTest(path: test)
132+
print("Test \(testName) started")
133+
switch try runTest(path: test) {
134+
case .success:
135+
print("Test \(testName) passed")
136+
case .failure(let error):
137+
XCTFail("Test \(testName) failed: \(error)")
138+
failedTests[manifest.name, default: []].append(testName)
139+
}
78140
}
79141
}
80142

@@ -89,7 +151,11 @@ final class IntegrationTests: XCTestCase {
89151
}
90152
}
91153

92-
func runTest(path: URL) throws {
154+
enum TestError: Error {
155+
case unexpectedExitCode(actual: UInt32, expected: UInt32)
156+
}
157+
158+
func runTest(path: URL) throws -> Result<(), Error> {
93159
let manifestPath = path.deletingPathExtension().appendingPathExtension("json")
94160
var manifest: CaseManifest
95161
if FileManager.default.fileExists(atPath: manifestPath.path) {
@@ -107,8 +173,6 @@ final class IntegrationTests: XCTestCase {
107173

108174
let suitePath = path.deletingLastPathComponent()
109175

110-
print("Testing \(path.path)")
111-
112176
let wasi = try WASIBridgeToHost(
113177
args: [path.path] + (manifest.args ?? []),
114178
environment: manifest.env ?? [:],
@@ -119,7 +183,15 @@ final class IntegrationTests: XCTestCase {
119183
let runtime = Runtime(hostModules: wasi.hostModules)
120184
let module = try parseWasm(filePath: FilePath(path.path))
121185
let instance = try runtime.instantiate(module: module)
122-
let exitCode = try wasi.start(instance, runtime: runtime)
123-
XCTAssertEqual(exitCode, manifest.exitCode ?? 0, path.path)
186+
do {
187+
let exitCode = try wasi.start(instance, runtime: runtime)
188+
let expected = manifest.exitCode ?? 0
189+
if exitCode != expected {
190+
throw TestError.unexpectedExitCode(actual: exitCode, expected: expected)
191+
}
192+
return .success(())
193+
} catch {
194+
return .failure(error)
195+
}
124196
}
125197
}

Vendor/dependencies.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
},
66
"wasi-testsuite": {
77
"repository": "https://github.com/WebAssembly/wasi-testsuite.git",
8-
"revision": "c9c751586fd86b321d595bbef13f2c7403cfdbc5"
8+
"revision": "2fec29ea6de1244c124f7fe3bfe9f2946113f66e"
99
},
1010
"swift-format": {
1111
"repository": "https://github.com/swiftlang/swift-format.git",

0 commit comments

Comments
 (0)