aboutsummaryrefslogtreecommitdiff
path: root/lib/std/testing.zig
AgeCommit message (Collapse)Author
23 hoursstd.testing: use debug Io instance in expectEqualSlicesAndrew Kelley
23 hoursstd: prevent testing.io from use outside testsAndrew Kelley
4 daysstd: add changing cur dir backAndrew Kelley
There's a good argument to not have this in the std lib but it's more work to remove it than to leave it in, and this branch is already 20,000+ lines changed.
4 daysstd: rename other Dir "make" functions to "create"Andrew Kelley
4 dayscompiler: fix compilation when linking libcAndrew Kelley
4 daysfix more fallout from locking stderrAndrew Kelley
4 dayslink.MappedFile: update statx usageAndrew Kelley
4 daysupdate lockStderrWriter sitesAndrew Kelley
use the application's Io implementation where possible. This correctly makes writing to stderr cancelable, fallible, and participate in the application's event loop. It also removes one more hard-coded dependency on a secondary Io implementation.
4 daysstd: update tty config references in the build systemAndrew Kelley
4 daysstd.debug: fix printLineFromFileAndrew Kelley
4 daysupdate makeDir() sites to specify permissionsAndrew Kelley
4 daysupdate all std.fs.cwd() to std.Io.Dir.cwd()Andrew Kelley
4 daysupdate all occurrences of std.fs.Dir to std.Io.DirAndrew Kelley
4 daysupdate all occurrences of close() to close(io)Andrew Kelley
6 daysMerge pull request 'std.ascii: rename indexOf functions to find' (#30101) ↵Alex Rønne Petersen
from adria/zig:indexof-find into master Reviewed-on: https://codeberg.org/ziglang/zig/pulls/30101 Reviewed-by: Andrew Kelley <andrewrk@noreply.codeberg.org> Reviewed-by: mlugg <mlugg@noreply.codeberg.org>
2025-12-05std: replace usages of std.mem.indexOf with std.mem.findAdrià Arrufat
2025-11-27std: Remove a handful of things deprecated during the 0.15 release cycleLinus Groh
- std.Build.Step.Compile.root_module mutators -> std.Build.Module - std.Build.Step.Compile.want_lto -> std.Build.Step.Compile.lto - std.Build.Step.ConfigHeader.getOutput -> std.Build.Step.ConfigHeader.getOutputFile - std.Build.Step.Run.max_stdio_size -> std.Build.Step.Run.stdio_limit - std.enums.nameCast -> @field(E, tag_name) / @field(E, @tagName(tag)) - std.Io.tty.detectConfig -> std.Io.tty.Config.detect - std.mem.trimLeft -> std.mem.trimStart - std.mem.trimRight -> std.mem.trimEnd - std.meta.intToEnum -> std.enums.fromInt - std.meta.TagPayload -> @FieldType(U, @tagName(tag)) - std.meta.TagPayloadByName -> @FieldType(U, tag_name)
2025-11-25std.testing: Fix expectEqualDeep formatted enum (#25960)Nir Lahad
2025-10-30std.debug.lockStderrWriter: also return ttyconfMatthew Lugg
`std.Io.tty.Config.detect` may be an expensive check (e.g. involving syscalls), and doing it every time we need to print isn't really necessary; under normal usage, we can compute the value once and cache it for the whole program's execution. Since anyone outputting to stderr may reasonably want this information (in fact they are very likely to), it makes sense to cache it and return it from `lockStderrWriter`. Call sites who do not need it will experience no significant overhead, and can just ignore the TTY config with a `const w, _` destructure.
2025-10-29std: fix compilation errors on WindowsAndrew Kelley
2025-10-29Io.net: finish implementing IPv6 parsingAndrew Kelley
2025-10-29add std.testing.ioAndrew Kelley
2025-10-08Reader.peekDelimiterInclusive: Fix handling of `stream` implementations that ↵Ryan Liptak
return 0 Previously, the logic in peekDelimiterInclusive (when the delimiter was not found in the existing buffer) used the `n` returned from `r.vtable.stream` as the length of the slice to check, but it's valid for `vtable.stream` implementations to return 0 if they wrote to the buffer instead of `w`. In that scenario, the `indexOfScalarPos` would be given a 0-length slice so it would never be able to find the delimiter. This commit changes the logic to assume that `r.vtable.stream` can both: - return 0, and - modify seek/end (i.e. it's also valid for a `vtable.stream` implementation to rebase) Also introduces `std.testing.ReaderIndirect` which helps in being able to test against Reader implementations that return 0 from `stream`/`readVec` Fixes #25428
2025-09-20coerce vectors to arrays rather than inline forAndrew Kelley
2025-09-20compiler: require comptime vector indexesAndrew Kelley
2025-08-29std.Io: delete GenericReaderAndrew Kelley
and delete deprecated alias std.io
2025-07-22aarch64: add new from scratch self-hosted backendJacob Young
2025-07-17std.Io.Reader: update OneByteReader usage to std.testing.ReaderAndrew Kelley
2025-07-09std.io.Reader.peekDelimiterInclusive: simplify and fixAndrew Kelley
2025-07-07std.testing: update to new std.io APIAndrew 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-07-07std.io: move getStdIn, getStdOut, getStdErr functions to fs.FileAndrew Kelley
preparing to rearrange std.io namespace into an interface how to upgrade: std.io.getStdIn() -> std.fs.File.stdin() std.io.getStdOut() -> std.fs.File.stdout() std.io.getStdErr() -> std.fs.File.stderr()
2025-06-23std.mem.byteSwapAllFields: support untagged unionsAli Cheraghi
2025-06-16rename spirv backend nameAli Cheraghi
`stage2_spirv64` -> `stage2_spirv`
2025-05-20compiler: Scaffold stage2_powerpc backend.Alex Rønne Petersen
Nothing interesting here; literally just the bare minimum so I can work on this on and off in a branch without worrying about merge conflicts in the non-backend code.
2025-02-16std.testing: improve compile error on untagged union equalityMark Rushakoff
2025-02-15added expectEqualDeep test coverage for issue 16625 (#22781)Benjamin Thompson
2025-02-11fuzzer: write inputs to shared memory before runningAndrew Kelley
breaking change to the fuzz testing API; it now passes a type-safe context parameter to the fuzz function. libfuzzer is reworked to select inputs from the entire corpus. I tested that it's roughly as good as it was before in that it can find the panics in the simple examples, as well as achieve decent coverage on the tokenizer fuzz test. however I think the next step here will be figuring out why so many points of interest are missing from the tokenizer in both Debug and ReleaseSafe modes. does not quite close #20803 yet since there are some more important things to be done, such as opening the previous corpus, continuing fuzzing after finding bugs, storing the length of the inputs, etc.
2025-02-06std.testing: don't ask wasm to stack traceAndrew Kelley
2025-02-06std.testing.allocator: different canary + enable resize tracesAndrew Kelley
Accept a slight performance degradation when unit testing for better debuggability when a leak or double-free is detected.
2025-02-06std.testing: make some things not pubAndrew Kelley
this looks like it was an accident to expose these
2025-02-06std.testing.FailingAllocator: flatten namespaceAndrew Kelley
2025-01-29std.testing.expectEqual: {any} in print and move testsThisPC
2025-01-16all: update to `std.builtin.Type.Pointer.Size` field renamesmlugg
This was done by regex substitution with `sed`. I then manually went over the entire diff and fixed any incorrect changes. This diff also changes a lot of `callconv(.C)` to `callconv(.c)`, since my regex happened to also trigger here. I opted to leave these changes in, since they *are* a correct migration, even if they're not the one I was trying to do!
2024-11-12std.testing.expectError: fix error namesgooncreeper
2024-09-12Replace deprecated default initializations with decl literalsLinus Groh
2024-09-11rework fuzzing APIAndrew Kelley
The previous API used `std.testing.fuzzInput(.{})` however that has the problem that users call it multiple times incorrectly, and there might be work happening to obtain the corpus which should not be included in coverage analysis, and which must not slow down iteration speed. This commit restructures it so that the main loop lives in libfuzzer and directly calls the "test one" function. In this commit I was a little too aggressive because I made the test runner export `fuzzer_one` for this purpose. This was motivated by performance, but it causes "exported symbol collision: fuzzer_one" to occur when more than one fuzz test is provided. There are three ways to solve this: 1. libfuzzer needs to be passed a function pointer instead. Possible performance downside. 2. build runner needs to build a different process per fuzz test. Potentially wasteful and unclear how to isolate them. 3. test runner needs to perform a relocation at runtime to point the function call to the relevant unit test. Portability issues and dubious performance gains.
2024-08-28std: update `std.builtin.Type` fields to follow naming conventionsmlugg
The compiler actually doesn't need any functional changes for this: Sema does reification based on the tag indices of `std.builtin.Type` already! So, no zig1.wasm update is necessary. This change is necessary to disallow name clashes between fields and decls on a type, which is a prerequisite of #9938.
2024-07-25implement std.testing.fuzzInputAndrew Kelley
For now this returns a dummy fuzz input.
2024-07-25implement std.testing.fuzzInputAndrew Kelley
for the -fno-fuzz case. The other case will take more work in libfuzzer.