226 lines (190 with data), 7.1 kB
VERSION='0.1.0'
APPNAME='CppUnit2'
srcdir = '.'
blddir = 'build'
import Options
import Logs
import UnitTest
import Utils
import os.path
import sys
import glob
CPPUT_EXAMPLES = '''
checking_assertions
ignore_failure_demo
input_test
light_fixture
log_demo
parametrized_test
stringize_demo
test_function
'''.split()
BROKEN_CPPUT_EXAMPLES = '''
input_based_test
opentest_demo
table_fixture
'''.split()
def _get_example_dirs():
return [ os.path.join( 'examples', d )
for d in CPPUT_EXAMPLES ]
def _get_main_script_dir():
"""Gets the path of the directory containing this script."""
# The main script path is only valid once the it has been executed, hence this can not be a global var.
assert Utils.g_module is not None
return os.path.split( Utils.g_module.root_path )[0]
def _fix_import_path():
"""Adds the main script directory to be able to import waftools modules."""
import_dir = _get_main_script_dir()
if import_dir not in sys.path:
sys.path.append( import_dir )
def _get_tool_dir():
return os.path.join( main_script_dir, 'waftools' )
def set_options(opt):
"""Always called first during the build."""
_fix_import_path()
import waftools.log_output
waftools.log_output.set_options( opt )
# Adds command-line options for compiler
opt.tool_options('compiler_cxx')
# from compiler_cxx tools, set_options
import Tools.ccroot as ccroot
opt.add_option('-d', '--debug-level',
action="/?originalUrl=https%3A%2F%2Fsourceforge.net%2F%26%2339%3Bstore%26%2339%3B%2C%2520%2520%2520%2520%2520%2520%2520%2520default%2520%3D%2520ccroot.DEBUG_LEVELS.RELEASE%2C%2520%2520%2520%2520%2520%2520%2520%2520help%2520%3D%2520%26%2334%3BSpecify%2520the%2520debug%2520level%2C%2520does%2520nothing%2520if%2520CXXFLAGS%2520is%2520set%2520in%2520the%2520environment.%2520%5BAllowed%2520Values%3A%2520%26%2339%3B%25s%26%2339%3B%5D%2520%26%2334%3B%2520%25%2520%26%2334%3B%26%2339%3B%2C%2520%26%2339%3B%26%2334%3B.join(ccroot.DEBUG_LEVELS.ALL)%2520%2B%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%26%2334%3B%5Bdefault%3A%2520%25default%5D%26%2334%3B%2C%2520%2520%2520%2520%2520%2520%2520%2520choices%2520%3D%2520ccroot.DEBUG_LEVELS.ALL%2C%2520%2520%2520%2520%2520%2520%2520%2520dest%2520%3D%2520%26%2339%3Bdebug_level%26%2339%3B)def%2520init()%3A%2520%2520%2520%2520%26%2334%3B%26%2334%3B%26%2334%3BCalled%2520set_options()%2520once%2520the%2520command-line%2520has%2520been%2520parsed.%2520%2520%2520%2520%2520%2520%2520Command-line%2520options%2520value%2520are%2520accessed%2520through%2520Options.options.%2520%2520%2520%2520%26%2334%3B%26%2334%3B%26%2334%3B%2520%2520%2520%2520import%2520waftools.log_output%2520%2520%2520%2520waftools.log_output.init()%2520%2520%2520%2520def%2520configure(conf)%3A%2520%2520%2520%2520%23%2520There%2520is%2520a%2520link%2520issue%2520with%2520msvc%25209!%2520%2520%2520%2520conf.env%5B%26%2339%3BMSVC_VERSIONS%26%2339%3B%5D%2520%3D%2520%5B%26%2339%3Bmsvc%25208.0%26%2339%3B%5D%2520%2520%2520%2520%23%2520CXX%3Dg%2B%2B-3.0%2520.%2Fwaf.py%2520configure%2520will%2520use%2520g%2B%2B-3.0%2520instead%2520of%2520%26%2339%3Bg%2B%2B%26%2339%3B%2520%2520%2520%2520conf.check_tool(%26%2339%3Bcompiler_cxx%26%2339%3B)%2520%2520%2520%2520%23%2520Select%2520debug%2Foptimize%2520flags%2520%2520%2520%2520debug_level%2520%3D%2520Options.options.debug_level.upper()%2520%2520%2520%2520conf.env.append_unique(%26%2339%3BCXXFLAGS%26%2339%3B%2C%2520conf.env%5B%26%2339%3BCXXFLAGS_%26%2339%3B%2520%2B%2520debug_level%5D)%2520%2520%2520%2520compiler%2520%3D%2520conf.env%5B%26%2339%3BCOMPILER_CXX%26%2339%3B%5D%2520%2520%2520%2520if%2520compiler%2520%3D%3D%2520%26%2339%3Bmsvc%26%2339%3B%3A%2520%2520%23%2520Microsoft%2520Visual%2520Studio%2520specifics%2520%2520%2520%2520%2520%2520%2520%2520%23%2520Select%2520run-time%2520library%2520variant%2520%2520%2520%2520%2520%2520%2520%2520if%2520%26%2339%3BDEBUG%26%2339%3B%2520in%2520debug_level%3A%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520crt_variant%2520%3D%2520%26%2339%3BMULTITHREADED_DLL_DBG%26%2339%3B%2520%2520%2520%2520%2520%2520%2520%2520else%3A%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520crt_variant%2520%3D%2520%26%2339%3BMULTITHREADED_DLL%26%2339%3B%2520%2520%2520%2520%2520%2520%2520%2520%23%2520MULTITHREADED%2C%2520MULTITHREADED_DLL%2C%2520MULTITHREADED_DBG%2C%2520MULTITHREADED_DLL_DBG%2520%2520%2520%2520%2520%2520%2520%2520conf.env.append_unique(%26%2339%3BCPPFLAGS%26%2339%3B%2C%2520conf.env%5B%26%2339%3BCPPFLAGS_CRT_%26%2339%3B%2520%2B%2520crt_variant%5D)%2520%2520%2520%2520%2520%2520%2520%2520conf.env.append_unique(%26%2339%3BCPPDEFINES%26%2339%3B%2C%2520conf.env%5B%26%2339%3BCPPDEFINES_CRT_%26%2339%3B%2520%2B%2520crt_variant%5D)%2520%2520%2520%2520%2520%2520%2520%2520%23%23%2520batched%2520builds%2520can%2520be%2520enabled%2520by%2520including%2520the%2520module%2520optim_cc%2520%2520%2520%2520%23%2520conf.check_tool(%26%2339%3Bbatched_cc%26%2339%3B)%2520%2520%2520%2520%2520%2520%23%2520WAF%2520command%3Adef%2520build(bld)%3A%2520%2520%2520%2520%23%2520process%2520subfolders%2520from%2520here%2520%2520%2520%2520bld.add_subdirs(%26%2339%3B%26%2339%3B%26%2339%3Bsrc%2Fcpptl%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520src%2Fcpput%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520src%2Fcpputtest%26%2339%3B%26%2339%3B%26%2339%3B)%2520%2520%2520%2520bld.add_subdirs(%2520_get_example_dirs()%2520)def%2520gen_examples_wscript(ctx)%3A%2520%2520%2520%2520for%2520example_dir%2520in%2520_get_example_dirs()%3A%2520%2520%2520%2520%2520%2520%2520%2520wscript_path%2520%3D%2520os.path.join(%2520example_dir%2C%2520%26%2339%3Bwscript_build%26%2339%3B%2520)%2520%2520%2520%2520%2520%2520%2520%2520sources%2520%3D%2520glob.glob(%2520os.path.join(%2520example_dir%2C%2520%26%2339%3B*.cpp%26%2339%3B%2520)%2520)%2520%2520%2520%2520%2520%2520%2520%2520Logs.info(%2520%26%2339%3BGenerating%2520%26%2334%3B%25s%26%2334%3B%26%2339%3B%2520%25%2520wscript_path%2520)%2520%2520%2520%2520%2520%2520%2520%2520open(%2520wscript_path%2C%2520%26%2339%3Bwb%26%2339%3B%2520).write(%2520%26%2334%3B%26%2334%3B%26%2334%3B%5C%23!%2520%2Fusr%2Fbin%2Fenv%2520python%23%2520encoding%3A%2520utf-8%23%2520Baptiste%2520Lepilleur%2C%25202009bld.new_task_gen(%2520%2520%2520%2520features%2520%3D%2520%26%2339%3Bcxx%2520cprogram%26%2339%3B%2C%2520%2520%2520%2520source%2520%3D%2520%26%2339%3B%26%2339%3B%26%2339%3B%25(sources)s%26%2339%3B%26%2339%3B%26%2339%3B%2C%2520%2520%2520%2520includes%2520%3D%2520%26%2339%3B..%2F..%2520..%2F..%2Finclude%26%2339%3B%2C%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%23%2520for%2520examples%2Fcommon%2520%2520%2520%2520uselib_local%2520%3D%2520%26%2339%3Bcpptl%2520cpput%26%2339%3B%2C%2520%2520%2520%2520name%2520%3D%2520%26%2339%3Bexample_%25(name)s%26%2339%3B%2C%2520%2520%2520%2520target%2520%3D%2520%26%2339%3Bexample_%25(name)s%26%2339%3B%2520)%26%2334%3B%26%2334%3B%26%2334%3B%2520%25%2520%7B%2520%2520%2520%2520%26%2339%3Bsources%26%2339%3B%3A%2520%26%2339%3B%2520%26%2339%3B.join(%2520%5Bos.path.basename(s)%2520for%2520s%2520in%2520sources%5D%2520)%2C%2520%2520%2520%2520%26%2339%3Bname%26%2339%3B%3A%2520os.path.basename(%2520example_dir%2520)%2520%2520%2520%2520%7D%2520)def%2520_fix_python_source(%2520path%2C%2520is_dry_run%2520%3D%2520True%2C%2520verbose%2520%3D%2520True%2520)%3A%2520%2520%2520%2520%26%2334%3B%26%2334%3B%26%2334%3BMakes%2520sure%2520that%2520all%2520sources%2520have%2520unix%2520EOL%2520and%2520replace%2520tabs%2520with%25204%2520spaces.%26%2334%3B%26%2334%3B%26%2334%3B%2520%2520%2520%2520from%2520waftools%2520import%2520reindent%2520%2520%2520%2520if%2520not%2520os.path.isfile(%2520path%2520)%3A%2520%2520%2520%2520%2520%2520%2520%2520raise%2520ValueError(%2520%26%2339%3BPath%2520%26%2334%3B%25s%26%2334%3B%2520is%2520not%2520a%2520file%26%2339%3B%2520%25%2520path%2520)%2520%2520%2520%2520try%3A%2520%2520%2520%2520%2520%2520%2520%2520f%2520%3D%2520open(path%2C%2520%26%2339%3Brb%26%2339%3B)%2520%2520%2520%2520except%2520IOError%2C%2520msg%3A%2520%2520%2520%2520%2520%2520%2520%2520print%2520%26gt%3B%26gt%3B%2520sys.stderr%2C%2520%26%2334%3B%25s%3A%2520I%2FO%2520Error%3A%2520%25s%26%2334%3B%2520%25%2520(file%2C%2520str(msg))%2520%2520%2520%2520%2520%2520%2520%2520return%2520False%2520%2520%2520%2520if%2520verbose%3A%2520%2520%2520%2520%2520%2520%2520%2520print%2520%26%2339%3B%25s%2520%3D%26gt%3B%26%2339%3B%2520%25%2520path%2C%2520%2520%2520%2520%2520try%3A%2520%2520%2520%2520%2520%2520%2520%2520r%2520%3D%2520reindent.Reindenter(f)%2520%2520%2520%2520finally%3A%2520%2520%2520%2520%2520%2520%2520%2520f.close()%2520%2520%2520%2520if%2520r.run()%3A%2520%23%2520File%2520need%2520to%2520be%2520fixed%2520%3F%2520%2520%2520%2520%2520%2520%2520%2520if%2520not%2520is_dry_run%3A%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520f%2520%3D%2520open(path%2C%2520%26%2334%3Bwb%26%2334%3B)%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520try%3A%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520r.write(f)%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520finally%3A%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520f.close()%2520%2520%2520%2520%2520%2520%2520%2520if%2520verbose%3A%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520print%2520is_dry_run%2520and%2520%26%2339%3B%2520NEED%2520FIX%26%2339%3B%2520or%2520%26%2339%3B%2520FIXED%26%2339%3B%2520%2520%2520%2520elif%2520verbose%3A%2520%2520%2520%2520%2520%2520%2520%2520print%2520%26%2339%3B%2520OK%26%2339%3B%2520%2520%2520%2520return%2520Truedef%2520_fix_source_eol(%2520path%2C%2520is_dry_run%2520%3D%2520True%2C%2520verbose%2520%3D%2520True%2C%2520eol%2520%3D%2520%26%2339%3B%5Cn%26%2339%3B%2520)%3A%2520%2520%2520%2520%26%2334%3B%26%2334%3B%26%2334%3BMakes%2520sure%2520that%2520all%2520sources%2520have%2520the%2520specified%2520eol%2520sequence%2520(default%3A%2520unix).%26%2334%3B%26%2334%3B%26%2334%3B%2520%2520%2520%2520if%2520not%2520os.path.isfile(%2520path%2520)%3A%2520%2520%2520%2520%2520%2520%2520%2520raise%2520ValueError(%2520%26%2339%3BPath%2520%26%2334%3B%25s%26%2334%3B%2520is%2520not%2520a%2520file%26%2339%3B%2520%25%2520path%2520)%2520%2520%2520%2520try%3A%2520%2520%2520%2520%2520%2520%2520%2520f%2520%3D%2520open(path%2C%2520%26%2339%3Brb%26%2339%3B)%2520%2520%2520%2520except%2520IOError%2C%2520msg%3A%2520%2520%2520%2520%2520%2520%2520%2520print%2520%26gt%3B%26gt%3B%2520sys.stderr%2C%2520%26%2334%3B%25s%3A%2520I%2FO%2520Error%3A%2520%25s%26%2334%3B%2520%25%2520(file%2C%2520str(msg))%2520%2520%2520%2520%2520%2520%2520%2520return%2520False%2520%2520%2520%2520try%3A%2520%2520%2520%2520%2520%2520%2520%2520raw_lines%2520%3D%2520f.readlines()%2520%2520%2520%2520finally%3A%2520%2520%2520%2520%2520%2520%2520%2520f.close()%2520%2520%2520%2520fixed_lines%2520%3D%2520%5Bline.rstrip(%26%2339%3B%5Cr%5Cn%26%2339%3B)%2520%2B%2520eol%2520for%2520line%2520in%2520raw_lines%5D%2520%2520%2520%2520if%2520raw_lines%2520!%3D%2520fixed_lines%3A%2520%2520%2520%2520%2520%2520%2520%2520print%2520%26%2339%3B%25s%2520%3D%26gt%3B%26%2339%3B%2520%25%2520path%2C%2520%2520%2520%2520%2520%2520%2520%2520if%2520not%2520is_dry_run%3A%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520f%2520%3D%2520open(path%2C%2520%26%2334%3Bwb%26%2334%3B)%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520try%3A%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520f.writelines(fixed_lines)%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520finally%3A%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520f.close()%2520%2520%2520%2520%2520%2520%2520%2520if%2520verbose%3A%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520print%2520is_dry_run%2520and%2520%26%2339%3B%2520NEED%2520FIX%26%2339%3B%2520or%2520%26%2339%3B%2520FIXED%26%2339%3B%2520%2520%2520%2520return%2520True%2520%2520%2520%2520%2520%2520%2520%2520def%2520_do_fix(%2520is_dry_run%2520%3D%2520True%2520)%3A%2520%2520%2520%2520from%2520waftools%2520import%2520antglob%2520%2520%2520%2520python_sources%2520%3D%2520antglob.glob(%2520%26%2339%3B.%26%2339%3B%2C%2520%2520%2520%2520%2520%2520%2520%2520includes%2520%3D%2520%26%2339%3B**%2F*.py%2520**%2Fwscript%2520**%2Fwscript_build%26%2339%3B%2C%2520%2520%2520%2520%2520%2520%2520%2520excludes%2520%3D%2520antglob.default_excludes%2520%2B%2520%26%2339%3B.%2Fwaf.py%26%2339%3B%2C%2520%2520%2520%2520%2520%2520%2520%2520prune_dirs%2520%3D%2520antglob.prune_dirs%2520%2B%2520%26%2339%3Bwaf-*%2520.%2Fbuild%26%2339%3B%2520)%2520%2520%2520%2520for%2520path%2520in%2520python_sources%3A%2520%2520%2520%2520%2520%2520%2520%2520_fix_python_source(%2520path%2C%2520is_dry_run%2520)%2520%2520%2520%2520cpp_sources%2520%3D%2520antglob.glob(%2520%26%2339%3B.%26%2339%3B%2C%2520%2520%2520%2520%2520%2520%2520%2520includes%2520%3D%2520%26%2339%3B**%2F*.cpp%2520**%2F*.h%2520**%2F*.inl%26%2339%3B%2C%2520%2520%2520%2520%2520%2520%2520%2520prune_dirs%2520%3D%2520antglob.prune_dirs%2520%2B%2520%26%2339%3Bwaf-*%2520.%2Fbuild%26%2339%3B%2520)%2520%2520%2520%2520for%2520path%2520in%2520cpp_sources%3A%2520%2520%2520%2520%2520%2520%2520%2520_fix_source_eol(%2520path%2C%2520is_dry_run%2520)def%2520dry_fix(context)%3A%2520%2520%2520%2520_do_fix(%2520is_dry_run%2520%3D%2520True%2520)def%2520fix(context)%3A%2520%2520%2520%2520_do_fix(%2520is_dry_run%2520%3D%2520False%2520)def%2520shutdown()%3A%2520%2520%2520%2520passdef%2520check(context)%3A%2520%2520%2520%2520%23%2520Unit%2520tests%2520are%2520run%2520when%2520%26%2334%3Bcheck%26%2334%3B%2520target%2520is%2520used%2520%2520%2520%2520ut%2520%3D%2520UnitTest.unit_test()%2520%2520%2520%2520ut.change_to_testfile_dir%2520%3D%2520True%2520%2520%2520%2520ut.want_to_see_test_output%2520%3D%2520True%2520%2520%2520%2520ut.want_to_see_test_error%2520%3D%2520True%2520%2520%2520%2520ut.run()%2520%2520%2520%2520ut.print_results()%253C%2Fpre">