From 6c6d0fda6928aab668bdf1a92e1bebfbcbd6dc52 Mon Sep 17 00:00:00 2001 From: Olivier Tilloy Date: Wed, 14 Apr 2010 11:40:06 +0200 Subject: Add a scons target to run the unit tests. --- SConstruct | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'SConstruct') diff --git a/SConstruct b/SConstruct index 7e54c37..ec57e67 100644 --- a/SConstruct +++ b/SConstruct @@ -22,6 +22,10 @@ def build_doc(): sys.path.insert(0, os.path.join(curdir, 'src')) SConscript('doc/SConscript') +def run_tests(): + from test.TestsRunner import run_unit_tests + run_unit_tests() + if not BUILD_TARGETS: # Default target: lib build_lib() @@ -32,4 +36,6 @@ else: # Note: building the doc requires the lib to be built and the pyexiv2 # module to be in the python path. build_doc() + if 'test' in BUILD_TARGETS: + run_tests() -- cgit From 21b0124ed55537a9640dc21fbedfb644cd269ab5 Mon Sep 17 00:00:00 2001 From: Olivier Tilloy Date: Wed, 14 Apr 2010 11:59:12 +0200 Subject: Isolate the PYTHONPATH fiddling in a separate function, and do it when running the unit tests too. --- SConstruct | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) (limited to 'SConstruct') diff --git a/SConstruct b/SConstruct index ec57e67..f3e9702 100644 --- a/SConstruct +++ b/SConstruct @@ -3,6 +3,13 @@ import os import sys +def _fiddle_with_pythonpath(): + # Fiddle with the pythonpath to allow builders to locate pyexiv2 + # (see https://bugs.launchpad.net/pyexiv2/+bug/549398). + curdir = os.path.abspath(os.curdir) + sys.path.insert(0, os.path.join(curdir, 'build')) + sys.path.insert(0, os.path.join(curdir, 'src')) + def build_lib(): try: from site import USER_SITE @@ -15,15 +22,15 @@ def build_lib(): SConscript('src/SConscript', variant_dir='build', duplicate=0) def build_doc(): - # Fiddle with the pythonpath to allow the doc builder to locate pyexiv2 - # (see https://bugs.launchpad.net/pyexiv2/+bug/549398). - curdir = os.path.abspath(os.curdir) - sys.path.insert(0, os.path.join(curdir, 'build')) - sys.path.insert(0, os.path.join(curdir, 'src')) + _fiddle_with_pythonpath() SConscript('doc/SConscript') def run_tests(): + _fiddle_with_pythonpath() from test.TestsRunner import run_unit_tests + # FIXME: this is not really well integrated as scons is not informed + # whether the unit tests passed or failed. + # http://www.scons.org/wiki/UnitTests may be of use. run_unit_tests() if not BUILD_TARGETS: -- cgit From e6c641481f5f0485ccc8d76e7b1f3ca095771cde Mon Sep 17 00:00:00 2001 From: Olivier Tilloy Date: Wed, 14 Apr 2010 12:04:23 +0200 Subject: Return the test runner's result. --- SConstruct | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'SConstruct') diff --git a/SConstruct b/SConstruct index f3e9702..05393a7 100644 --- a/SConstruct +++ b/SConstruct @@ -31,7 +31,7 @@ def run_tests(): # FIXME: this is not really well integrated as scons is not informed # whether the unit tests passed or failed. # http://www.scons.org/wiki/UnitTests may be of use. - run_unit_tests() + result = run_unit_tests() if not BUILD_TARGETS: # Default target: lib -- cgit From 1f28278abbabe63e5c3061566fa41e643a289734 Mon Sep 17 00:00:00 2001 From: Olivier Tilloy Date: Wed, 14 Apr 2010 13:17:53 +0200 Subject: The test scons target is now aware of the result of running the test suite. --- SConstruct | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) (limited to 'SConstruct') diff --git a/SConstruct b/SConstruct index 05393a7..5422ccd 100644 --- a/SConstruct +++ b/SConstruct @@ -27,11 +27,7 @@ def build_doc(): def run_tests(): _fiddle_with_pythonpath() - from test.TestsRunner import run_unit_tests - # FIXME: this is not really well integrated as scons is not informed - # whether the unit tests passed or failed. - # http://www.scons.org/wiki/UnitTests may be of use. - result = run_unit_tests() + SConscript('test/SConscript') if not BUILD_TARGETS: # Default target: lib @@ -44,5 +40,6 @@ else: # module to be in the python path. build_doc() if 'test' in BUILD_TARGETS: + # Note: running the unit tests requires the lib to be built. run_tests() -- cgit