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 @@

Homepage

-

Your SuperMD content goes here.

+

Your SuperMD content goes here.

H1

Lorem Ipsum 1

H2

Lorem Ipsum 2

H3

Lorem Ipsum 3

\ No newline at end of file diff --git a/tests/simple/snapshot/sections/index.html b/tests/simple/snapshot/sections/index.html new file mode 100644 index 0000000..9200ef0 --- /dev/null +++ b/tests/simple/snapshot/sections/index.html @@ -0,0 +1,30 @@ + + + + + Simple Test Website + + +

Sections

+
+

-- TABLE OF CONTENTS --

+ +
+
+

-- SECTION BEGIN --

+

H1

Lorem Ipsum 1

+

-- SECTION END --

+ +

-- SECTION BEGIN --

+

H2

Lorem Ipsum 2

+

-- SECTION END --

+ +

-- SECTION BEGIN --

+

H3

Lorem Ipsum 3

+

-- SECTION END --

+
+ + \ No newline at end of file diff --git a/tests/simple/src/content/index.smd b/tests/simple/src/content/index.smd index 5cdfe33..dcf4a73 100644 --- a/tests/simple/src/content/index.smd +++ b/tests/simple/src/content/index.smd @@ -6,3 +6,14 @@ .draft = false, --- Your **SuperMD** content goes here. + + +# H1 +Lorem Ipsum 1 + +## H2 +Lorem Ipsum 2 + +#### H3 +Lorem Ipsum 3 + diff --git a/tests/simple/src/content/sections.smd b/tests/simple/src/content/sections.smd new file mode 100644 index 0000000..d097eac --- /dev/null +++ b/tests/simple/src/content/sections.smd @@ -0,0 +1,17 @@ +--- +.title = "Sections", +.date = @date("2020-07-06T00:00:00"), +.author = "Sample Author", +.layout = "sections.shtml", +.draft = false, +--- + +# [H1]($section.id('h1')) +Lorem Ipsum 1 + +## [H2]($section.id('h2')) +Lorem Ipsum 2 + +### [H3]($section.id('h3')) +Lorem Ipsum 3 + diff --git a/tests/simple/src/layouts/sections.shtml b/tests/simple/src/layouts/sections.shtml new file mode 100644 index 0000000..91aa734 --- /dev/null +++ b/tests/simple/src/layouts/sections.shtml @@ -0,0 +1,19 @@ + + + + + + + +

+
+

-- TABLE OF CONTENTS --

+ +
+
+

-- SECTION BEGIN --

+
+

-- SECTION END --

+
+ + \ No newline at end of file