Add a basic test framework, borrowed from the framework used by git.git. A shell script library (tests/test-lib.sh) helps generate the fixtures, and simplifies the process of writing test scripts. Tests can be run as a suite (via 'make test') or individually (sh tests/t0000-config.sh). Results are aggregated upon completion. Includes a detailed README. A basic test of config file processing is part of this commit. Signed-off-by: Emil Sit <sit@emilsit.net>
52 lines
1.2 KiB
Makefile
52 lines
1.2 KiB
Makefile
#
|
|
# Makefile for todo.txt
|
|
#
|
|
|
|
# Dynamically detect/generate version file as necessary
|
|
# This file will define a variable called VERSION.
|
|
.PHONY: .FORCE-VERSION-FILE
|
|
VERSION-FILE: .FORCE-VERSION-FILE
|
|
@./GEN-VERSION-FILE
|
|
-include VERSION-FILE
|
|
|
|
# Maybe this will include the version in it.
|
|
todo.sh: VERSION-FILE
|
|
|
|
# For packaging
|
|
DISTFILES := README todo.cfg
|
|
|
|
DISTNAME=todo.sh-$(VERSION)
|
|
dist: $(DISTFILES) todo.sh
|
|
mkdir -p $(DISTNAME)
|
|
cp -f $(DISTFILES) $(DISTNAME)/
|
|
sed -e 's/@DEV_VERSION@/'$(VERSION)'/' todo.sh > $(DISTNAME)/todo.sh
|
|
tar cf $(DISTNAME).tar $(DISTNAME)/
|
|
gzip -f -9 $(DISTNAME).tar
|
|
zip -9r $(DISTNAME).zip $(DISTNAME)/
|
|
rm -r $(DISTNAME)
|
|
|
|
.PHONY: clean
|
|
clean:
|
|
rm -f $(DISTNAME).tar.gz $(DISTNAME).zip
|
|
|
|
#
|
|
# Testing
|
|
#
|
|
TESTS = $(wildcard tests/t[0-9][0-9][0-9][0-9]-*.sh)
|
|
#TEST_OPTIONS=--verbose
|
|
|
|
test-pre-clean:
|
|
rm -rf tests/test-results "tests/trash directory"*
|
|
|
|
aggregate-results: $(TESTS)
|
|
|
|
$(TESTS): test-pre-clean
|
|
-cd tests && sh $(notdir $@) $(TEST_OPTIONS)
|
|
|
|
test: aggregate-results
|
|
tests/aggregate-results.sh tests/test-results/t*-*
|
|
rm -rf tests/test-results
|
|
|
|
# Force tests to get run every time
|
|
.PHONY: test test-pre-clean aggregate-results $(TESTS)
|