tests: Rewrite how core tests are run
My old testing system was rather convoluted. This patch makes the Sconscript file easier to follow. Signed-off-by: Anna Schumaker <Anna@OcarinaProject.net>
This commit is contained in:
parent
d944ed4e95
commit
7faa895b22
|
@ -1,42 +1,68 @@
|
|||
#!/usr/bin/python
|
||||
|
||||
Import("OTest", "TestList")
|
||||
import sys, os
|
||||
Import("test_env")
|
||||
|
||||
all = False
|
||||
for arg in sys.argv[1:]:
|
||||
arg = os.path.normpath(arg)
|
||||
name = os.path.basename(arg)
|
||||
if (arg.find("tests") == 0) and (name == "tests"):
|
||||
all = True
|
||||
if (arg.find("tests/core") == 0) and (name == "core"):
|
||||
all = True
|
||||
|
||||
res = []
|
||||
objs = []
|
||||
|
||||
def get_core_obj(name):
|
||||
global objs
|
||||
if not os.path.exists("../../core/%s.cpp" % name):
|
||||
return []
|
||||
objs += test_env.Object("%s.cpp-core" % name, "../../core/%s.cpp" % name)
|
||||
return objs
|
||||
|
||||
def add_test(test):
|
||||
global all
|
||||
global res
|
||||
|
||||
if (all == True) and (len(res) > 0):
|
||||
Depends(test, res[-1])
|
||||
res += [ test ]
|
||||
|
||||
def test(name):
|
||||
extra = get_core_obj(name)
|
||||
exe = test_env.Program(name, [ "%s.cpp" % name ] + extra)
|
||||
test = Command("%s.fake" % name, [], "tests/core/%s" % name);
|
||||
Alias("tests/core/%s" % name, test)
|
||||
Depends(test, exe)
|
||||
add_test(test)
|
||||
|
||||
|
||||
class CoreTest(OTest):
|
||||
Objs = []
|
||||
|
||||
def __init__(self, src, pkg = None, extra = None):
|
||||
OTest.__init__(self, src, pkg)
|
||||
if extra != None:
|
||||
self.add_object(extra)
|
||||
###
|
||||
#
|
||||
# Test configuration starts here
|
||||
#
|
||||
|
||||
def add_object(self, obj):
|
||||
path = "../../core/%s" % obj
|
||||
CoreTest.Objs += [ OTest.Env.Object("%s-core" % obj, path) ]
|
||||
test( "version" )
|
||||
test( "file" )
|
||||
test( "database" )
|
||||
test( "index" )
|
||||
test( "filter" )
|
||||
test( "idle" )
|
||||
|
||||
def get_program(self):
|
||||
self.add_object(self.Src)
|
||||
return OTest.Env.Program(self.Name, [ self.Src ] + CoreTest.Objs)
|
||||
test_env.UsePackage("taglib")
|
||||
test( "tags" )
|
||||
test( "random" )
|
||||
|
||||
get_core_obj("callback")
|
||||
test( "queue" )
|
||||
test( "library" )
|
||||
test( "playlist" )
|
||||
test( "deck" )
|
||||
test( "driver" )
|
||||
test( "audio" )
|
||||
|
||||
res = TestList("core", [
|
||||
|
||||
OTest ("version.cpp"),
|
||||
CoreTest("file.cpp"),
|
||||
CoreTest("database.cpp"),
|
||||
CoreTest("index.cpp"),
|
||||
CoreTest("filter.cpp"),
|
||||
CoreTest("idle.cpp"),
|
||||
CoreTest("tags.cpp", "taglib"),
|
||||
CoreTest("random.cpp"),
|
||||
CoreTest("queue.cpp", extra = "callback.cpp"),
|
||||
CoreTest("library.cpp"),
|
||||
CoreTest("playlist.cpp"),
|
||||
CoreTest("deck.cpp"),
|
||||
CoreTest("driver.cpp"),
|
||||
CoreTest("audio.cpp"),
|
||||
|
||||
]).prepare()
|
||||
|
||||
Return("res")
|
||||
|
|
Loading…
Reference in New Issue