#! /usr/bin/env python
# encoding: utf-8
# Richard Quirk, 2008

import unittestw, Utils, Options

top = '.'
out = 'build'

def set_options(opt):
	opt.tool_options('compiler_cxx')
	opt.tool_options('unittest')

def configure(conf):
	conf.check_tool('compiler_cxx')
	conf.check_tool('unittest')

	# the demo files require cppunit - but the waf tool does not
	conf.check_cfg(package='cppunit', args='--cflags --libs', mandatory=True)
	if 'dl' not in conf.env.LIB_CPPUNIT:
		l = conf.check(lib='dl', uselib_store='CPPUNIT')

def build(bld):
	bld.add_subdirs('src tests')

	# unittestw.summary is a pretty ugly function for displaying a report (feel free to improve!)
	# results -> bld.utest_results [(filename, returncode, stdout, stderr), (..., ), ...]
	bld.add_post_fun(unittestw.summary)

	# to execute all tests:
	# $ waf --alltests
	# to set this behaviour permanenly:
	Options.options.all_tests = True

	# debugging zone:
	# $ waf --zones=ut
	# setting the cwd for a unit test execution: see tests/test1/wscript_build (ut_cwd)

"""
old waf versions upgrade:
if the method check does not exist, add it:

def check(ctx):
	ut = UnitTest.unit_test()
	ut.change_to_testfile_dir = True
	ut.run()
	ut.print_results()
"""
