summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris Boesch <chrboesch@noreply.codeberg.org>2026-01-07 19:57:43 +0100
committerChris Boesch <chrboesch@noreply.codeberg.org>2026-01-07 19:57:43 +0100
commit639a763044415e15ee78d0a5f878ecdf24fc19b6 (patch)
tree764bd037bb94ac315e8b2efbba12cb54ce63e30f
parent878bebb1d1911682f1519cfc7ce4445ec31da6bc (diff)
adjust temp files
-rw-r--r--README.md4
-rw-r--r--build.zig2
-rw-r--r--test/tests.zig27
3 files changed, 16 insertions, 17 deletions
diff --git a/README.md b/README.md
index 2b846f0..5e77bd2 100644
--- a/README.md
+++ b/README.md
@@ -38,7 +38,8 @@ is incredibly friendly and helpful!
Install a [development build](https://ziglang.org/download/) of
the Zig compiler. (See the "master" section of the downloads
-page.)
+page.) Sometimes the latest build is not available there;
+in that case, you can download it directly from the [build directory](https://ziglang.org/download/index.json).
Verify the installation and build number of `zig` like so:
@@ -86,6 +87,7 @@ that if you update one, you may need to also update the other.
### Version Changes
+* 2026-01-07 zig 0.16.0-dev.2040 - adjust temp files, see [#30683](https://codeberg.org/ziglang/zig/pulls/30683)
* 2026-01-06 zig 0.16.0-dev.1976 - move process API to `std.Io` and changes to main/environ/argv, see [#30644](https://codeberg.org/ziglang/zig/pulls/30644)
* *2025-12-28* zig 0.16.0-dev.1859 - file system I/O integrated with the std.Io interface, see [#30232](https://codeberg.org/ziglang/zig/pulls/30232)
* *2025-11-01* zig 0.16.0-dev.1204 - more changes due to new I/O API, see [#25592](https://github.com/ziglang/zig/pull/25592)
diff --git a/build.zig b/build.zig
index 15bcf67..c2958e3 100644
--- a/build.zig
+++ b/build.zig
@@ -15,7 +15,7 @@ const print = std.debug.print;
// 1) Getting Started
// 2) Version Changes
comptime {
- const required_zig = "0.16.0-dev.1976";
+ const required_zig = "0.16.0-dev.2040";
const current_zig = builtin.zig_version;
const min_zig = std.SemanticVersion.parse(required_zig) catch unreachable;
if (current_zig.order(min_zig) == .lt) {
diff --git a/test/tests.zig b/test/tests.zig
index 5e84ef7..94cf6aa 100644
--- a/test/tests.zig
+++ b/test/tests.zig
@@ -21,9 +21,10 @@ pub fn addCliTests(b: *std.Build, exercises: []const Exercise) *Step {
// Test that `zig build -Dhealed -Dn=n` selects the nth exercise.
const case_step = createCase(b, "case-1");
- const tmp_path = makeTempPath(b) catch |err| {
+ const tmp_path = createTempPath(b) catch |err| {
return fail(step, "unable to make tmp path: {s}\n", .{@errorName(err)});
};
+ defer deleteTmpPath(b, tmp_path);
const heal_step = HealStep.create(b, exercises, tmp_path);
@@ -47,20 +48,16 @@ pub fn addCliTests(b: *std.Build, exercises: []const Exercise) *Step {
case_step.dependOn(&verify.step);
}
-
- const cleanup = b.addRemoveDirTree(.{ .src_path = .{ .owner = b, .sub_path = tmp_path } });
- cleanup.step.dependOn(case_step);
-
- step.dependOn(&cleanup.step);
}
{
// Test that `zig build -Dhealed` processes all the exercises in order.
const case_step = createCase(b, "case-2");
- const tmp_path = makeTempPath(b) catch |err| {
+ const tmp_path = createTempPath(b) catch |err| {
return fail(step, "unable to make tmp path: {s}\n", .{@errorName(err)});
};
+ defer deleteTmpPath(b, tmp_path);
const heal_step = HealStep.create(b, exercises, tmp_path);
heal_step.step.dependOn(case_step);
@@ -79,11 +76,6 @@ pub fn addCliTests(b: *std.Build, exercises: []const Exercise) *Step {
const stderr = cmd.captureStdErr(.{});
const verify = CheckStep.create(b, exercises, stderr);
verify.step.dependOn(&cmd.step);
-
- const cleanup = b.addRemoveDirTree(.{ .src_path = .{ .owner = b, .sub_path = tmp_path } });
- cleanup.step.dependOn(&verify.step);
-
- step.dependOn(&cleanup.step);
}
{
@@ -400,9 +392,7 @@ fn heal(allocator: Allocator, exercises: []const Exercise, work_path: []const u8
}
}
-/// This function is the same as the one in std.Build.makeTempPath, with the
-/// difference that returns an error when the temp path cannot be created.
-pub fn makeTempPath(b: *Build) ![]const u8 {
+fn createTempPath(b: *Build) ![]const u8 {
const io = b.graph.io;
const rand_int = std.crypto.random.int(u64);
const tmp_dir_sub_path = "tmp" ++ std.Io.Dir.path.sep_str ++ std.fmt.hex(rand_int);
@@ -410,3 +400,10 @@ pub fn makeTempPath(b: *Build) ![]const u8 {
try b.cache_root.handle.createDirPath(io, tmp_dir_sub_path);
return result_path;
}
+
+fn deleteTmpPath(b: *Build, path: []const u8) void {
+ const io = b.graph.io;
+ std.Io.Dir.cwd().deleteTree(io, path) catch |err| {
+ std.log.warn("failed to delete {s}: {t}", .{ path, err });
+ };
+}