2014-12-08 20:52:52 +01:00
|
|
|
import os
|
|
|
|
import glob
|
|
|
|
from copy import copy
|
|
|
|
|
|
|
|
Import ('env')
|
|
|
|
|
|
|
|
test_env = env.Clone()
|
|
|
|
|
|
|
|
if not env['CPP_TESTS']:
|
2015-04-25 22:08:12 +02:00
|
|
|
for cpp_test_bin in glob.glob('./*/*-bin'):
|
2014-12-08 20:52:52 +01:00
|
|
|
os.unlink(cpp_test_bin)
|
2016-03-12 02:52:07 +01:00
|
|
|
if os.path.exists('./unit/run'): os.unlink('./unit/run')
|
|
|
|
if os.path.exists('./visual/run'): os.unlink('./visual/run')
|
2014-12-08 20:52:52 +01:00
|
|
|
else:
|
|
|
|
test_env['LIBS'] = [env['MAPNIK_NAME']]
|
|
|
|
test_env.AppendUnique(LIBS='mapnik-wkt')
|
|
|
|
test_env.AppendUnique(LIBS='mapnik-json')
|
2015-05-18 15:45:30 +02:00
|
|
|
test_env.AppendUnique(LIBS=copy(env['LIBMAPNIK_LIBS']))
|
2014-12-08 20:52:52 +01:00
|
|
|
if env['RUNTIME_LINK'] == 'static' and env['PLATFORM'] == 'Linux':
|
|
|
|
test_env.AppendUnique(LIBS='dl')
|
|
|
|
test_env.AppendUnique(CXXFLAGS='-g')
|
|
|
|
test_env['CXXFLAGS'] = copy(test_env['LIBMAPNIK_CXXFLAGS'])
|
2019-11-04 11:47:35 +01:00
|
|
|
test_env['CPPFLAGS'] = '-fsanitize=bounds'
|
2014-12-08 20:52:52 +01:00
|
|
|
test_env.Append(CPPDEFINES = env['LIBMAPNIK_DEFINES'])
|
2019-11-04 11:47:35 +01:00
|
|
|
|
2014-12-08 20:52:52 +01:00
|
|
|
if test_env['HAS_CAIRO']:
|
|
|
|
test_env.PrependUnique(CPPPATH=test_env['CAIRO_CPPPATHS'])
|
|
|
|
test_env.Append(CPPDEFINES = '-DHAVE_CAIRO')
|
2015-04-25 22:08:12 +02:00
|
|
|
test_env.PrependUnique(CPPPATH=['./'])
|
2015-02-17 17:28:49 +01:00
|
|
|
if test_env['PLATFORM'] == 'Linux':
|
|
|
|
test_env['LINKFLAGS'].append('-pthread')
|
2019-11-04 11:47:35 +01:00
|
|
|
test_env['LINKFLAGS'].append('-fsanitize=bounds')
|
2015-02-17 17:28:49 +01:00
|
|
|
test_env.AppendUnique(LIBS='boost_program_options%s' % env['BOOST_APPEND'])
|
2014-12-08 20:52:52 +01:00
|
|
|
test_env_local = test_env.Clone()
|
2015-04-25 22:08:12 +02:00
|
|
|
|
|
|
|
|
|
|
|
# unit tests
|
|
|
|
sources = glob.glob('./unit/*/*.cpp')
|
|
|
|
sources.extend(glob.glob('./unit/*.cpp'))
|
2019-11-04 11:47:35 +01:00
|
|
|
sources.append('../src/text/scrptrun.cpp')
|
2015-04-25 22:08:12 +02:00
|
|
|
test_program = test_env_local.Program("./unit/run", source=sources)
|
|
|
|
Depends(test_program, env.subst('../src/%s' % env['MAPNIK_LIB_NAME']))
|
|
|
|
Depends(test_program, env.subst('../src/json/libmapnik-json${LIBSUFFIX}'))
|
|
|
|
Depends(test_program, env.subst('../src/wkt/libmapnik-wkt${LIBSUFFIX}'))
|
2015-05-21 16:41:28 +02:00
|
|
|
if 'install' in COMMAND_LINE_TARGETS:
|
|
|
|
env.Alias('install',test_program)
|
2015-04-25 22:08:12 +02:00
|
|
|
|
|
|
|
# standalone tests
|
|
|
|
for standalone in glob.glob('./standalone/*cpp'):
|
2015-05-21 16:41:28 +02:00
|
|
|
test_program2 = test_env_local.Program(standalone.replace('.cpp','-bin'), source=standalone)
|
2015-04-25 22:08:12 +02:00
|
|
|
Depends(test_program, env.subst('../src/%s' % env['MAPNIK_LIB_NAME']))
|
2015-05-21 16:41:28 +02:00
|
|
|
if 'install' in COMMAND_LINE_TARGETS:
|
|
|
|
env.Alias('install',test_program2)
|
2015-04-25 22:08:12 +02:00
|
|
|
|
2015-02-17 17:28:49 +01:00
|
|
|
# visual tests
|
|
|
|
source = Split(
|
|
|
|
"""
|
|
|
|
visual/report.cpp
|
|
|
|
visual/runner.cpp
|
|
|
|
visual/run.cpp
|
2016-12-09 11:52:25 +01:00
|
|
|
visual/parse_map_sizes.cpp
|
2015-02-17 17:28:49 +01:00
|
|
|
"""
|
|
|
|
)
|
2015-05-21 16:41:28 +02:00
|
|
|
test_program3 = test_env_local.Program('visual/run', source=source)
|
2015-02-17 17:28:49 +01:00
|
|
|
Depends(test_program, env.subst('../src/%s' % env['MAPNIK_LIB_NAME']))
|
|
|
|
|
2014-12-08 20:52:52 +01:00
|
|
|
# build locally if installing
|
|
|
|
if 'install' in COMMAND_LINE_TARGETS:
|
2015-05-21 16:41:28 +02:00
|
|
|
env.Alias('install',test_program3)
|