ocarina/tests/Sconscript

53 lines
1.1 KiB
Python

#!/usr/bin/python
import os, subprocess
Import("env", "CONFIG")
GOOD = "%s.good"
def run_test(target, source, env):
res = str(target[0])
out = open(res, 'w')
ret = subprocess.call("%s" % source[0], stdout = out)
out.close()
if (len(source) == 2) and (ret == 0):
good = str(source[1])
if (subprocess.call("diff -u %s %s" % (good, res), shell = True) != 0):
print
else:
for line in open( str(target[0]) ):
print line.rstrip()
print
def Test(group, src):
name, extension = src.rsplit(".", 1)
CONFIG.reconfigure()
lib = SConscript("../../lib/Sconscript")
prog = env.Program("%s.test" % name, [ src ] + lib)
src_files = [ "%s.test" % name ]
if os.path.exists(GOOD % name):
src_files += [ GOOD % name ]
test = Command("%s.run" % name, src_files, run_test)
Depends(test, prog)
AlwaysBuild(test)
Alias("tests", [ prog, test ])
Alias("tests/%s" % group, [ prog, test ])
Alias("tests/%s/%s" % (group, name), [ prog, test ])
Export("Test")
# Read SConscript files
scripts = [ "basic", "file" ]
for s in scripts:
CONFIG.reset()
CONFIG.TEST = True
SConscript("%s/Sconscript" % s)
Default("tests")