aboutsummaryrefslogtreecommitdiff
path: root/lib/std/testing.zig
AgeCommit message (Collapse)Author
2020-05-22std.testing: fix a crash when printing diffsAndrew Kelley
2020-05-18Integrate getTestDir with tmpDir logicJakub Konka
2020-05-18Add/fix missing WASI functionality to pass libstd testsJakub Konka
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
2020-05-01rework std.math.big.IntAndrew Kelley
Now there are 3 types: * std.math.big.int.Const - the memory is immutable, only stores limbs and is_positive - all methods operating on constant data go here * std.math.big.int.Mutable - the memory is mutable, stores capacity in addition to limbs and is_positive - methods here have some Mutable parameters and some Const parameters. These methods expect callers to pre-calculate the amount of resources required, and asserts that the resources are available. * std.math.big.int.Managed - the memory is mutable and additionally stores an allocator. - methods here perform the resource calculations for the programmer. - this is the high level abstraction from before Each of these 3 types can be converted to the other ones. You can see the use case for this in the self-hosted compiler, where we only store limbs, and construct the big ints as needed. This gets rid of the hack where the allocator was optional and the notion of "fixed" versions of the struct. Such things are now modeled with the `big.int.Const` type.
2020-05-01add ZIR compare output test case to test suiteAndrew Kelley
2020-04-30move printWithVisibleNewlines to testing.expectEqualStringsVexu
2020-04-07fix broken testsVexu
2020-03-01short std.builtin enum literals in std libxackus
2020-02-28separate std.Target and std.zig.CrossTargetAndrew Kelley
Zig now supports a more fine-grained sense of what is native and what is not. Some examples: This is now allowed: -target native Different OS but native CPU, default Windows C ABI: -target native-windows This could be useful for example when running in Wine. Different CPU but native OS, native C ABI. -target x86_64-native -mcpu=skylake Different C ABI but otherwise native target: -target native-native-musl -target native-native-gnu Lots of breaking changes to related std lib APIs. Calls to getOs() will need to be changed to getOsTag(). Calls to getArch() will need to be changed to getCpuArch(). Usage of Target.Cross and Target.Native need to be updated to use CrossTarget API. `std.build.Builder.standardTargetOptions` is changed to accept its parameters as a struct with default values. It now has the ability to specify a whitelist of targets allowed, as well as the default target. Rather than two different ways of collecting the target, it's now always a string that is validated, and prints helpful diagnostics for invalid targets. This feature should now be actually useful, and contributions welcome to further improve the user experience. `std.build.LibExeObjStep.setTheTarget` is removed. `std.build.LibExeObjStep.setTarget` is updated to take a CrossTarget parameter. `std.build.LibExeObjStep.setTargetGLibC` is removed. glibc versions are handled in the CrossTarget API and can be specified with the `-target` triple. `std.builtin.Version` gains a `format` method.
2020-02-14std: increase memory available to testing allocatordaurnimator
2020-02-13Vector comparison in meta and testingdata-man
2020-01-30Convert a few more page_allocatorBenjamin Feng
2020-01-29Promoted "leak_count_allocator" to the main testing.allocatorBenjamin Feng
2020-01-29Move FailingAllocator to testingBenjamin Feng
2020-01-29Create leak_count_allocatorBenjamin Feng
2020-01-29Move debug.global_allocator to testing.allocatorBenjamin Feng
2019-12-29Fixes #3966data-man
2019-12-10Replace @typeOf with @TypeOf in all zig sourceRobin Voetter
This change was mostly made with `zig fmt` and this also modified some whitespace. Note that in some files, `zig fmt` produced incorrect code, so the change was made manually.
2019-12-09remove no-longer-needed workaround for var argsAndrew Kelley
See #557
2019-12-09remove var args from the languageAndrew Kelley
closes #208
2019-12-08std.fmt.format: tuple parameter instead of var argsAndrew Kelley
2019-11-27Implements std.testing.expectEqual for tagged unions. (#3773)Felix Queißner
2019-11-19std.testing.expectEqual: show differing pointer valuesJohan Bolmsjö
Show differing pointer values when comparing pointers instead of the content they point to. It's confusing for a test to say "expected S{.x = 1}, found S{.x = 1}" as illustrated below when it was the pointers that differed. There seems to be different rules for when a pointer is dereferenced by the printing routine depending on its type. I don't fully grok this but it's also illustrated below. const std = @import("std"); const S = struct { x: u32 }; // before: ...expected S{ .x = 1 }, found S{ .x = 1 } // after: ...expected S@7ffcd20b7798, found S@7ffcd20b7790 test "compare_ptr_to_struct" { var a = S{.x = 1}; var b = S{.x = 1}; std.testing.expectEqual(&a, &b); } // before: ...expected u32@7fff316ba31c, found u32@7fff316ba318 // after: ...expected u32@7ffecec622dc, found u32@7ffecec622d8 test "compare_ptr_to_scalar" { var a: u32 = 1; var b: u32 = 1; std.testing.expectEqual(&a, &b); }
2019-09-25mv std/ lib/Andrew Kelley
that's all this commit does. further commits will fix cli flags and such. see #2221