summaryrefslogtreecommitdiff
path: root/build.zig
diff options
context:
space:
mode:
authorGabriel Schneider <[email protected]>2026-11-16 23:50:55 -0300
committerGabriel Schneider <[email protected]>2026-11-17 12:15:01 -0300
commited6581dbf287d8a2fb1c439a88ce7380ee754f75 (patch)
treec87566725d2c5b7ab89c642a088f9db9e8f19a98 /build.zig
parent3cf0b76e12f06a68cc0d84b2877f7f0261fe8d19 (diff)
downloadsketchbook-ed6581dbf287d8a2fb1c439a88ce7380ee754f75.tar.gz
sketchbook-ed6581dbf287d8a2fb1c439a88ce7380ee754f75.zip
Bound a scripted run's memory sessions; check a script records the same twice
A scripted run from fresh state records in memory, and a very long one grew without end. It stops at 256 MiB (ten hours or more of play at 60 Hz; a write the memory database cannot make, out of memory included, is the same): once, a warning, and no more frames, while what it holds still reads (marks, clips, past sessions). test-same plays test/past.script twice into two databases and compares them value by value with test/same_sessions.zig, but for a session's started and ended (the wall clock): every frame, keyframe, stretch and mark follows from the script alone. A third run from fresh state leaves its state file and no database. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_016Y9MNBECMWcJD5pdS4SR6T
Diffstat (limited to 'build.zig')
-rw-r--r--build.zig30
1 files changed, 30 insertions, 0 deletions
diff --git a/build.zig b/build.zig
index d8da703..9b99597 100644
--- a/build.zig
+++ b/build.zig
@@ -409,6 +409,36 @@ pub fn build(b: *Build) void {
test_step.dependOn(&moved.step);
b.step("test-import", "Export a session from one database, import it into another, replay it").dependOn(&moved.step);
+ // A script run twice records the same database but for the wall clock's
+ // times: the log and the keyframes follow from the script alone. From
+ // fresh state it records in memory: no database at all.
+ const same_sessions = b.addExecutable(.{ .name = "same_sessions", .root_module = b.createModule(.{
+ .root_source_file = b.path("test/same_sessions.zig"),
+ .target = target,
+ .optimize = optimize,
+ .imports = &.{.{ .name = "Sessions", .module = b.createModule(.{ .root_source_file = b.path("src/host/Sessions.zig"), .imports = &.{ .{ .name = "abi", .module = abi }, .{ .name = "xitdb", .module = xitdb } } }) }},
+ }) });
+ const twice = b.addSystemCommand(&.{ "sh", "-c",
+ \\set -e
+ \\mkdir -p "$3"; d=$(realpath "$3"); rm -f "$d"/*
+ \\"$0" --headless --script "$1" --state "$d/a.state" "$4"
+ \\"$0" --headless --script "$1" --state "$d/b.state" "$4"
+ \\"$2" "$d/a.xitdb" "$d/b.xitdb"
+ \\"$0" --headless --fresh --script "$1" --state "$d/c.state" "$4"
+ \\test -e "$d/c.state"; test ! -e "$d/c.xitdb"
+ \\rm -f "$d"/*
+ });
+ twice.setName("a script recorded twice");
+ twice.addArtifactArg(host_exe);
+ twice.addFileArg(b.path("test/past.script"));
+ twice.addArtifactArg(same_sessions);
+ _ = twice.addOutputDirectoryArg("twice");
+ twice.addArtifactArg(recorded);
+ twice.has_side_effects = true;
+ twice.expectExitCode(0);
+ test_step.dependOn(&twice.step);
+ b.step("test-same", "A script run twice records the same database but for times").dependOn(&twice.step);
+
// Where files go. Without --state: the XDG data directory, state and
// sessions. In .sketchbook/ (`zig build run`'s): a .gitignore, and an
// older build's state moved in, once, never over a file there.