Many improvements to 2005/giljade presentation
The try.sh script lets one experience the entry without having to use vi(m) .. you know, in case they're afraid of getting stuck :-) (and it is easier too). The script leaves the file there (rather than piping to less(1)) so that one can view it in a text editor if they wish. The file test.sh runs the test suite mode but it filters out the running of 'make', instead only showing the lines matching '^Line'. When it's all done it checks if 180 versions (lines) were found (it writes to stdout and another file with tee(1)). If it does not find 180 it is an error and this is reported (with exit 1). If it does find 180 all is good. The make test rule was added and uses this script. Format and typo check README.md file.
This commit is contained in:
1 parent
ea2f4dbb30
commit
a9fbaf593f
5 files changed
+134
-42
No files matched your search
Executable
+34
@@ -0,0 +1,34 @@
|
||||
#!/usr/bin/env bash
|
||||
#
|
||||
# test.sh - demonstrate IOCCC winner 2005/giljade test suite feature
|
||||
#
|
||||
|
||||
# make sure CC is set so that when we do make CC="$CC" it isn't empty. Doing it
|
||||
# this way allows us to have the user specify a different compiler in an easy
|
||||
# way.
|
||||
if [[ -z "$CC" ]]; then
|
||||
CC="cc"
|
||||
fi
|
||||
|
||||
make CC="$CC" all >/dev/null || exit 1
|
||||
|
||||
GILJADE="giljade"
|
||||
EXIT_CODE=0
|
||||
|
||||
rm -f out out.count
|
||||
|
||||
./"$GILJADE" > out
|
||||
./"$GILJADE" out | tee out.count | grep '^Line'
|
||||
COUNT="$(grep -c '^Line' out.count)"
|
||||
|
||||
if [[ "$COUNT" != 180 ]]; then
|
||||
echo "FAIL: expected 180 versions, got $COUNT" 1>&2
|
||||
EXIT_CODE=1
|
||||
else
|
||||
echo "Found all 180 versions!" 1>&2
|
||||
fi
|
||||
|
||||
rm -f out out.count
|
||||
|
||||
exit "$EXIT_CODE"
|
||||
|
||||
Reference in new issue
Block a user