236,241c236,237
< unit_tests = []
< def UnitTest(target, sources):
< '''Create a unit test, specify the target name and a source or
< list of sources'''
< if not isinstance(sources, (list, tuple)):
< sources = [ sources ]
---
> class UnitTest(object):
> '''Create a UnitTest'''
243,244c239,244
< sources = [ Source(src, skip_lib=True) for src in sources ]
< unit_tests.append((target, sources))
---
> all = []
> def __init__(self, target, *sources):
> '''Specify the target name and any sources. Sources that are
> not SourceFiles are evalued with Source(). All files are
> guarded with a guard of the same name as the UnitTest
> target.'''
245a246,256
> srcs = []
> for src in sources:
> if not isinstance(src, SourceFile):
> src = Source(src, skip_lib=True)
> src.guards[target] = True
> srcs.append(src)
>
> self.sources = srcs
> self.target = target
> UnitTest.all.append(self)
>
676c687,688
< init_file = 'python/swig/init_%s.cc' % swig.module
---
> cc_file = str(swig.tnode)
> init_file = '%s/init_%s.cc' % (dirname(cc_file), basename(cc_file))
679c691
< Source(init_file)
---
> Source(init_file, **swig.guards)
907,910d918
< for target, sources in unit_tests:
< objs = [ make_obj(s, static=True) for s in sources ]
< new_env.Program("unittest/%s.%s" % (target, label), objs + static_objs)
<
913a922,928
> for test in UnitTest.all:
> flags = { test.target : True }
> test_sources = Source.get(**flags)
> test_objs = [ make_obj(s, static=True) for s in test_sources ]
> testname = "unittest/%s.%s" % (test.target, label)
> new_env.Program(testname, main_objs + test_objs + static_objs)
>