Skip to content

Instantly share code, notes, and snippets.

@danthemango
Last active February 2, 2018 04:06
Show Gist options
  • Save danthemango/242ea3872fb9dbbd832420c6c579d066 to your computer and use it in GitHub Desktop.
Save danthemango/242ea3872fb9dbbd832420c6c579d066 to your computer and use it in GitHub Desktop.
Testcasing Makefile
###############################################
## Filename: Makefile
## Author: Daniel Guenther
## Date: 2018-01-31
## Purpose: To quickly create and run test cases for a small program
###############################################
program=gcl -f lab3.cl
testdir=Tests
# runs the newest test
runNewTest: ${testdir} ${progname}
${program} < ${testdir}/`ls -t ${testdir} | head -1`
# runs program with each test case found in testing directory
runTests: ${testdir} ${progname}
echo; for testfile in `ls ${testdir}/`; do ${program} < ${testdir}/$$testfile; echo; done
# quickly create a new one-line test case (prompts user for test contents, generates new filename)
newTest: ${testdir}
i=0;while [ -f ${testdir}/test$$i ]; do i=$$(($$i+1)); done; read input && echo $$input > ${testdir}/test$$i
${testdir}:
mkdir -p ${testdir}
@danthemango
Copy link
Author

danthemango commented Feb 1, 2018

If you want to make a new lisp testing file, just type in:

$ make newTest
((1 2 3 4) (2 3 4 5) (9 8 7 6)) 2

which will create a file which can be used as input to the lisp program (a list of lists then a number, which is what's needed for lab3). You can then immediately run this new test with make runNewTest.

By default it will create a file called Tests/test0 (or Tests/test1 or Tests/test2 or Tests/testN for a number N that hasn't already been taken) which may be used as an input file for lab3.cl (e.g. gcl -f lab3.cl < Tests/test0, or run all tests with make runTests)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment