diff --git a/build/tools.zig b/build/tools.zig index 0d56d64..490964d 100644 --- a/build/tools.zig +++ b/build/tools.zig @@ -131,6 +131,7 @@ fn setupSnapshotTesting(b: *std.Build, scopes: []const []const u8) !void { const diff = b.addSystemCommand(&.{ "git", "diff", + "--cached", "--exit-code", }); @@ -138,6 +139,13 @@ fn setupSnapshotTesting(b: *std.Build, scopes: []const []const u8) !void { test_step.dependOn(&diff.step); + // We need to stage all of tests/ in order for untracked files to show up in + // the diff. It's also not a bad automatism since it avoids the problem of + // forgetting to stage new snapshot files. + const git_add = b.addSystemCommand(&.{ "git", "add", "tests/" }); + + diff.step.dependOn(&git_add.step); + const tests_dir = try b.build_root.handle.openDir("tests/", .{ .iterate = true, }); @@ -167,7 +175,7 @@ fn setupSnapshotTesting(b: *std.Build, scopes: []const []const u8) !void { "src", }))); - diff.step.dependOn(&build_site.step); + git_add.step.dependOn(&build_site.step); } } diff --git a/tests/simple/snapshot/index.html b/tests/simple/snapshot/index.html index 61c185d..6f1f4ec 100644 --- a/tests/simple/snapshot/index.html +++ b/tests/simple/snapshot/index.html @@ -6,6 +6,6 @@
Your SuperMD content goes here.
Your SuperMD content goes here.
Lorem Ipsum 1
Lorem Ipsum 2
Lorem Ipsum 3