From 8c32753594ce0d6852336206b86cbdd88a8878b1 Mon Sep 17 00:00:00 2001 From: Gabriel Schneider Date: Tue, 17 Nov 2026 13:06:17 -0300 Subject: test: a consumer package, run by the library's own test step cloud9's build is used from other build.zig files (pardes, sketchbook), and nothing in its own suite used it that way: a break in what a consumer writes was found by the consumer. test/consumer is a package of its own whose manifest names cloud9 by ../.. and whose build.zig takes both exported modules by name with no option, b.dependency("cloud9", .{}).module("cloud9") and .module("9proc"), for its own target and optimize. Its test is a client and a server, each a cloud9 session (Client, Server) on its own end of a Unix socket pair, through a version, an attach and a read; and a call into 9proc, which shares the consumer's cloud9 module. The library's test step runs it as a nested zig build test in test/consumer, as pardes's lib-test runs test/lib (the consumer depends back on cloud9, so it cannot be a dependency of it). It has its own .zig-cache there (39 MB after a run). build.zig.zon's paths already carry test/ and every directory build.zig imports, so a fetched copy builds as before: unchanged. zig build test: the library's 108 of 108 and test/consumer's 2 of 2 at load 3.6 (at load 14, 107: serve's "repeated connect/disconnect", which fails on the base under load too, from the same test binary); a warm zig build test, the nested one included, 42-50 ms. 9proc-test and 9proc-check-freestanding pass: 9proc's library test binary is the base's (one cache key), so the first change's copy of the module is the module it was. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_016Y9MNBECMWcJD5pdS4SR6T --- test/consumer/build.zig | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 test/consumer/build.zig (limited to 'test/consumer/build.zig') diff --git a/test/consumer/build.zig b/test/consumer/build.zig new file mode 100644 index 0000000..9fc2c77 --- /dev/null +++ b/test/consumer/build.zig @@ -0,0 +1,20 @@ +//! A package that depends on cloud9 as any other does: cloud9's `test` +//! step runs `zig build test` here, so its build API is used the way a +//! consumer uses it (modules by name, no option). +const std = @import("std"); + +pub fn build(b: *std.Build) void { + const target = b.standardTargetOptions(.{}); + const optimize = b.standardOptimizeOption(.{}); + const cloud9 = b.dependency("cloud9", .{}); + const tests = b.addTest(.{ .root_module = b.createModule(.{ + .root_source_file = b.path("main.zig"), + .target = target, + .optimize = optimize, + .imports = &.{ + .{ .name = "cloud9", .module = cloud9.module("cloud9") }, + .{ .name = "9proc", .module = cloud9.module("9proc") }, + }, + }) }); + b.step("test", "a client and a server on cloud9 talk over a socket pair").dependOn(&b.addRunArtifact(tests).step); +} -- cgit v1.3