mirror of
https://github.com/ziglang/zig.git
synced 2025-12-06 06:13:07 +00:00
This rather large commit adds/fixes missing WASI functionality
in `libstd` needed to pass the `libstd` tests. As such, now by
default tests targeting `wasm32-wasi` target are enabled in
`test/tests.zig` module. However, they can be disabled by passing
the `-Dskip-wasi=true` flag when invoking the `zig build test`
command. When the flag is set to `false`, i.e., when WASI tests are
included, `wasmtime` with `--dir=.` is used as the default testing
command.
Since the majority of `libstd` tests were relying on `fs.cwd()`
call to get current working directory handle wrapped in `Dir`
struct, in order to make the tests WASI-friendly, `fs.cwd()`
call was replaced with `testing.getTestDir()` function which
resolved to either `fs.cwd()` for non-WASI targets, or tries to
fetch the preopen list from the WASI runtime and extract a
preopen for '.' path.
The summary of changes introduced by this commit:
* implement `Dir.makeDir` and `Dir.openDir` targeting WASI
* implement `Dir.deleteFile` and `Dir.deleteDir` targeting WASI
* fix `os.close` and map errors in `unlinkat`
* move WASI-specific `mkdirat` and `unlinkat` from `std.fs.wasi`
to `std.os` module
* implement `lseek_{SET, CUR, END}` targeting WASI
* implement `futimens` targeting WASI
* implement `ftruncate` targeting WASI
* implement `readv`, `writev`, `pread{v}`, `pwrite{v}` targeting WASI
* make sure ANSI escape codes are _not_ used in stderr or stdout
in WASI, as WASI always sanitizes stderr, and sanitizes stdout if
fd is a TTY
* fix specifying WASI rights when opening/creating files/dirs
* tweak `AtomicFile` to be WASI-compatible
* implement `os.renameatWasi` for WASI-compliant `os.renameat` function
* implement sleep() targeting WASI
* fix `process.getEnvMap` targeting WASI
85 lines
3.8 KiB
Zig
85 lines
3.8 KiB
Zig
pub const ArrayList = @import("array_list.zig").ArrayList;
|
|
pub const ArrayListAligned = @import("array_list.zig").ArrayListAligned;
|
|
pub const ArrayListAlignedUnmanaged = @import("array_list.zig").ArrayListAlignedUnmanaged;
|
|
pub const ArrayListSentineled = @import("array_list_sentineled.zig").ArrayListSentineled;
|
|
pub const ArrayListUnmanaged = @import("array_list.zig").ArrayListUnmanaged;
|
|
pub const AutoHashMap = @import("hash_map.zig").AutoHashMap;
|
|
pub const BloomFilter = @import("bloom_filter.zig").BloomFilter;
|
|
pub const BufMap = @import("buf_map.zig").BufMap;
|
|
pub const BufSet = @import("buf_set.zig").BufSet;
|
|
pub const ChildProcess = @import("child_process.zig").ChildProcess;
|
|
pub const DynLib = @import("dynamic_library.zig").DynLib;
|
|
pub const HashMap = @import("hash_map.zig").HashMap;
|
|
pub const Mutex = @import("mutex.zig").Mutex;
|
|
pub const PackedIntArray = @import("packed_int_array.zig").PackedIntArray;
|
|
pub const PackedIntArrayEndian = @import("packed_int_array.zig").PackedIntArrayEndian;
|
|
pub const PackedIntSlice = @import("packed_int_array.zig").PackedIntSlice;
|
|
pub const PackedIntSliceEndian = @import("packed_int_array.zig").PackedIntSliceEndian;
|
|
pub const PriorityQueue = @import("priority_queue.zig").PriorityQueue;
|
|
pub const Progress = @import("progress.zig").Progress;
|
|
pub const ResetEvent = @import("reset_event.zig").ResetEvent;
|
|
pub const SegmentedList = @import("segmented_list.zig").SegmentedList;
|
|
pub const SinglyLinkedList = @import("linked_list.zig").SinglyLinkedList;
|
|
pub const SpinLock = @import("spinlock.zig").SpinLock;
|
|
pub const StringHashMap = @import("hash_map.zig").StringHashMap;
|
|
pub const TailQueue = @import("linked_list.zig").TailQueue;
|
|
pub const Target = @import("target.zig").Target;
|
|
pub const Thread = @import("thread.zig").Thread;
|
|
|
|
pub const atomic = @import("atomic.zig");
|
|
pub const base64 = @import("base64.zig");
|
|
pub const build = @import("build.zig");
|
|
pub const builtin = @import("builtin.zig");
|
|
pub const c = @import("c.zig");
|
|
pub const coff = @import("coff.zig");
|
|
pub const crypto = @import("crypto.zig");
|
|
pub const cstr = @import("cstr.zig");
|
|
pub const debug = @import("debug.zig");
|
|
pub const dwarf = @import("dwarf.zig");
|
|
pub const elf = @import("elf.zig");
|
|
pub const event = @import("event.zig");
|
|
pub const fifo = @import("fifo.zig");
|
|
pub const fmt = @import("fmt.zig");
|
|
pub const fs = @import("fs.zig");
|
|
pub const hash = @import("hash.zig");
|
|
pub const hash_map = @import("hash_map.zig");
|
|
pub const heap = @import("heap.zig");
|
|
pub const http = @import("http.zig");
|
|
pub const io = @import("io.zig");
|
|
pub const json = @import("json.zig");
|
|
pub const macho = @import("macho.zig");
|
|
pub const math = @import("math.zig");
|
|
pub const mem = @import("mem.zig");
|
|
pub const meta = @import("meta.zig");
|
|
pub const net = @import("net.zig");
|
|
pub const os = @import("os.zig");
|
|
pub const once = @import("once.zig").once;
|
|
pub const packed_int_array = @import("packed_int_array.zig");
|
|
pub const pdb = @import("pdb.zig");
|
|
pub const process = @import("process.zig");
|
|
pub const rand = @import("rand.zig");
|
|
pub const rb = @import("rb.zig");
|
|
pub const sort = @import("sort.zig");
|
|
pub const ascii = @import("ascii.zig");
|
|
pub const testing = @import("testing.zig");
|
|
pub const time = @import("time.zig");
|
|
pub const unicode = @import("unicode.zig");
|
|
pub const valgrind = @import("valgrind.zig");
|
|
pub const zig = @import("zig.zig");
|
|
pub const start = @import("start.zig");
|
|
|
|
// This forces the start.zig file to be imported, and the comptime logic inside that
|
|
// file decides whether to export any appropriate start symbols.
|
|
comptime {
|
|
_ = start;
|
|
}
|
|
|
|
test "" {
|
|
// TODO is there a way around this? When enabled for WASI, we pick up functions
|
|
// which generate compile error. Perhaps semantic analyser should skip those
|
|
// if running in test mode?
|
|
if (builtin.os.tag != .wasi) {
|
|
meta.refAllDecls(@This());
|
|
}
|
|
}
|