2013-07-05 09:40:11 -04:00
|
|
|
#!/usr/bin/python
|
2014-03-03 12:09:51 -05:00
|
|
|
|
|
|
|
import sys
|
2014-02-27 09:51:05 -05:00
|
|
|
Import("env")
|
2014-05-06 08:36:11 -04:00
|
|
|
tests = [
|
|
|
|
|
|
|
|
###
|
|
|
|
#
|
|
|
|
# (source.cpp, use collected lib_files?, [ other files ])
|
|
|
|
#
|
|
|
|
|
|
|
|
("version.cpp", False, []),
|
|
|
|
("file.cpp", True, []),
|
|
|
|
("database.cpp", True, []),
|
|
|
|
("index.cpp", True, []),
|
|
|
|
("filter.cpp", True, []),
|
|
|
|
("idle.cpp", False, [ "idle.cpp" ]),
|
2014-05-06 22:44:40 -04:00
|
|
|
("tags.cpp", True, []),
|
2014-05-06 08:36:11 -04:00
|
|
|
|
|
|
|
]
|
|
|
|
|
2013-07-07 21:17:27 -04:00
|
|
|
|
2014-04-13 18:39:56 -04:00
|
|
|
check_depends = True
|
|
|
|
|
|
|
|
for arg in sys.argv:
|
|
|
|
if arg.find("tests") == 0:
|
|
|
|
env.Append( CCFLAGS = [ "-DCONFIG_TEST" ] )
|
|
|
|
if len(arg) > 5:
|
|
|
|
check_depends = False
|
|
|
|
break
|
2014-03-03 12:09:51 -05:00
|
|
|
|
2014-05-06 08:36:11 -04:00
|
|
|
def expand_files(extra_files):
|
|
|
|
res = []
|
|
|
|
for f in extra_files:
|
|
|
|
res += [ "../lib/%s" % f ]
|
|
|
|
return res
|
|
|
|
|
|
|
|
def make_program(src, name, extra_files):
|
|
|
|
return env.Program("%s" % name, [ src ] + expand_files(extra_files))
|
|
|
|
|
|
|
|
def make_test(src, name):
|
|
|
|
test = Command("%s.out" % name, [],
|
2014-05-06 22:44:40 -04:00
|
|
|
"set -o pipefail; ./tests/%s | tee ./tests/%s.out" % (name, name))
|
2014-05-06 08:36:11 -04:00
|
|
|
Alias("tests/%s" % name, test)
|
|
|
|
AlwaysBuild(test)
|
|
|
|
return test
|
|
|
|
|
|
|
|
def prepare_test(name, src, extra_files):
|
|
|
|
exe = make_program(src, name, extra_files)
|
|
|
|
test = make_test(src, name)
|
|
|
|
Depends(test, exe)
|
|
|
|
return test
|
|
|
|
|
|
|
|
res = []
|
|
|
|
lib_files = []
|
|
|
|
|
|
|
|
ignore = open(".gitignore", 'w')
|
|
|
|
for src, lib, extra in tests:
|
|
|
|
name = "%s" % src.rsplit(".")[0]
|
|
|
|
|
|
|
|
if lib == True:
|
|
|
|
lib_files += [ src ]
|
|
|
|
extra = lib_files + extra
|
2013-07-07 21:17:27 -04:00
|
|
|
|
2014-05-06 08:36:11 -04:00
|
|
|
test = prepare_test(name, src, extra)
|
|
|
|
if (check_depends == True) and (len(res) > 0):
|
|
|
|
Depends(test, res[len(res) - 1])
|
2014-03-02 12:00:41 -05:00
|
|
|
|
2014-05-06 08:36:11 -04:00
|
|
|
res += [ test ]
|
|
|
|
ignore.write(name + "\n")
|
|
|
|
ignore.close();
|
2014-03-02 12:00:41 -05:00
|
|
|
|
2014-05-06 08:36:11 -04:00
|
|
|
Return("res")
|
2014-03-02 14:44:24 -05:00
|
|
|
|
2014-05-06 08:36:11 -04:00
|
|
|
#tests = [ "version" , "file", "database", "index", "filter", "idle" ]
|
|
|
|
## "tag_db",
|
|
|
|
## "queue" ]
|
|
|
|
##scripts = [ "playlist", "library", "deck", "audio", "gui" ]
|