###### File: oceani-tests.mk
oceani_tests :=
+ ## test list
tests:: oceani_test_suite
oceani_test_suite: oceani coverage_oceani
./coverage_oceani --print --section "test: $$t" oceani-tests.mdc $${1+"$$@"} > /dev/null ; \
./coverage_oceani -tpbn --section "test: $$t" oceani-tests.mdc > /dev/null 2>&1; \
done
+
+ ## test code
+
@gcov -o coverage oceani.mdc > /dev/null 2> /dev/null
@mv *.gcov coverage ; [ -f .gcov ] && mv .gcov coverage
@ awk '/^ *[1-9]/ {ran+=1} /^ *###/ {skip+=1} \
coverage_oceani: oceani.c
$(CC) $(CFLAGS) --coverage -fprofile-dir=coverage -o coverage_oceani oceani.c $(LDLIBS)
- ## test list
-
## Values and variables
The first test stores values in variables and performs various
list[ 53 ]= 9040
list[ 54 ]= 9768
+## Test erroneous command line args
+
+To improve coverage, we want to test correct handling of strange command
+line arguments. These tests won't use code, so the exiting test types
+won't work. So we need to be able to explicitly give the command line,
+and the expected output, and have that tested and the coverage assessed.
+Rather than having to spell out the whole command name, just give "cmd",
+and discard that. Requiring but discarding the command make an empty
+command list possible.
+
+###### test code
+ @for t in $(oceani_special_tests); do \
+ echo -n "Test $$t ... ";\
+ i="$$IFS"; IFS=,; set $$t; IFS="$$i"; shift ;\
+ ./md2c oceani-tests.mdc "output: $$t" | grep -v '^#' > .tmp.want; \
+ ./oceani $${1+"$$@"} > .tmp.have 2>&1 ;\
+ if ! cmp -s .tmp.want .tmp.have; then \
+ echo "FAILED"; diff -u .tmp.want .tmp.have ; exit 1; fi ;\
+ echo "passed"; \
+ ./coverage_oceani $${1+"$$@"} > /dev/null 2>&1 ;\
+ done || true
+
+
+###### test list
+ oceani_special_tests += "cmd"
+ oceani_special_tests += "cmd,-zyx"
+ oceani_special_tests += "cmd,nofile"
+ oceani_special_tests += "cmd,/dev/null"
+ oceani_special_tests += "cmd,--section,toast:nothing,oceani-tests.mdc"
+
+###### output: cmd
+ oceani: no input file given
+
+###### output: cmd,-zyx
+ ./oceani: invalid option -- 'z'
+ Usage: oceani --trace --print --noexec --brackets--section=SectionName prog.ocn
+
+###### output: cmd,nofile
+ oceani: cannot open nofile
+
+###### output: cmd,/dev/null
+ oceani: could not find any code in /dev/null
+
+###### output: cmd,--section,toast:nothing,oceani-tests.mdc
+ oceani: cannot find section toast:nothing
+