aboutsummaryrefslogtreecommitdiff
path: root/lib/std/fs/test.zig
AgeCommit message (Collapse)Author
2025-10-29std.fs: use BadPathName rather than InvalidWtf8 on WindowsAndrew Kelley
2025-10-29std.Io.Threaded: implement dirOpenFile for WASIAndrew Kelley
2025-10-29fix miscellaneous compilation errorsAndrew Kelley
- ILSEQ -> error.BadPathName - implement dirStatPath for WASI
2025-10-29std: fix compilation errors on macosAndrew Kelley
2025-10-29fix compilation errors introduced by rebasingAndrew Kelley
2025-10-29std: fix some Io compilation errorsAndrew Kelley
2025-10-29std: updating to std.Io interfaceAndrew Kelley
got the build runner compiling
2025-10-29WIP: hack away at std.Io return flightAndrew Kelley
2025-10-29WIP: hack at std.Io on a planeAndrew Kelley
2025-10-08std: std.fs.File fix sendFile with buffered dataMaciej 'vesim' Kuliński
fixes #25196 Co-authored-by: Andrew Kelley <andrew@ziglang.org>
2025-10-08std: fix File.Writer sendfile with buffered contentsAndrew Kelley
* File.Writer.seekBy passed wrong offset to setPosAdjustingBuffer. * File.Writer.sendFile incorrectly used non-logical position. Related to 1d764c1fdf04829cec5974d82cec901825a80e49 Test case provided by: Co-authored-by: Kendall Condon <goon.pri.low@gmail.com>
2025-10-03Add depth function to `Walker.Entry`Ryan Liptak
This enables depth-related use cases without any dependency on the Walker's internal stack which doesn't always pertain to the actual depth of the current entry (i.e. recursing into a directory immediately affects the stack).
2025-10-03test: enter after check to preserve depthHenry Kupty
2025-10-03test: Include expected depth testHenry Kupty
2025-10-03Add SelectiveWalker/walkSelectively and implement Walker in terms of itRyan Liptak
This is a breaking change, since the fields of Walker have changed. The function APIs are unchanged, though.
2025-09-05Revert "Merge pull request #24905 from gooncreeper/file-reader-buffered"Andrew Kelley
This reverts commit ac42eaaadd0650ffc281f9a1ed1a642fde8984b7, reversing changes made to 9fa2394f8c00d060931d69fb6f342f7f2e3d826e. I would like a chance to review this, please. I already spotted some issues.
2025-09-04File.Writer.sendFile: properly update reader posKendall Condon
seekBy affects the reader's physical position, not its logical position.
2025-09-03fix: std.fs.File.Writer.seekTo does not flush (#25135)Josh GM Walker
* add failing test case * perform flush and allow error * dont over constrain flush error * reset seek error during conversion
2025-08-30rework std.Io.Writer.Allocating to support runtime-known alignmentAndrew Kelley
Also, breaking API changes to: * std.fs.Dir.readFileAlloc * std.fs.Dir.readFileAllocOptions
2025-08-13std.fs.File.Reader: fix seekByAndrew Kelley
Tested locally: stage3/bin/zig build test -Dskip-release -Dskip-non-native closes #24495 closes #24498 closes #24713
2025-08-11std.ArrayList: make unmanaged the defaultAndrew Kelley
2025-07-21std.fs.File.Reader: fix seek position logicAndrew Kelley
2025-07-21std.fs.File: delete writeFileAll and friendsAndrew Kelley
please use File.Writer for these use cases also breaking API changes to std.fs.AtomicFile
2025-07-21std.fs.File.Reader: fix missed advance writer positionsAndrew Kelley
2025-07-07std.fmt: breaking API changesAndrew Kelley
added adapter to AnyWriter and GenericWriter to help bridge the gap between old and new API make std.testing.expectFmt work at compile-time std.fmt no longer has a dependency on std.unicode. Formatted printing was never properly unicode-aware. Now it no longer pretends to be. Breakage/deprecations: * std.fs.File.reader -> std.fs.File.deprecatedReader * std.fs.File.writer -> std.fs.File.deprecatedWriter * std.io.GenericReader -> std.io.Reader * std.io.GenericWriter -> std.io.Writer * std.io.AnyReader -> std.io.Reader * std.io.AnyWriter -> std.io.Writer * std.fmt.format -> std.fmt.deprecatedFormat * std.fmt.fmtSliceEscapeLower -> std.ascii.hexEscape * std.fmt.fmtSliceEscapeUpper -> std.ascii.hexEscape * std.fmt.fmtSliceHexLower -> {x} * std.fmt.fmtSliceHexUpper -> {X} * std.fmt.fmtIntSizeDec -> {B} * std.fmt.fmtIntSizeBin -> {Bi} * std.fmt.fmtDuration -> {D} * std.fmt.fmtDurationSigned -> {D} * {} -> {f} when there is a format method * format method signature - anytype -> *std.io.Writer - inferred error set -> error{WriteFailed} - options -> (deleted) * std.fmt.Formatted - now takes context type explicitly - no fmt string
2025-06-23lib/std/fs/test.zig: Some filesystems support 8 EiB filesPat Tullmann
Btrfs at least supports 16 EiB files (limited in practice to 8EiB by the Linux VFS code which uses signed 64-bit offsets). So fix the fs.zig test case to expect either a FileTooBig or success from truncating a file to 8EiB. And test that beyond that size the offset is interpreted as a negative number. Fixes #24242
2025-05-08std: Disable `fs.test.test.setEndPos` on MIPS N32.Alex Rønne Petersen
https://github.com/ziglang/zig/issues/23806
2025-03-26lib/std/posix: test ftruncate via std.fs.File.setEndPos()Pat Tullmann
Add a test for std.fs.File's `setEndPos` (which is a simple wrapper around `std.posix.ftruncate`) to exercise some success and failure paths. Explicitly check that the `ftruncate` length isn't negative when interpreted as a signed value. This avoids having to decode overloaded `EINVAL` errors. Add errno handling to Windows path to map INVALID_PARAMETER to FileTooBig. Fixes #22960
2025-03-24lib/std/: WASI code should follow POSIX semantics for ↵Pat Tullmann
AccessDenied/PermissionDenied Use error.AccessDenied for permissions (rights) failures on Wasi (`EACCES`) and error.PermissionDenied (`EPERM`) for systemic failures. And pass-through underlying Wasi errors (PermissionDenied or AccessDenied) without mapping.
2025-03-09std/lib: {fs,io,posix} test clean upPat Tullmann
* use `tmp.dir.realpathAlloc()` to get full path into tmpDir instances * use `testing.allocator` where that simplifies things (vs. manual ArenaAllocator for 1 or 2 allocs) * Trust `TmpDir.cleanup()` to clean up contained files and sub-trees * Remove some unnecessary absolute paths (enabling WASI to run the tests) * Drop some no-longer necessary `[_][]const u8` casts * Add scopes to reduce `var` usage in favor of `const`
2025-02-09wasi: fix wasm-wasi-musl constantsPat Tullmann
Zig's copy of the `SYMLINK_{NO,}FOLLOW` constants from wasi-musl was wrong, as were the `IFIFO` and `IFSOCK` file type flags. Fix these up, and add comments pointing to exactly where they come from (as the wasi-musl source has lots of unused, different definitions of these constants). Add tests for the Zig convention that WASM preopen 3 is the current working directory. This is true for WASM with or without libc. Enable several fs and posix tests that are now passing (not necessarily because of this change) on wasm targets. Fixes #20890.
2024-10-05std.os.windows.ReadFile: handle ERROR_LOCK_VIOLATIONJonathan Marler
fixes #21500
2024-08-23std.fs: Disable `file operations on directories` test on WASI.Alex Rønne Petersen
https://github.com/ziglang/zig/issues/20747
2024-07-03Rename MAX_NAME_BYTES to max_name_bytesMichael Bradshaw
2024-06-13std: Convert deprecated aliases to compile errors and fix usagesRyan Liptak
Deprecated aliases that are now compile errors: - `std.fs.MAX_PATH_BYTES` (renamed to `std.fs.max_path_bytes`) - `std.mem.tokenize` (split into `tokenizeAny`, `tokenizeSequence`, `tokenizeScalar`) - `std.mem.split` (split into `splitSequence`, `splitAny`, `splitScalar`) - `std.mem.splitBackwards` (split into `splitBackwardsSequence`, `splitBackwardsAny`, `splitBackwardsScalar`) - `std.unicode` + `utf16leToUtf8Alloc`, `utf16leToUtf8AllocZ`, `utf16leToUtf8`, `fmtUtf16le` (all renamed to have capitalized `Le`) + `utf8ToUtf16LeWithNull` (renamed to `utf8ToUtf16LeAllocZ`) - `std.zig.CrossTarget` (moved to `std.Target.Query`) Deprecated `lib/std/std.zig` decls were deleted instead of made a `@compileError` because the `refAllDecls` in the test block would trigger the `@compileError`. The deleted top-level `std` namespaces are: - `std.rand` (renamed to `std.Random`) - `std.TailQueue` (renamed to `std.DoublyLinkedList`) - `std.ChildProcess` (renamed/moved to `std.process.Child`) This is not exhaustive. Deprecated aliases that I didn't touch: + `std.io.*` + `std.Build.*` + `std.builtin.Mode` + `std.zig.c_translation.CIntLiteralRadix` + anything in `src/`
2024-06-04fs tests: Fix leaking a directory handle in "makepath existing directories" testRyan Liptak
2024-05-29rename zig-cache to .zig-cacheAndrew Kelley
closes #20077
2024-05-11windows: use permissive file share flags everywhere (#19505)Georgijs
* use permissive file share flags everywhere * remove file_share_delete from createnamedpipefile
2024-05-03Rename Dir.writeFile2 -> Dir.writeFile and update all callsitesRyan Liptak
writeFile was deprecated in favor of writeFile2 in f645022d16361865e24582d28f1e62312fbc73bb. This commit renames writeFile2 to writeFile and makes writeFile2 a compile error.
2024-04-28std.posix.iovec: use .base and .len instead of .iov_base and .iov_lenNameless
2024-04-22ComptimeStringMap: return a regular struct and optimizeTravis Staloch
this patch renames ComptimeStringMap to StaticStringMap, makes it accept only a single type parameter, and return a known struct type instead of an anonymous struct. initial motivation for these changes was to reduce the 'very long type names' issue described here https://github.com/ziglang/zig/pull/19682. this breaks the previous API. users will now need to write: `const map = std.StaticStringMap(T).initComptime(kvs_list);` * move `kvs_list` param from type param to an `initComptime()` param * new public methods * `keys()`, `values()` helpers * `init(allocator)`, `deinit(allocator)` for runtime data * `getLongestPrefix(str)`, `getLongestPrefixIndex(str)` - i'm not sure these belong but have left in for now incase they are deemed useful * performance notes: * i posted some benchmarking results here: https://github.com/travisstaloch/comptime-string-map-revised/issues/1 * i noticed a speedup reducing the size of the struct from 48 to 32 bytes and thus use u32s instead of usize for all length fields * i noticed speedup storing KVs as a struct of arrays * latest benchmark shows these wall_time improvements for debug/safe/small/fast builds: -6.6% / -10.2% / -19.1% / -8.9%. full output in link above.
2024-04-20Revert "disable flaky std.fs test"Jacob Young
This reverts commit d080622cc3f5db1ae3cd628c21c1ffaeb2b899d5. Workaround applied to CI.
2024-04-19disable flaky std.fs testAndrew Kelley
Tracked by #17134
2024-03-19extract std.posix from std.osAndrew Kelley
closes #5019
2024-02-29fs/test: Make testWithAllSupportedPathTypes also test all supported path ↵Ryan Liptak
separators Now, all the tests that use `testWithAllSupportedPathTypes` will also run each test with both `/` and `\` as the path separator on Windows. Also, removes the now-redundant "Dir.symLink with relative target that has a / path separator" since the same thing is now tested in the "Dir.readLink" test
2024-02-29Fix symLink's handling of `/` path separators on WindowsRyan Liptak
Symlink targets require canonicalized path separators on Windows
2024-02-24Fix handling of Windows (WTF-16) and WASI (UTF-8) pathsRyan Liptak
Windows paths now use WTF-16 <-> WTF-8 conversion everywhere, which is lossless. Previously, conversion of ill-formed UTF-16 paths would either fail or invoke illegal behavior. WASI paths must be valid UTF-8, and the relevant function calls have been updated to handle the possibility of failure due to paths not being encoded/encodable as valid UTF-8. Closes #18694 Closes #1774 Closes #2565
2024-02-11some API work on std.c, std.os, std.os.wasiAndrew Kelley
* std.c: consolidate some definitions, making them share code. For example, freebsd, dragonfly, and openbsd can all share the same `pthread_mutex_t` definition. * add type safety to std.c.O - this caught a bug where mode flags were incorrectly passed as the open flags. * 3 fewer uses of usingnamespace keyword * as per convention, remove purposeless field prefixes from struct field names even if they have those prefixes in the corresponding C code. * fix incorrect wasi libc Stat definition * remove C definitions from incorrectly being in std.os.wasi * make std.os.wasi definitions type safe * go through wasi native APIs even when linking libc because the libc APIs are problematic and wasteful * don't expose WASI definitions in std.posix * remove std.os.wasi.rights_t.ALL: this is a footgun. should it be all future rights too? or only all current rights known? both are the wrong answer.
2024-02-09Merge pull request #18712 from Vexu/std.optionsAndrew Kelley
std: make options a struct instance instead of a namespace
2024-02-02fs tests: Make path type show up in stack traces of ↵Ryan Liptak
testWithAllSupportedPathTypes This allows for easier debugging without the need to print out the path type to stderr. Context: 5a3ae38f3b79a69cb6f4ad28934a51165cae2ef1