|
#!/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 |