#!/bin/bash set -e echo "building..." zig build -Doptimize=ReleaseFast BIN=./zig-out/bin/ypsilanti TMP=$(mktemp -d) trap "rm -rf $TMP" EXIT echo "test: no args shows usage" $BIN 2>&1 | grep -q "commands:" || { echo "FAIL: no args"; exit 1; } echo "test: invalid command shows usage" $BIN invalid 2>&1 | grep -q "commands:" || { echo "FAIL: invalid cmd"; exit 1; } echo "test: build missing args" $BIN build 2>&1 | grep -q "usage:" || { echo "FAIL: build no args"; exit 1; } echo "test: serve missing args" $BIN serve 2>&1 | grep -q "usage:" || { echo "FAIL: serve no args"; exit 1; } echo "test: build example site" $BIN build ./example $TMP/out [ -f "$TMP/out/index.html" ] || { echo "FAIL: no index.html"; exit 1; } [ -f "$TMP/out/about/index.html" ] || { echo "FAIL: no about/index.html"; exit 1; } [ -f "$TMP/out/404.html" ] || { echo "FAIL: no 404.html"; exit 1; } [ -f "$TMP/out/posts/index.html" ] || { echo "FAIL: no generated posts index"; exit 1; } [ -f "$TMP/out/tags/linux/index.html" ] || { echo "FAIL: no generated tag page"; exit 1; } [ -f "$TMP/out/categories/technology/index.html" ] || { echo "FAIL: no generated category page"; exit 1; } [ -f "$TMP/out/sitemap.xml" ] || { echo "FAIL: no sitemap"; exit 1; } [ -f "$TMP/out/feed.xml" ] || { echo "FAIL: no feed"; exit 1; } [ -f "$TMP/out/style.css" ] || { echo "FAIL: no static files"; exit 1; } echo "test: html contains content" grep -q "Example Site" $TMP/out/index.html || { echo "FAIL: missing content"; exit 1; } grep -q "