ssh git@grit.deadkey.org man

mailmanpat/jenny · 2026-09-06 09:36:46 +08002026-9-6 +8git clone …

FILES / test / smoke.sh

NameLast CommitTimestampSize
..
fixtures ad9c389 h test: replace the cloned-blog CI job with a committed fixture 26-08-24 11:38 -
lib 41cf051 h fix(index): restore the original break-marker placement and dimming 26-08-24 22:33 -
compare-golden.sh ad9c389 h test: replace the cloned-blog CI job with a committed fixture 26-08-24 11:38 1 KB
regressions.sh b70d686 h Take the parser's escape-by-default contract 26-09-05 10:21 123 KB
run.sh a346b6b h test: add bash test harness, fixtures and link checker 26-08-20 09:30 392 B
smoke.sh a346b6b h test: add bash test harness, fixtures and link checker 26-08-20 09:30 2 KB
units.sh b70d686 h Take the parser's escape-by-default contract 26-09-05 10:21 20 KB
#!/usr/bin/env bash
# Smoke test: init -> build -> assert overall structure.
source "$(dirname "${BASH_SOURCE[0]}")/lib/assert.bash"
TMPROOT=$(mktemp -d -t jenny-smoke.XXXXXX)
trap 'rm -rf "$TMPROOT"' EXIT
BLOG="$TMPROOT/blog"
make_blog "$BLOG" 3
run_jenny_split "$BLOG"
DIST="$BLOG/.dist"
suite "build"
it "exits successfully"
assert_success "$status" "$output"
it "writes nothing to stderr"
assert_eq "$stderr_output" ""
it "creates the index"
assert_file_exists "$DIST/index.html"
it "creates the feed"
assert_file_exists "$DIST/feed.xml"
it "renders one page per post"
assert_eq "$(find "$DIST/post" -name '*.html' | wc -l | tr -d ' ')" "10"
it "no rendered post has an empty body"
emptied=""
for f in "$DIST"/post/*.html; do
body=$(sed -n '/class="contents"/,/class="tags"/p' "$f" | sed '1d;$d' | tr -d '[:space:]')
[ -z "$body" ] && emptied="$emptied $(basename "$f")"
done
assert_eq "$emptied" ""
it "creates paginated pages"
assert_file_exists "$DIST/page/1.html"
it "creates the tag index"
assert_file_exists "$DIST/tag/alpha/index.html"
it "creates the tag feed"
assert_file_exists "$DIST/tag/alpha/feed.xml"
it "every link resolves from the document root"
broken=$(check_links "$DIST") && pass || fail "broken links:
$broken"
it "the main index holds POSTS_PER_PAGE posts"
assert_eq "$(index_post_count "$DIST/index.html")" "3"
it "the feed holds every post"
assert_eq "$(feed_item_count "$DIST/feed.xml")" "10"
suite "jenny init"
it "init creates a .blogrc and a sample post"
fresh="$TMPROOT/fresh"
mkdir -p "$fresh"
( cd "$fresh" && printf 'http://example.com\nMy Blog\n5\n.dist\nimages\n' | "$JENNY" init >/dev/null 2>&1 )
assert_file_exists "$fresh/.blogrc"
it "the sample post builds"
run_jenny "$fresh"
assert_success "$status" "$output"
it "init refuses to overwrite an existing .blogrc"
out=$(cd "$fresh" && printf '\n\n\n\n\n' | "$JENNY" init 2>&1); st=$?
assert_failure "$st" "$out"
suite "help and version"
it "-h works outside a blog directory"
out=$(cd "$TMPROOT" && "$JENNY" -h 2>&1); st=$?
assert_success "$st" "$out"
it "-h lists the options"
assert_contains "$out" "-d"
it "--version reports a version"
out=$(cd "$TMPROOT" && "$JENNY" --version 2>&1); st=$?
assert_success "$st" "$out"
it "a build outside a blog directory fails"
out=$(cd "$TMPROOT" && "$JENNY" 2>&1); st=$?
assert_failure "$st" "$out"
summary