From e21920846db8017c27d329419b4b0eed3ff3c443 Mon Sep 17 00:00:00 2001 From: Rohit Goswami Date: Mon, 16 Nov 2026 13:07:44 +0000 Subject: [PATCH] build: run the suite and differential steps in the build root Both steps run their script by a path relative to the working directory, tests/test_eb_keep_logs.sh and tests/differential.sh, and a Run step without a cwd runs where zig build was started. zig build finds build.zig in a parent directory, so started from src/ it built the binary and passed the unit tests, then bash exited 127 with "No such file or directory" for both scripts and the test step failed, in a plain checkout as in zig-common's CI layout. The scripts find everything else from their own path, so both steps now run in the build root wherever zig build was started. --- build.zig | 4 ++++ changelog.d/+suite-cwd.misc.md | 1 + 2 files changed, 5 insertions(+) create mode 100644 changelog.d/+suite-cwd.misc.md diff --git a/build.zig b/build.zig index 25e37ed..9679584 100644 --- a/build.zig +++ b/build.zig @@ -29,12 +29,16 @@ pub fn build(b: *std.Build) void { b.step("unit", "Run the unit tests").dependOn(&b.addRunArtifact(unit).step); // The shell suite of the old implementation, run against this binary. + // It and the differential run below run in the build root: their script + // paths are relative, and zig build may be started in a subdirectory. const suite = b.addSystemCommand(&.{ "bash", "-c", "TOOL_BIN=\"$0\" exec bash tests/test_eb_keep_logs.sh" }); suite.addArtifactArg(exe); + suite.setCwd(b.path(".")); suite.expectExitCode(0); // The same invocations through the shell implementation and this one. const diff = b.addSystemCommand(&.{ "bash", "-c", "TOOL_BIN=\"$0\" exec bash tests/differential.sh" }); diff.addArtifactArg(exe); + diff.setCwd(b.path(".")); diff.expectExitCode(0); const test_step = b.step("test", "Run the unit tests, the command-line suite and the differential run"); diff --git a/changelog.d/+suite-cwd.misc.md b/changelog.d/+suite-cwd.misc.md new file mode 100644 index 0000000..56811be --- /dev/null +++ b/changelog.d/+suite-cwd.misc.md @@ -0,0 +1 @@ +`zig build test` passes when started in a subdirectory such as `src/`: the command-line suite and the differential run start their scripts from the build root instead of from where `zig build` was started, where bash stopped with `tests/test_eb_keep_logs.sh: No such file or directory`.