1 |
# Scons configuration file for esysUtils unit tests |
Import('*') |
2 |
|
# FIXME: This whole test should be refactored into the directory above as esysUtils_UnitTest so it is the same as the other modules |
3 |
|
|
4 |
# |
program_name = 'EsysExceptionTest' |
|
# set appropriate defaults for configuration variables |
|
5 |
|
|
6 |
esysroot=str(Dir('./../../../..').abspath) |
local_env=env.Copy() |
|
execfile(str(File(esysroot+"/scons/esys_options.py"))) |
|
7 |
|
|
8 |
cxx_flags=cxx_flags_debug |
local_env.Append(LIBS=['esysUtils', 'CppUnitTest', sys_libs]) |
9 |
|
|
10 |
# |
src_dir = local_env.Dir('.').srcnode().abspath |
|
# print out build configuration for this module |
|
|
|
|
|
print "Build configuration for module: EsysException unit tests" |
|
|
print " cxx: ", cxx |
|
|
print " cxx_flags: ", cxx_flags |
|
|
|
|
|
# |
|
|
# do the actual build |
|
|
|
|
|
esysexception_test_path = str(esysroot) + '/esysUtils/test/EsysException' |
|
|
esysUtils_path = str(esysroot) + '/esysUtils/src' |
|
|
CppUnitTest_path = str(esysroot) + '/tools/CppUnitTest/inc' |
|
|
|
|
|
esysUtils_lib_path = str(esysroot) + '/esysUtils/lib' |
|
|
CppUnitTest_lib_path = str(esysroot) + '/tools/CppUnitTest/lib' |
|
|
|
|
|
esysUtils_lib = str(esysUtils_lib_path) + '/libesysUtils.a' |
|
|
|
|
|
install_dir = str(esysroot) + '/esysUtils/test' |
|
|
|
|
|
cpp_path = [esysexception_test_path, |
|
|
esysUtils_path, |
|
|
CppUnitTest_path] |
|
|
|
|
|
lib_path = [esysUtils_lib_path, |
|
|
CppUnitTest_lib_path] |
|
|
|
|
|
libs = ['esysUtils', |
|
|
'CppUnitTest'] |
|
|
|
|
|
libs.extend(sys_libs) |
|
|
|
|
|
sources = ['EsysExceptionTestCase.cpp', |
|
|
'EsysExceptionTest.cpp'] |
|
|
|
|
|
target = 'EsysExceptionTest.exe' |
|
11 |
|
|
12 |
import os |
import os |
13 |
esysexception_env = Environment(ENV = os.environ) |
filenames = os.listdir(src_dir) |
14 |
|
sources = [x for x in filenames if os.path.splitext(x)[1] in ['.cpp', '.c']] |
15 |
|
|
16 |
|
local_env.Append(CPPPATH = ['#/tools/CppUnitTest/inc',]) |
17 |
|
|
18 |
esysexception_env.Replace(CXX = cxx) |
program = local_env.Program(program_name, sources) |
|
esysexception_env.Replace(CXXFLAGS = cxx_flags) |
|
|
esysexception_env.Replace(CPPPATH = cpp_path) |
|
|
esysexception_env.Replace(LIBPATH = lib_path) |
|
|
esysexception_env.Replace(LIBS = libs) |
|
19 |
|
|
20 |
esysexception_test_exe = esysexception_env.Program(target, sources) |
Depends(program, dep_lib) |
21 |
|
|
22 |
Depends(esysexception_test_exe, esysUtils_lib) |
# TODO: Need to decide on how the library paths etc are going to be handled |
23 |
|
# TODO: For now just install the program to the same location as the libraries so things can run at least |
24 |
|
test_install = local_env.Install(libinstall, program) |
25 |
|
|
26 |
Alias("build_tests", esysexception_env.Install(install_dir, esysexception_test_exe)) |
#Add Unit Test to target alias |
27 |
|
|
28 |
import scons_extensions |
env.Alias('build_tests', test_install) |
|
runUnitTest_builder = Builder(action = scons_extensions.runUnitTest, suffix = '.passed', single_source=True) |
|
|
esysexception_env.Append(BUILDERS = {'RunUnitTest' : runUnitTest_builder}); |
|
29 |
|
|
30 |
Alias("run_tests", esysexception_env.RunUnitTest(target)) |
# run the tests - but only if test_targets are stale |
31 |
|
local_env.RunUnitTest(program_name) |
32 |
|
test_targets = os.path.splitext(program_name)[0]+'.passed' |
33 |
|
Alias("run_tests", test_targets) |