authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2023-03-13 12:15:45-07:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2023-03-15 10:48:14-07:00
log61d7e31078fc54010009494d894e2461b41eeee2
tree318bd88d0a4d9ad30b88010bdd6171a4e551ea5e
parent8a8f148c8cb1254a3989584c54181218434b56c9

remove bad unit test from std lib

This unit test tested the command line arguments which were passed to the test runner, which is not really something that unit tests are supposed to observe. The proper way to test command line argument parsing is with a standalone test, where the set of command line arguments being tested for are also being controlled by the test itself.

1 files changed, 0 insertions(+), 18 deletions(-)

lib/std/process.zig-18
......@@ -828,24 +828,6 @@ pub fn argsWithAllocator(allocator: Allocator) ArgIterator.InitError!ArgIterator
828828 return ArgIterator.initWithAllocator(allocator);
829829}
830830
831test "args iterator" {
832 var ga = std.testing.allocator;
833 var it = try argsWithAllocator(ga);
834 defer it.deinit(); // no-op unless WASI or Windows
835
836 const prog_name = it.next() orelse unreachable;
837 const expected_suffix = switch (builtin.os.tag) {
838 .wasi => "test.wasm",
839 .windows => "test.exe",
840 else => "test",
841 };
842 const given_suffix = std.fs.path.basename(prog_name);
843
844 try testing.expect(mem.eql(u8, expected_suffix, given_suffix));
845 try testing.expect(it.next() == null);
846 try testing.expect(!it.skip());
847}
848
849831/// Caller must call argsFree on result.
850832pub fn argsAlloc(allocator: Allocator) ![][:0]u8 {
851833 // TODO refactor to only make 1 allocation.