feat: migrate to Zig 0.16#43
Merged
Merged
Conversation
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Owner
Author
|
@copilot review |
Zig 0.16 migration requires CI to run on 0.16.0 too. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Contributor
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
There was a problem hiding this comment.
Pull request overview
Migrates zspec internals, examples, and CI configuration toward Zig 0.16 compatibility while preserving the custom test runner, factory helpers, and JUnit output support.
Changes:
- Replaces removed/changed Zig std APIs with local implementations or Zig 0.16 equivalents.
- Updates runner timing, env access, raw output/JUnit file writing, and stack trace dumping.
- Adjusts factory struct generation, unmanaged containers, examples, tests, and CI Zig version.
Reviewed changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
tests/example_test.zig |
Updates allocator free slice coercion for Zig 0.16. |
src/zspec.zig |
Adds local recursive declaration referencing helper. |
src/runner.zig |
Migrates exit, output file handling, timer, priority dequeue, env reading, and stack trace dumping. |
src/junit.zig |
Migrates ArrayList/writer usage, timestamping, and JUnit file output. |
src/factory.zig |
Migrates runtime struct creation to @Struct. |
examples/fsm_integration_test.zig |
Updates unmanaged array list initialization. |
.github/workflows/coverage.yml |
Updates coverage workflow Zig version. |
.github/workflows/ci.yml |
Updates CI matrix Zig version. |
Comments suppressed due to low confidence (1)
src/runner.zig:635
- This now dumps every frame directly, so the
SmartStackTracepath no longer usesisFrameworkFrameto filter runner/expect/std frames even though the runner and the remaining tests still describe that as its behavior. That regresses the user-facing stack trace signal-to-noise; either preserve the filtering with the new 0.16 APIs or update/remove the dead filtering code and tests.
const index = std.mem.indexOf(u8, test_name, marker) orelse return false;
_ = std.fmt.parseInt(u32, test_name[index + marker.len ..], 10) catch return false;
return true;
}
fn isSetup(t: std.builtin.TestFn) bool {
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| } | ||
|
|
||
| // Clean up in reverse order | ||
| // Clean up in reverse order. Note: in Zig 0.16 we have to coerce the |
Comment on lines
+96
to
+105
| } | ||
|
|
||
| for (self.results.items) |result| { | ||
| total_time_ns += result.time_ns; | ||
| switch (result.status) { | ||
| .failed => failures += 1, | ||
| .skipped => skipped += 1, | ||
| .passed => {}, | ||
| } | ||
| fn writeAllToPath(path: []const u8, bytes: []const u8) !void { | ||
| const native_os = @import("builtin").os.tag; | ||
| switch (native_os) { | ||
| .windows => { | ||
| // Use the Win32 file API directly. `std.c.O` is `void` on | ||
| // Windows in 0.16, so we can't reuse the POSIX path here. | ||
| const w = std.os.windows; | ||
| const k32 = struct { |
Comment on lines
80
to
+90
|
|
||
| pub fn addResult(self: *JUnitWriter, result: TestResult) !void { | ||
| try self.results.append(self.allocator, result); | ||
| } | ||
|
|
||
| pub fn writeToFile(self: *JUnitWriter, path: []const u8) !void { | ||
| const file = try std.fs.cwd().createFile(path, .{}); | ||
| defer file.close(); | ||
| // Build the XML fully in memory, then dump via the libc file descriptor | ||
| // API. Doing the entire I/O dance via `std.Io` would require plumbing an | ||
| // `Io` instance through the test runner, which is overkill here. | ||
| var aw: std.Io.Writer.Allocating = .init(self.allocator); | ||
| defer aw.deinit(); |
Comment on lines
+513
to
519
| _ = slow.popMin(); | ||
| slow.push(self.allocator, TestInfo{ .ns = ns, .name = test_name }) catch @panic("failed to track test timing"); | ||
| return ns; | ||
| } | ||
|
|
||
| fn display(self: *SlowTracker, printer: Printer) !void { | ||
| var slow = self.slowest; |
Comment on lines
+117
to
+123
| lpBuffer: [*]const u8, | ||
| nNumberOfBytesToWrite: w.DWORD, | ||
| lpNumberOfBytesWritten: *w.DWORD, | ||
| lpOverlapped: ?*anyopaque, | ||
| ) callconv(.winapi) w.BOOL; | ||
| }; | ||
| const GENERIC_WRITE: w.DWORD = 0x40000000; |
- example_test: reverse iteration to match the comment. - junit.zig: corrected Windows-vs-POSIX implementation comment. - junit.zig: added writeToFile test coverage (success + error). - runner.zig: distinguish missing vs empty env vars on Windows via GetLastError. - junit.zig: reject paths containing interior NUL bytes. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Release version bump for the Zig 0.16 migration. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Migrates zspec from Zig 0.15 to 0.16.
@Type(.{ .@"struct" })→@Struct(...)(factory.zig)std.testing.refAllDeclsRecursive→ small local implementation (zspec.zig)std.time.Timer→clock_gettime-basedMonoTimer(runner.zig)std.process.getEnvVarOwned→std.c.getenv/ Win32 fallback (runner.zig)std.fs.File→std.Io.Filewith raw libcopen/write/closefor output pathsstd.PriorityDequeuemigrated to unmanaged API (.empty,push(alloc, ...),popMin)dumpStackTracenow takes*const std.debug.StackTracestd.posix.exit→std.process.exitSelfInfoAPIArrayListUnmanaged→.empty;std.Io.Writer.Allocatingfor writersstd.time.timestamp→clock_gettime(.REALTIME)(junit.zig)Status
zig build: ✅ PASSzig build test: ✅ PASS (51/51 lib unit tests + fixture + factory_union + factory_zon + examples — over 110 total)