|
I don't think it's a big pain in python. I imagine ruby wouldn't be terrible either: #!/usr/bin/env python
import sys, os, subprocess, glob
os.chdir(os.path.dirname(sys.argv[0]))
for test in glob.glob("*.in"):
test = os.path.splitext(test)[0]
infile = test + ".in"
outfile = test + ".out"
output = subprocess.check_output(["./whofrom", infile], stderr=subprocess.STDOUT)
expected = open(outfile, 'r').read()
if output != expected:
print("Failed test", test)
try:
devnull = open(os.devnull, 'w')
subprocess.check_call(["valgrind", "--error-exitcode=1", "--leak-check=full", "./whofrom", infile], stderr=devnull, stdout=devnull)
except subprocess.CalledProcessError:
print("Failed test", test)
subprocess.check_call(["valgrind", "-q", "--leak-check=full", "./whofrom", infile])
(since it's a quick script, I'm ignoring stuff like closing files - they'll get GCd on each iteration anyway)Apart from the header, the whole script is pretty much the same when comparing line-by-line. |
How do you find which module you need? Search on the web may be the best answer. In shell at least you have "man -k".
Once I know the module, how do I get its documentation? Here at least there is an answer: import glob; help(glob);
But how good is this documentation? If I do it I get:
Already python is telling me that the "man" documentation is going to be better :-).