Skip to content

Commit 3ef9e6a

Browse files
committed
Fix tests on WASI
1 parent a3eb48a commit 3ef9e6a

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
#if os(WASI)
2+
import Foundation
3+
import WASILibc
4+
5+
6+
7+
typealias Pipe = FakePipe
8+
struct FakePipe {
9+
10+
init() {
11+
try! Data().write(to: fileURL)
12+
assert(FileManager.default.fileExists(atPath: fileURL.absoluteURL.path), "Created file does not exist!")
13+
}
14+
15+
var fileHandleForWriting: FileHandle {
16+
return try! FileHandle(forWritingTo: fileURL)
17+
}
18+
19+
var fileHandleForReading: FileHandle {
20+
return try! FileHandle(forReadingFrom: fileURL)
21+
}
22+
23+
private let fileURL = FileManager.default.temporaryDirectory.appendingPathComponent("json-logger-test-\(UUID()).txt")
24+
// private let fileURL = URL(fileURLWithPath: #filePath).deletingLastPathComponent().appendingPathComponent("json-logger-test-\(UUID()).txt")
25+
private var filepath: String {
26+
fileURL.absoluteURL.path
27+
}
28+
29+
}
30+
#endif

0 commit comments

Comments
 (0)