Lindenii Project Forge
Set up test suite
VERSION=1.2.3 CFLAGS=-g -DVERSION='"$(VERSION)"' -Wall -Wextra -Werror -Wno-unused-parameter LDFLAGS=-static INCLUDE=-Iinclude PREFIX=/usr/local DESTDIR= _INSTDIR=$(DESTDIR)$(PREFIX) BINDIR=$(_INSTDIR)/bin MANDIR=$(_INSTDIR)/share/man OUTDIR=.build HOST_SCDOC=./scdoc .DEFAULT_GOAL=all OBJECTS=\ $(OUTDIR)/main.o \ $(OUTDIR)/string.o \ $(OUTDIR)/utf8_chsize.o \ $(OUTDIR)/utf8_decode.o \ $(OUTDIR)/utf8_encode.o \ $(OUTDIR)/utf8_fgetch.o \ $(OUTDIR)/utf8_fputch.o \ $(OUTDIR)/utf8_size.o \ $(OUTDIR)/util.o $(OUTDIR)/%.o: src/%.c @mkdir -p $(OUTDIR) $(CC) -std=c99 -pedantic -c -o $@ $(CFLAGS) $(INCLUDE) $< scdoc: $(OBJECTS) $(CC) $(LDFLAGS) -o $@ $^ scdoc.1: scdoc.1.scd $(HOST_SCDOC) $(HOST_SCDOC) < $< > $@ all: scdoc scdoc.1 clean: rm -rf $(OUTDIR) scdoc scdoc.1 install: all install -Dm755 scdoc $(BINDIR)/scdoc install -Dm644 scdoc.1 $(MANDIR)/man1/scdoc.1
.PHONY: all clean install
check: scdoc scdoc.1 @find test -executable -exec '{}' \; .PHONY: all clean install check
begin() { printf '%-40s' "$1" } scdoc() { ./scdoc "$@" 2>&1 } end() { if [ $? -ne "$1" ] then printf 'FAIL\n' else printf 'OK\n' fi }
#!/bin/sh . test/lib.sh begin "Expects a name" scdoc <<EOF >/dev/null (8) EOF end 1 begin "Expects a section" scdoc <<EOF >/dev/null test EOF end 1 begin "Expects name to alphanumeric" scdoc <<EOF >/dev/null ____(8) EOF end 1 begin "Expects section to be a number" scdoc <<EOF >/dev/null test(hello) EOF end 1 begin "Expects section to legit" scdoc <<EOF >/dev/null test(100) EOF end 1 begin "Accepts a valid preamble" scdoc <<EOF >/dev/null test(8) EOF end 0 begin "Writes the appropriate header" scdoc <<EOF | grep '^\.TH "test" "8" "'"$(date +'%F')"'"' >/dev/null test(8) EOF end 0