From 39b3417f8e7e5d3f2453c56da959eb592558d267 Mon Sep 17 00:00:00 2001 From: Eric Willigers Date: Wed, 7 Oct 2026 09:55:38 +1100 Subject: [PATCH] update to Zig 0.17.0 I used Claude for this PR --- Dockerfile | 2 +- bin/run-tests.sh | 11 +++++++---- tests/example-all-fail/expected_results.json | 18 +++++++++--------- .../example_anagram_success.zig | 2 +- .../expected_results.json | 4 ++-- .../expected_results.json | 2 +- .../example-memory-leak/expected_results.json | 2 +- .../expected_results.json | 8 ++++---- .../example-partial-fail/expected_results.json | 6 +++--- .../expected_results.json | 2 +- .../example-user-output/expected_results.json | 2 +- 11 files changed, 31 insertions(+), 28 deletions(-) diff --git a/Dockerfile b/Dockerfile index ac67324..ccb8d81 100644 --- a/Dockerfile +++ b/Dockerfile @@ -2,7 +2,7 @@ FROM alpine:3.24.1@sha256:28bd5fe8b56d1bd048e5babf5b10710ebe0bae67db86916198a6eec434943f8b AS builder -ARG VERSION=0.16.0 +ARG VERSION=0.17.0 ARG RELEASE=zig-x86_64-linux-${VERSION} # We can't reliably pin the package versions on Alpine, so we ignore the linter warning. diff --git a/bin/run-tests.sh b/bin/run-tests.sh index 536f561..66578ee 100755 --- a/bin/run-tests.sh +++ b/bin/run-tests.sh @@ -29,13 +29,16 @@ for test_dir in "${tmp_dir}"/*; do bin/run.sh "${test_dir_name}" "${test_dir_path}" "${test_dir_path}" for file in "$results_file_path" "$expected_results_file_path"; do - # We remove nondeterministic memory locations of instructions and - # compiler-generated anonymous function suffixes (e.g. - # `expectError__anon_17425`), both of which vary between builds. + # We remove nondeterministic memory locations of instructions and of + # leaked allocations (printed without a `0x` prefix, e.g. + # `leaked [addr: 7820fd4cc140,`) and compiler-generated function + # instantiation suffixes (e.g. `expectError__anon_17425` or + # `expectError__func_957`), all of which vary between builds. # See: https://github.com/exercism/zig-test-runner/issues/26 sed -E \ -e 's/0x[a-f0-9]+//g' \ - -e 's/__anon_[0-9]+/__anon_/g' \ + -e 's/addr: [a-f0-9]+/addr: /g' \ + -e 's/__(anon|func)_[0-9]+/__\1_/g' \ "${file}" > "${file}.tmp" done diff --git a/tests/example-all-fail/expected_results.json b/tests/example-all-fail/expected_results.json index 11969c8..a854427 100644 --- a/tests/example-all-fail/expected_results.json +++ b/tests/example-all-fail/expected_results.json @@ -6,55 +6,55 @@ "name": "year not divisible by 4 in common year", "test_code": "try testing.expect(!leap.leap(2015));", "status": "fail", - "message": "/opt/zig/lib/std/testing.zig:615:14: in expect (std.zig)\n if (!ok) return error.TestUnexpectedResult;\n ^\ntest_example_all_fail.zig:7:5: in test.year not divisible by 4 in common year (test_example_all_fail.zig)\n try testing.expect(!leap.leap(2015));\n ^" + "message": "/opt/zig/lib/std/testing.zig:584:14: in expect (std.zig)\n if (!ok) return error.TestUnexpectedResult;\n ^\ntest_example_all_fail.zig:7:5: in test.year not divisible by 4 in common year (test_example_all_fail.zig)\n try testing.expect(!leap.leap(2015));\n ^" }, { "name": "year divisible by 2, not divisible by 4 in common year", "test_code": "try testing.expect(!leap.leap(1970));", "status": "fail", - "message": "/opt/zig/lib/std/testing.zig:615:14: in expect (std.zig)\n if (!ok) return error.TestUnexpectedResult;\n ^\ntest_example_all_fail.zig:11:5: in test.year divisible by 2, not divisible by 4 in common year (test_example_all_fail.zig)\n try testing.expect(!leap.leap(1970));\n ^" + "message": "/opt/zig/lib/std/testing.zig:584:14: in expect (std.zig)\n if (!ok) return error.TestUnexpectedResult;\n ^\ntest_example_all_fail.zig:11:5: in test.year divisible by 2, not divisible by 4 in common year (test_example_all_fail.zig)\n try testing.expect(!leap.leap(1970));\n ^" }, { "name": "year divisible by 4, not divisible by 100 in leap year", "test_code": "try testing.expect(leap.leap(1996));", "status": "fail", - "message": "/opt/zig/lib/std/testing.zig:615:14: in expect (std.zig)\n if (!ok) return error.TestUnexpectedResult;\n ^\ntest_example_all_fail.zig:15:5: in test.year divisible by 4, not divisible by 100 in leap year (test_example_all_fail.zig)\n try testing.expect(leap.leap(1996));\n ^" + "message": "/opt/zig/lib/std/testing.zig:584:14: in expect (std.zig)\n if (!ok) return error.TestUnexpectedResult;\n ^\ntest_example_all_fail.zig:15:5: in test.year divisible by 4, not divisible by 100 in leap year (test_example_all_fail.zig)\n try testing.expect(leap.leap(1996));\n ^" }, { "name": "year divisible by 4 and 5 is still a leap year", "test_code": "try testing.expect(leap.leap(1960));", "status": "fail", - "message": "/opt/zig/lib/std/testing.zig:615:14: in expect (std.zig)\n if (!ok) return error.TestUnexpectedResult;\n ^\ntest_example_all_fail.zig:19:5: in test.year divisible by 4 and 5 is still a leap year (test_example_all_fail.zig)\n try testing.expect(leap.leap(1960));\n ^" + "message": "/opt/zig/lib/std/testing.zig:584:14: in expect (std.zig)\n if (!ok) return error.TestUnexpectedResult;\n ^\ntest_example_all_fail.zig:19:5: in test.year divisible by 4 and 5 is still a leap year (test_example_all_fail.zig)\n try testing.expect(leap.leap(1960));\n ^" }, { "name": "year divisible by 100, not divisible by 400 in common year", "test_code": "try testing.expect(!leap.leap(2100));", "status": "fail", - "message": "/opt/zig/lib/std/testing.zig:615:14: in expect (std.zig)\n if (!ok) return error.TestUnexpectedResult;\n ^\ntest_example_all_fail.zig:23:5: in test.year divisible by 100, not divisible by 400 in common year (test_example_all_fail.zig)\n try testing.expect(!leap.leap(2100));\n ^" + "message": "/opt/zig/lib/std/testing.zig:584:14: in expect (std.zig)\n if (!ok) return error.TestUnexpectedResult;\n ^\ntest_example_all_fail.zig:23:5: in test.year divisible by 100, not divisible by 400 in common year (test_example_all_fail.zig)\n try testing.expect(!leap.leap(2100));\n ^" }, { "name": "year divisible by 100 but not by 3 is still not a leap year", "test_code": "try testing.expect(!leap.leap(1900));", "status": "fail", - "message": "/opt/zig/lib/std/testing.zig:615:14: in expect (std.zig)\n if (!ok) return error.TestUnexpectedResult;\n ^\ntest_example_all_fail.zig:27:5: in test.year divisible by 100 but not by 3 is still not a leap year (test_example_all_fail.zig)\n try testing.expect(!leap.leap(1900));\n ^" + "message": "/opt/zig/lib/std/testing.zig:584:14: in expect (std.zig)\n if (!ok) return error.TestUnexpectedResult;\n ^\ntest_example_all_fail.zig:27:5: in test.year divisible by 100 but not by 3 is still not a leap year (test_example_all_fail.zig)\n try testing.expect(!leap.leap(1900));\n ^" }, { "name": "year divisible by 400 is leap year", "test_code": "try testing.expect(leap.leap(2000));", "status": "fail", - "message": "/opt/zig/lib/std/testing.zig:615:14: in expect (std.zig)\n if (!ok) return error.TestUnexpectedResult;\n ^\ntest_example_all_fail.zig:31:5: in test.year divisible by 400 is leap year (test_example_all_fail.zig)\n try testing.expect(leap.leap(2000));\n ^" + "message": "/opt/zig/lib/std/testing.zig:584:14: in expect (std.zig)\n if (!ok) return error.TestUnexpectedResult;\n ^\ntest_example_all_fail.zig:31:5: in test.year divisible by 400 is leap year (test_example_all_fail.zig)\n try testing.expect(leap.leap(2000));\n ^" }, { "name": "year divisible by 400 but not by 125 is still a leap year", "test_code": "try testing.expect(leap.leap(2400));", "status": "fail", - "message": "/opt/zig/lib/std/testing.zig:615:14: in expect (std.zig)\n if (!ok) return error.TestUnexpectedResult;\n ^\ntest_example_all_fail.zig:35:5: in test.year divisible by 400 but not by 125 is still a leap year (test_example_all_fail.zig)\n try testing.expect(leap.leap(2400));\n ^" + "message": "/opt/zig/lib/std/testing.zig:584:14: in expect (std.zig)\n if (!ok) return error.TestUnexpectedResult;\n ^\ntest_example_all_fail.zig:35:5: in test.year divisible by 400 but not by 125 is still a leap year (test_example_all_fail.zig)\n try testing.expect(leap.leap(2400));\n ^" }, { "name": "year divisible by 200, not divisible by 400 in common year", "test_code": "try testing.expect(!leap.leap(1800));", "status": "fail", - "message": "/opt/zig/lib/std/testing.zig:615:14: in expect (std.zig)\n if (!ok) return error.TestUnexpectedResult;\n ^\ntest_example_all_fail.zig:39:5: in test.year divisible by 200, not divisible by 400 in common year (test_example_all_fail.zig)\n try testing.expect(!leap.leap(1800));\n ^" + "message": "/opt/zig/lib/std/testing.zig:584:14: in expect (std.zig)\n if (!ok) return error.TestUnexpectedResult;\n ^\ntest_example_all_fail.zig:39:5: in test.year divisible by 200, not divisible by 400 in common year (test_example_all_fail.zig)\n try testing.expect(!leap.leap(1800));\n ^" } ] } diff --git a/tests/example-anagram-success/example_anagram_success.zig b/tests/example-anagram-success/example_anagram_success.zig index 1ef9d77..ba6ee99 100644 --- a/tests/example-anagram-success/example_anagram_success.zig +++ b/tests/example-anagram-success/example_anagram_success.zig @@ -4,7 +4,7 @@ const mem = std.mem; /// Returns the case-insensitive counts of English letters in `s`. /// Caller guarantees that `s` contains at most 15 of a single letter. fn count(s: []const u8) [26]u4 { - var result = [_]u4{0} ** 26; + var result: [26]u4 = @splat(0); for (s) |c| { switch (c) { 'A'...'Z' => result[c - 'A'] += 1, diff --git a/tests/example-debug-error-output/expected_results.json b/tests/example-debug-error-output/expected_results.json index ddf791f..04eaeae 100644 --- a/tests/example-debug-error-output/expected_results.json +++ b/tests/example-debug-error-output/expected_results.json @@ -12,14 +12,14 @@ "name": "failing test alongside error-like debug output", "test_code": "try testing.expect(mod.greet().len == 99);", "status": "fail", - "message": "FAIL (TestUnexpectedResult)\n/opt/zig/lib/std/testing.zig:615:14: in expect (std.zig)\n if (!ok) return error.TestUnexpectedResult;\n ^\ntest_example_debug_error_output.zig:15:5: in test.failing test alongside error-like debug output (test_example_debug_error_output.zig)\n try testing.expect(mod.greet().len == 99);\n ^", + "message": "FAIL (TestUnexpectedResult)\n/opt/zig/lib/std/testing.zig:584:14: in expect (std.zig)\n if (!ok) return error.TestUnexpectedResult;\n ^\ntest_example_debug_error_output.zig:15:5: in test.failing test alongside error-like debug output (test_example_debug_error_output.zig)\n try testing.expect(mod.greet().len == 99);\n ^", "output": "error: greet was called with no arguments" }, { "name": "failing line carries an error-like comment", "test_code": "try testing.expect(mod.greet().len == 99); // error: expected a longer greeting", "status": "fail", - "message": "FAIL (TestUnexpectedResult)\n/opt/zig/lib/std/testing.zig:615:14: in expect (std.zig)\n if (!ok) return error.TestUnexpectedResult;\n ^\ntest_example_debug_error_output.zig:19:5: in test.failing line carries an error-like comment (test_example_debug_error_output.zig)\n try testing.expect(mod.greet().len == 99); // error: expected a longer greeting\n ^", + "message": "FAIL (TestUnexpectedResult)\n/opt/zig/lib/std/testing.zig:584:14: in expect (std.zig)\n if (!ok) return error.TestUnexpectedResult;\n ^\ntest_example_debug_error_output.zig:19:5: in test.failing line carries an error-like comment (test_example_debug_error_output.zig)\n try testing.expect(mod.greet().len == 99); // error: expected a longer greeting\n ^", "output": "error: greet was called with no arguments" } ] diff --git a/tests/example-error-exercise/expected_results.json b/tests/example-error-exercise/expected_results.json index 7816da0..a6aac09 100644 --- a/tests/example-error-exercise/expected_results.json +++ b/tests/example-error-exercise/expected_results.json @@ -26,7 +26,7 @@ "name": "zero is an error", "test_code": "const expected = ComputationError.IllegalArgument;\nconst actual = collatz.steps(0);\ntry testing.expectError(expected, actual);", "status": "fail", - "message": "FAIL (TestExpectedError)\n/opt/zig/lib/std/testing.zig:65:9: in expectError__anon_ (std.zig)\n return error.TestExpectedError;\n ^\ntest_example_error_exercise.zig:34:5: in test.zero is an error (test_example_error_exercise.zig)\n try testing.expectError(expected, actual);\n ^" + "message": "FAIL (TestExpectedError)\n/opt/zig/lib/std/testing.zig:634:9: in expectError__func_ (std.zig)\n return error.TestExpectedError;\n ^\ntest_example_error_exercise.zig:34:5: in test.zero is an error (test_example_error_exercise.zig)\n try testing.expectError(expected, actual);\n ^" } ] } diff --git a/tests/example-memory-leak/expected_results.json b/tests/example-memory-leak/expected_results.json index 3171b8f..2c341e0 100644 --- a/tests/example-memory-leak/expected_results.json +++ b/tests/example-memory-leak/expected_results.json @@ -6,7 +6,7 @@ "name": "makePair cleans up on allocation failure", "test_code": "try std.testing.checkAllAllocationFailures(\n std.testing.allocator,\n pairTest,\n .{},\n);", "status": "fail", - "message": "FAIL (MemoryLeakDetected)\n/opt/zig/lib/std/mem/Allocator.zig:300:82: in allocBytesWithAlignment__anon_ (std.zig)\n const byte_ptr = self.rawAlloc(byte_count, alignment, return_address) orelse return error.OutOfMemory;\n ^\n/opt/zig/lib/std/mem/Allocator.zig:286:5: in allocWithSizeAndAlignment__anon_ (std.zig)\n return self.allocBytesWithAlignment(alignment, byte_count, return_address);\n ^\n/opt/zig/lib/std/mem/Allocator.zig:274:55: in allocAdvancedWithRetAddr (std.zig)\n const ptr: [*]align(a.toByteUnits()) T = @ptrCast(try self.allocWithSizeAndAlignment(@sizeOf(T), a, n, return_address));\n ^\n/opt/zig/lib/std/mem/Allocator.zig:198:5: in alloc__anon_ (std.zig)\n return self.allocAdvancedWithRetAddr(T, null, n, @returnAddress());\n ^\nexample_memory_leak.zig:9:20: in makePair (test_example_memory_leak.zig)\n const second = try allocator.alloc(u8, 16);\n ^\ntest_example_memory_leak.zig:7:15: in pairTest (test_example_memory_leak.zig)\n const p = try mod.makePair(allocator);\n ^\n/opt/zig/lib/std/testing.zig:1156:21: in checkAllAllocationFailures__anon_ (std.zig)\n return error.MemoryLeakDetected;\n ^\ntest_example_memory_leak.zig:13:5: in test.makePair cleans up on allocation failure (test_example_memory_leak.zig)\n try std.testing.checkAllAllocationFailures(\n ^\n[DebugAllocator] (err): memory address leaked: \nexample_memory_leak.zig:8:38: in makePair (test_example_memory_leak.zig)\n const first = try allocator.alloc(u8, 16);\n ^\ntest_example_memory_leak.zig:7:31: in pairTest (test_example_memory_leak.zig)\n const p = try mod.makePair(allocator);\n ^\n/opt/zig/lib/std/testing.zig:1133:69: in checkAllAllocationFailures__anon_ (std.zig)\n if (@call(.auto, test_fn, .{failing_allocator_inst.allocator()} ++ extra_args)) |_| {\n ^\ntest_example_memory_leak.zig:13:47: in test.makePair cleans up on allocation failure (test_example_memory_leak.zig)\n try std.testing.checkAllAllocationFailures(\n ^\n/opt/zig/lib/compiler/test_runner.zig:291:25: in mainTerminal (test_runner.zig)\n if (test_fn.func()) |_| {\n ^\n/opt/zig/lib/compiler/test_runner.zig:73:28: in main (test_runner.zig)\n return mainTerminal(init);\n ^\n/opt/zig/lib/std/start.zig:699:88: in callMain (std.zig)\n if (fn_info.params[0].type.? == std.process.Init.Minimal) return wrapMain(root.main(.{\n ^\n/opt/zig/lib/std/start.zig:190:5: in _start (std.zig)\n asm volatile (switch (native_arch) {\n ^", + "message": "FAIL (MemoryLeakDetected)\n/opt/zig/lib/std/mem/Allocator.zig:325:82: in allocBytesAligned__func_ (std.zig)\n const byte_ptr = self.rawAlloc(byte_count, alignment, return_address) orelse return error.OutOfMemory;\n ^\n/opt/zig/lib/std/mem/Allocator.zig:311:5: in allocWithSizeAndAlignment__func_ (std.zig)\n return self.allocBytesAligned(alignment, byte_count, return_address);\n ^\n/opt/zig/lib/std/mem/Allocator.zig:299:55: in allocAdvancedWithRetAddr (std.zig)\n const ptr: [*]align(a.toByteUnits()) T = @ptrCast(try self.allocWithSizeAndAlignment(@sizeOf(T), a, n, return_address));\n ^\n/opt/zig/lib/std/mem/Allocator.zig:223:5: in alloc__func_ (std.zig)\n return self.allocAdvancedWithRetAddr(T, null, n, @returnAddress());\n ^\nexample_memory_leak.zig:9:20: in makePair (test_example_memory_leak.zig)\n const second = try allocator.alloc(u8, 16);\n ^\ntest_example_memory_leak.zig:7:15: in pairTest (test_example_memory_leak.zig)\n const p = try mod.makePair(allocator);\n ^\n/opt/zig/lib/std/testing.zig:1186:21: in checkAllAllocationFailures__func_ (std.zig)\n return error.MemoryLeakDetected;\n ^\ntest_example_memory_leak.zig:13:5: in test.makePair cleans up on allocation failure (test_example_memory_leak.zig)\n try std.testing.checkAllAllocationFailures(\n ^\n[SafeAllocator] (err): leaked [addr: , len: 16 () align: 1] allocated at: \nexample_memory_leak.zig:8:38: in makePair (test_example_memory_leak.zig)\n const first = try allocator.alloc(u8, 16);\n ^\ntest_example_memory_leak.zig:7:31: in pairTest (test_example_memory_leak.zig)\n const p = try mod.makePair(allocator);\n ^\n/opt/zig/lib/std/testing.zig:1163:69: in checkAllAllocationFailures__func_ (std.zig)\n if (@call(.auto, test_fn, .{failing_allocator_inst.allocator()} ++ extra_args)) |_| {\n ^\ntest_example_memory_leak.zig:13:47: in test.makePair cleans up on allocation failure (test_example_memory_leak.zig)\n try std.testing.checkAllAllocationFailures(\n ^\n/opt/zig/lib/compiler/test_runner.zig:295:25: in mainTerminal (test_runner.zig)\n if (test_fn.func()) |_| {\n ^\n/opt/zig/lib/compiler/test_runner.zig:74:28: in main (test_runner.zig)\n return mainTerminal(init);\n ^\n/opt/zig/lib/std/start.zig:789:88: in callMain (std.zig)\n if (fn_info.param_types[0].? == std.process.Init.Minimal) return wrapMain(root.main(.{\n ^\n(additional stack frames may have been skipped...)", "output": "fail_index: 1/2\nallocated bytes: 16\nfreed bytes: 0\nallocations: 1\ndeallocations: 0\nallocation that was made to fail: \nexample_memory_leak.zig:9:39: in makePair (test_example_memory_leak.zig)\n const second = try allocator.alloc(u8, 16);\n ^\ntest_example_memory_leak.zig:7:31: in pairTest (test_example_memory_leak.zig)\n const p = try mod.makePair(allocator);\n ^\n/opt/zig/lib/std/testing.zig: [output truncated]" }, { diff --git a/tests/example-output-truncated/expected_results.json b/tests/example-output-truncated/expected_results.json index ca28fbb..2bb17d9 100644 --- a/tests/example-output-truncated/expected_results.json +++ b/tests/example-output-truncated/expected_results.json @@ -12,21 +12,21 @@ "name": "detects two anagrams", "test_code": "const expected = [_][]const u8{ \"lemons\", \"melons\" };\nconst word = \"solemn\";\nconst candidates = [_][]const u8{ \"lemons\", \"cherry\", \"melons\" };\ntry std.testing.checkAllAllocationFailures(\n std.testing.allocator,\n testAnagrams,\n .{ &expected, word, &candidates },\n);", "status": "fail", - "message": "FAIL (TestExpectedEqual)\n/opt/zig/lib/std/testing.zig:118:17: in expectEqualInner__anon_ (std.zig)\n return error.TestExpectedEqual;\n ^\n/opt/zig/lib/std/testing.zig:83:5: in expectEqual (test_example_output_truncated.zig)\n return expectEqualInner(T, expected, actual);\n ^\ntest_example_output_truncated.zig:14:5: in testAnagrams (test_example_output_truncated.zig)\n try testing.expectEqual(expected.len, actual.count());\n ^\n/opt/zig/lib/std/testing.zig:1124:9: in checkAllAllocationFailures__anon_ (std.zig)\n try @call(.auto, test_fn, .{failing_allocator_inst.allocator()} ++ extra_args);\n ^\ntest_example_output_truncated.zig:35:5: in test.detects two anagrams (test_example_output_truncated.zig)\n try std.testing.checkAllAllocationFailures(\n ^", + "message": "FAIL (TestExpectedEqual)\n/opt/zig/lib/std/testing.zig:93:17: in expectEqualInner__func_ (std.zig)\n return error.TestExpectedEqual;\n ^\n/opt/zig/lib/std/testing.zig:57:5: in expectEqual (test_example_output_truncated.zig)\n return expectEqualInner(T, expected, actual);\n ^\ntest_example_output_truncated.zig:14:5: in testAnagrams (test_example_output_truncated.zig)\n try testing.expectEqual(expected.len, actual.count());\n ^\n/opt/zig/lib/std/testing.zig:1154:9: in checkAllAllocationFailures__func_ (std.zig)\n try @call(.auto, test_fn, .{failing_allocator_inst.allocator()} ++ extra_args);\n ^\ntest_example_output_truncated.zig:35:5: in test.detects two anagrams (test_example_output_truncated.zig)\n try std.testing.checkAllAllocationFailures(\n ^", "output": "lemons\ncherry\nmelons\nexpected 2, found 0" }, { "name": "detects three anagrams", "test_code": "const expected = [_][]const u8{ \"gallery\", \"regally\", \"largely\" };\nconst word = \"allergy\";\nconst candidates = [_][]const u8{ \"gallery\", \"ballerina\", \"regally\", \"clergy\", \"largely\", \"leading\" };\ntry std.testing.checkAllAllocationFailures(\n std.testing.allocator,\n testAnagrams,\n .{ &expected, word, &candidates },\n);", "status": "fail", - "message": "FAIL (TestExpectedEqual)\n/opt/zig/lib/std/testing.zig:118:17: in expectEqualInner__anon_ (std.zig)\n return error.TestExpectedEqual;\n ^\n/opt/zig/lib/std/testing.zig:83:5: in expectEqual (test_example_output_truncated.zig)\n return expectEqualInner(T, expected, actual);\n ^\ntest_example_output_truncated.zig:14:5: in testAnagrams (test_example_output_truncated.zig)\n try testing.expectEqual(expected.len, actual.count());\n ^\n/opt/zig/lib/std/testing.zig:1124:9: in checkAllAllocationFailures__anon_ (std.zig)\n try @call(.auto, test_fn, .{failing_allocator_inst.allocator()} ++ extra_args);\n ^\ntest_example_output_truncated.zig:46:5: in test.detects three anagrams (test_example_output_truncated.zig)\n try std.testing.checkAllAllocationFailures(\n ^", + "message": "FAIL (TestExpectedEqual)\n/opt/zig/lib/std/testing.zig:93:17: in expectEqualInner__func_ (std.zig)\n return error.TestExpectedEqual;\n ^\n/opt/zig/lib/std/testing.zig:57:5: in expectEqual (test_example_output_truncated.zig)\n return expectEqualInner(T, expected, actual);\n ^\ntest_example_output_truncated.zig:14:5: in testAnagrams (test_example_output_truncated.zig)\n try testing.expectEqual(expected.len, actual.count());\n ^\n/opt/zig/lib/std/testing.zig:1154:9: in checkAllAllocationFailures__func_ (std.zig)\n try @call(.auto, test_fn, .{failing_allocator_inst.allocator()} ++ extra_args);\n ^\ntest_example_output_truncated.zig:46:5: in test.detects three anagrams (test_example_output_truncated.zig)\n try std.testing.checkAllAllocationFailures(\n ^", "output": "gallery\nballerina\nregally\nclergy\nlargely\nleading\nexpected 3, found 0" }, { "name": "detects anagrams case-insensitively", "test_code": "const expected = [_][]const u8{\"Carthorse\"};\nconst word = \"Orchestra\";\nconst candidates = [_][]const u8{ \"cashregister\", \"Carthorse\", \"radishes\" };\ntry std.testing.checkAllAllocationFailures(\n std.testing.allocator,\n testAnagrams,\n .{ &expected, word, &candidates },\n);", "status": "fail", - "message": "FAIL (TestExpectedEqual)\n/opt/zig/lib/std/testing.zig:118:17: in expectEqualInner__anon_ (std.zig)\n return error.TestExpectedEqual;\n ^\n/opt/zig/lib/std/testing.zig:83:5: in expectEqual (test_example_output_truncated.zig)\n return expectEqualInner(T, expected, actual);\n ^\ntest_example_output_truncated.zig:14:5: in testAnagrams (test_example_output_truncated.zig)\n try testing.expectEqual(expected.len, actual.count());\n ^\n/opt/zig/lib/std/testing.zig:1124:9: in checkAllAllocationFailures__anon_ (std.zig)\n try @call(.auto, test_fn, .{failing_allocator_inst.allocator()} ++ extra_args);\n ^\ntest_example_output_truncated.zig:57:5: in test.detects anagrams case-insensitively (test_example_output_truncated.zig)\n try std.testing.checkAllAllocationFailures(\n ^", + "message": "FAIL (TestExpectedEqual)\n/opt/zig/lib/std/testing.zig:93:17: in expectEqualInner__func_ (std.zig)\n return error.TestExpectedEqual;\n ^\n/opt/zig/lib/std/testing.zig:57:5: in expectEqual (test_example_output_truncated.zig)\n return expectEqualInner(T, expected, actual);\n ^\ntest_example_output_truncated.zig:14:5: in testAnagrams (test_example_output_truncated.zig)\n try testing.expectEqual(expected.len, actual.count());\n ^\n/opt/zig/lib/std/testing.zig:1154:9: in checkAllAllocationFailures__func_ (std.zig)\n try @call(.auto, test_fn, .{failing_allocator_inst.allocator()} ++ extra_args);\n ^\ntest_example_output_truncated.zig:57:5: in test.detects anagrams case-insensitively (test_example_output_truncated.zig)\n try std.testing.checkAllAllocationFailures(\n ^", "output": "cashregister\nCarthorse\nradishes\nexpected 1, found 0" }, { @@ -39,7 +39,7 @@ "name": "detects many anagrams of 26-letter words", "test_code": "const expected = [_][]const u8{\n \"ZYXWVUTSRQPONMLKJIHGFEDCBA\",\n \"MNOPQRSTUVWXYZABCDEFGHIJKL\",\n \"BADCFEHGJILKNMPORQTSVUXWZY\",\n \"QWERTYUIOPASDFGHJKLZXCVBNM\",\n \"GHIJKLMNOPQRSTUVWXYZABCDEF\",\n \"STUVWXYZABCDEFGHIJKLMNOPQR\",\n \"DCBAEFGHIJKLMNOPQRSTUVWXYZ\",\n \"AZBYCXDWEVFUGTHSIRJQKPLOMN\",\n \"ZAYXBWCVDUESFTGRHQIPJOKLNM\",\n \"NMLKJIHGFEDCBAZYXWVUTSRQPO\",\n \"BDFHJLNPRTVXZACEGIKMOQSUWY\",\n \"YWUSQOMKIGECAXZVTRPNLJHFDB\",\n \"JKLMNOPQRSTUVWXYZABCDEFGHI\",\n \"PONMLKJIHGFEDCBAZYXWVUTSRQ\",\n \"LKJIHGFEDCBAZYXWVUTSRQPONM\",\n \"CDEFGHIJKLMNOPQRSTUVWXYZAB\",\n \"EFGHIJKLMNOPQRSTUVWXYZABCD\",\n \"IJKLMNOPQRSTUVWXYZABCDEFGH\",\n \"OPQRSTUVWXYZABCDEFGHIJKLMN\",\n \"UVWXYZABCDEFGHIJKLMNOPQRST\",\n};\nconst word = \"ABCDEFGHIJKLMNOPQRSTUVWXYZ\";\ntry std.testing.checkAllAllocationFailures(\n std.testing.allocator,\n testAnagrams,\n .{ &expected, word, &expected },\n);", "status": "fail", - "message": "FAIL (TestExpectedEqual)\n/opt/zig/lib/std/testing.zig:118:17: in expectEqualInner__anon_ (std.zig)\n return error.TestExpectedEqual;\n ^\n/opt/zig/lib/std/testing.zig:83:5: in expectEqual (test_example_output_truncated.zig)\n return expectEqualInner(T, expected, actual);\n ^\ntest_example_output_truncated.zig:14:5: in testAnagrams (test_example_output_truncated.zig)\n try testing.expectEqual(expected.len, actual.count());\n ^\n/opt/zig/lib/std/testing.zig:1124:9: in checkAllAllocationFailures__anon_ (std.zig)\n try @call(.auto, test_fn, .{failing_allocator_inst.allocator()} ++ extra_args);\n ^\ntest_example_output_truncated.zig:99:5: in test.detects many anagrams of 26-letter words (test_example_output_truncated.zig)\n try std.testing.checkAllAllocationFailures(\n ^", + "message": "FAIL (TestExpectedEqual)\n/opt/zig/lib/std/testing.zig:93:17: in expectEqualInner__func_ (std.zig)\n return error.TestExpectedEqual;\n ^\n/opt/zig/lib/std/testing.zig:57:5: in expectEqual (test_example_output_truncated.zig)\n return expectEqualInner(T, expected, actual);\n ^\ntest_example_output_truncated.zig:14:5: in testAnagrams (test_example_output_truncated.zig)\n try testing.expectEqual(expected.len, actual.count());\n ^\n/opt/zig/lib/std/testing.zig:1154:9: in checkAllAllocationFailures__func_ (std.zig)\n try @call(.auto, test_fn, .{failing_allocator_inst.allocator()} ++ extra_args);\n ^\ntest_example_output_truncated.zig:99:5: in test.detects many anagrams of 26-letter words (test_example_output_truncated.zig)\n try std.testing.checkAllAllocationFailures(\n ^", "output": "ZYXWVUTSRQPONMLKJIHGFEDCBA\nMNOPQRSTUVWXYZABCDEFGHIJKL\nBADCFEHGJILKNMPORQTSVUXWZY\nQWERTYUIOPASDFGHJKLZXCVBNM\nGHIJKLMNOPQRSTUVWXYZABCDEF\nSTUVWXYZABCDEFGHIJKLMNOPQR\nDCBAEFGHIJKLMNOPQRSTUVWXYZ\nAZBYCXDWEVFUGTHSIRJQKPLOMN\nZAYXBWCVDUESFTGRHQIPJOKLNM\nNMLKJIHGFEDCBAZYXWVUTSRQPO\nBDFHJLNPRTVXZACEGIKMOQSUWY\nYWUSQOMKIGECAXZVTRPNLJHFDB\nJKLMNOPQRSTUVWXYZABCDEFGHI\nPONMLKJIHGFEDCBAZYXWVUTSRQ\nLKJIHGFEDCBAZYXWVUTSRQPONM\nCDEFGHIJKLMNOPQRSTUVWXYZAB\nEFGHIJKLMNOPQRSTUVWXYZABCD\nIJKLMNOPQRSTUVWXYZABCD [output truncated]" } ] diff --git a/tests/example-partial-fail/expected_results.json b/tests/example-partial-fail/expected_results.json index c61abec..4e6f4d8 100644 --- a/tests/example-partial-fail/expected_results.json +++ b/tests/example-partial-fail/expected_results.json @@ -26,13 +26,13 @@ "name": "year divisible by 100, not divisible by 400 in common year", "test_code": "try testing.expect(!leap.leap(2100));", "status": "fail", - "message": "/opt/zig/lib/std/testing.zig:615:14: in expect (std.zig)\n if (!ok) return error.TestUnexpectedResult;\n ^\ntest_example_partial_fail.zig:23:5: in test.year divisible by 100, not divisible by 400 in common year (test_example_partial_fail.zig)\n try testing.expect(!leap.leap(2100));\n ^" + "message": "/opt/zig/lib/std/testing.zig:584:14: in expect (std.zig)\n if (!ok) return error.TestUnexpectedResult;\n ^\ntest_example_partial_fail.zig:23:5: in test.year divisible by 100, not divisible by 400 in common year (test_example_partial_fail.zig)\n try testing.expect(!leap.leap(2100));\n ^" }, { "name": "year divisible by 100 but not by 3 is still not a leap year", "test_code": "try testing.expect(!leap.leap(1900));", "status": "fail", - "message": "/opt/zig/lib/std/testing.zig:615:14: in expect (std.zig)\n if (!ok) return error.TestUnexpectedResult;\n ^\ntest_example_partial_fail.zig:27:5: in test.year divisible by 100 but not by 3 is still not a leap year (test_example_partial_fail.zig)\n try testing.expect(!leap.leap(1900));\n ^" + "message": "/opt/zig/lib/std/testing.zig:584:14: in expect (std.zig)\n if (!ok) return error.TestUnexpectedResult;\n ^\ntest_example_partial_fail.zig:27:5: in test.year divisible by 100 but not by 3 is still not a leap year (test_example_partial_fail.zig)\n try testing.expect(!leap.leap(1900));\n ^" }, { "name": "year divisible by 400 is leap year", @@ -48,7 +48,7 @@ "name": "year divisible by 200, not divisible by 400 in common year", "test_code": "try testing.expect(!leap.leap(1800));", "status": "fail", - "message": "/opt/zig/lib/std/testing.zig:615:14: in expect (std.zig)\n if (!ok) return error.TestUnexpectedResult;\n ^\ntest_example_partial_fail.zig:39:5: in test.year divisible by 200, not divisible by 400 in common year (test_example_partial_fail.zig)\n try testing.expect(!leap.leap(1800));\n ^" + "message": "/opt/zig/lib/std/testing.zig:584:14: in expect (std.zig)\n if (!ok) return error.TestUnexpectedResult;\n ^\ntest_example_partial_fail.zig:39:5: in test.year divisible by 200, not divisible by 400 in common year (test_example_partial_fail.zig)\n try testing.expect(!leap.leap(1800));\n ^" } ] } diff --git a/tests/example-string-mismatch/expected_results.json b/tests/example-string-mismatch/expected_results.json index e61897e..db696dd 100644 --- a/tests/example-string-mismatch/expected_results.json +++ b/tests/example-string-mismatch/expected_results.json @@ -11,7 +11,7 @@ "name": "greeting is exactly Hello, World!", "test_code": "try testing.expectEqualStrings(\"Hello, World!\", mod.greeting());", "status": "fail", - "message": "FAIL (TestExpectedEqual)\n/opt/zig/lib/std/testing.zig:682:9: in expectEqualStrings (std.zig)\n return error.TestExpectedEqual;\n ^\ntest_example_string_mismatch.zig:11:5: in test.greeting is exactly Hello, World! (test_example_string_mismatch.zig)\n try testing.expectEqualStrings(\"Hello, World!\", mod.greeting());\n ^", + "message": "FAIL (TestExpectedEqual)\n/opt/zig/lib/std/testing.zig:696:9: in expectEqualStrings (std.zig)\n return error.TestExpectedEqual;\n ^\ntest_example_string_mismatch.zig:11:5: in test.greeting is exactly Hello, World! (test_example_string_mismatch.zig)\n try testing.expectEqualStrings(\"Hello, World!\", mod.greeting());\n ^", "output": "====== expected this output: =========\nHello, World!␃\n\n======== instead found this: =========\nGoodbye, Mars!␃\n\n======================================\nFirst difference occurs on line 1:\nexpected:\nHello, World!\n^ ('\\x48')\nfound:\nGoodbye, Mars!\n^ ('\\x47')" } ] diff --git a/tests/example-user-output/expected_results.json b/tests/example-user-output/expected_results.json index ca6df5e..eba45f6 100644 --- a/tests/example-user-output/expected_results.json +++ b/tests/example-user-output/expected_results.json @@ -6,7 +6,7 @@ "name": "greet returns a five-letter greeting", "test_code": "const result = try mod.greet();\ntry testing.expect(result.len == 5);", "status": "fail", - "message": "FAIL (TestUnexpectedResult)\n/opt/zig/lib/std/testing.zig:615:14: in expect (std.zig)\n if (!ok) return error.TestUnexpectedResult;\n ^\ntest_example_user_output.zig:8:5: in test.greet returns a five-letter greeting (test_example_user_output.zig)\n try testing.expect(result.len == 5);\n ^", + "message": "FAIL (TestUnexpectedResult)\n/opt/zig/lib/std/testing.zig:584:14: in expect (std.zig)\n if (!ok) return error.TestUnexpectedResult;\n ^\ntest_example_user_output.zig:8:5: in test.greet returns a five-letter greeting (test_example_user_output.zig)\n try testing.expect(result.len == 5);\n ^", "output": "debug: computed bad greeting" } ]