1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113
|
#!/usr/bin/python
import os
import sys
import re
import glob
import string
# list of tests to run ...
# prefixes
# C = command line scripts
# G = graphics and internal GUI
standard_prefixes = ['C', 'G' ]
# set module path for generic python stuff
#ppath = ''
#if os.environ.has_key('PYTHONPATH'):
# ppath = os.environ['PYTHONPATH'] + ":"
#ppath = ppath + os.getcwd() + "/../modules"
#os.environ['PYTHONPATH'] = ppath
#print ppath
# uniform parameter handling
argv = sys.argv
if len(argv):
if re.search("\.py$",argv[0]):
argv = argv[1:]
# ---
cmd = os.getenv("PYMOL", "./pymol-test") + ' -k'
diff_cmd = "diff -b"
cmp = "cmp"
ref = "ref"
inp = "inp"
tmp = "tmp"
python_exe = "../ext/bin/python"
if not os.path.exists(python_exe):
python_exe = "/usr/bin/python"
if not os.path.exists(python_exe):
python_exe = "python"
if not os.path.exists(cmp):
os.mkdir(cmp)
if not os.path.exists(tmp):
os.mkdir(tmp)
if len(argv)>1:
tests = argv
else:
tests = standard_prefixes
for test in tests:
flist = glob.glob( inp+"/"+test+"*" )
cvs = inp+"/CVS"
if cvs in flist:
flist.remove(cvs)
flist.sort()
for ifil in flist:
# get options
f = open(ifil)
opt = string.strip(f.readline())
opt = re.sub("^\s*\#","",opt)
f.close()
tst = re.sub(r".*/","",ifil) # get exact test name without suffix
tst = re.sub(r"\..*","",tst)
print " run_tests: "+tst+"..."
syscmd = cmd+" "+opt+" "+ifil+" 2>&1 | "+python_exe+" trim.py > "+cmp+"/"+tst+".log 2>&1"
os.system(syscmd)
# check log file and any other output files
for ref_fil in ( glob.glob(ref+"/"+tst+".*")):
postfx = re.sub(r".*/","",ref_fil)
cmp_fil = cmp+"/"+postfx
if os.path.exists(cmp_fil):
if os.system(diff_cmd+" "+ref_fil+" "+cmp_fil+" >/dev/null"):
sys.stdout.flush()
df = os.popen(diff_cmd+" "+ref_fil+" "+cmp_fil)
diffs = df.readlines()
df.close()
print " run_tests: "+ \
postfx+" DIFFERS over about %d lines." % int(len(diffs)/2)
if os.path.isdir('diffs'):
f = open('diffs/' + postfx + '.diff', 'w')
f.writelines(diffs)
f.close()
else:
print " run_tests: "+postfx+" is missing."
# check for extraneous, unverifiable files
for cmp_fil in ( glob.glob(cmp+"/"+tst+".*")):
postfx = re.sub(r".*/","",cmp_fil)
ref_fil = ref+"/"+postfx
if not os.path.exists(ref_fil):
print " run_tests: no reference version for "+cmp+"/"+postfx+"."
# vi:sw=3:expandtab
|