2013-07-05 09:40:11 -04:00
|
|
|
#!/usr/bin/python
|
2013-07-07 22:27:26 -04:00
|
|
|
import os, subprocess
|
|
|
|
Import("env", "CONFIG")
|
2013-07-07 21:17:27 -04:00
|
|
|
|
|
|
|
|
2013-07-07 22:27:26 -04:00
|
|
|
GOOD = "%s.good"
|
2013-07-05 09:40:11 -04:00
|
|
|
|
2013-07-07 22:27:26 -04:00
|
|
|
def run_test(target, source, env):
|
|
|
|
res = str(target[0])
|
|
|
|
out = open(res, 'w')
|
|
|
|
ret = subprocess.call("%s" % source[0], stdout = out)
|
|
|
|
out.close()
|
2013-07-07 21:17:27 -04:00
|
|
|
|
2013-07-07 22:27:26 -04:00
|
|
|
if (len(source) == 2) and (ret == 0):
|
|
|
|
good = str(source[1])
|
2013-07-28 22:36:08 -04:00
|
|
|
if (subprocess.call("diff -u %s %s" % (good, res), shell = True) != 0):
|
2013-07-07 22:27:26 -04:00
|
|
|
print
|
|
|
|
else:
|
|
|
|
for line in open( str(target[0]) ):
|
2013-07-28 22:36:08 -04:00
|
|
|
print line.rstrip()
|
2013-07-07 22:27:26 -04:00
|
|
|
print
|
2013-07-05 21:40:10 -04:00
|
|
|
|
2013-07-07 22:27:26 -04:00
|
|
|
def Test(group, src):
|
2013-07-07 21:17:27 -04:00
|
|
|
name, extension = src.rsplit(".", 1)
|
2013-07-07 22:27:26 -04:00
|
|
|
CONFIG.reconfigure()
|
2013-07-07 21:17:27 -04:00
|
|
|
|
2013-07-07 22:27:26 -04:00
|
|
|
lib = SConscript("../../lib/Sconscript")
|
2013-07-07 21:17:27 -04:00
|
|
|
prog = env.Program("%s.test" % name, [ src ] + lib)
|
2013-07-07 22:27:26 -04:00
|
|
|
|
|
|
|
src_files = [ "%s.test" % name ]
|
|
|
|
if os.path.exists(GOOD % name):
|
|
|
|
src_files += [ GOOD % name ]
|
|
|
|
test = Command("%s.run" % name, src_files, run_test)
|
2013-07-07 21:17:27 -04:00
|
|
|
|
2013-07-05 21:40:10 -04:00
|
|
|
Depends(test, prog)
|
2013-07-07 21:17:27 -04:00
|
|
|
AlwaysBuild(test)
|
2013-07-05 21:40:10 -04:00
|
|
|
|
2013-07-07 21:17:27 -04:00
|
|
|
Alias("tests", [ prog, test ])
|
|
|
|
Alias("tests/%s" % group, [ prog, test ])
|
|
|
|
Alias("tests/%s/%s" % (group, name), [ prog, test ])
|
2013-07-05 09:40:11 -04:00
|
|
|
|
2013-07-05 11:40:34 -04:00
|
|
|
Export("Test")
|
2013-07-05 09:40:11 -04:00
|
|
|
|
|
|
|
|
|
|
|
# Read SConscript files
|
2013-08-10 23:38:57 -04:00
|
|
|
scripts = [ "basic", "file", "database" ]
|
2013-07-07 22:27:26 -04:00
|
|
|
for s in scripts:
|
|
|
|
CONFIG.reset()
|
2013-07-27 11:40:16 -04:00
|
|
|
CONFIG.TEST = True
|
2013-07-07 22:27:26 -04:00
|
|
|
SConscript("%s/Sconscript" % s)
|
2013-07-07 21:17:27 -04:00
|
|
|
|
|
|
|
Default("tests")
|