From 8787aec7d010b74cdaa7ccdbe11f32ded55fc006 Mon Sep 17 00:00:00 2001 From: Simon Feltman Date: Wed, 18 Dec 2013 18:30:54 -0800 Subject: tests: Update Python stanza to change directories before running tests Ensure PYTHONPATH uses absolute paths for top_builddir and top_srcdir. Use pushd/popd before and after running tests with "python -m unittest...". This ensures TESTARGS can be used from within a vpath build directory. https://bugzilla.gnome.org/show_bug.cgi?id=720713 --- tests/gi-tester | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'tests/gi-tester') diff --git a/tests/gi-tester b/tests/gi-tester index 78a5c437..a7be6904 100755 --- a/tests/gi-tester +++ b/tests/gi-tester @@ -38,9 +38,11 @@ case $targetname in PYTHONPATH=${top_builddir}:${top_srcdir} ${PYTHON} ${targetname} exit $? else - # Run as Python unittest module with TESTARGS concatenated to the basename of target - targetbasename=`basename "${targetname}" .py` - PYTHONPATH=${top_builddir}:${top_srcdir} ${PYTHON} -m unittest -v "${targetbasename}.${TESTARGS}" + # Run as Python unittest module with TESTARGS concatenated to the basename of target. + # Ensure we are in the directory containing the python module first. + export PYTHONPATH=$(readlink -f ${top_builddir}):$(readlink -f ${top_srcdir}) + modulename=$(basename "${targetbase}" .py) + (cd $(dirname ${targetname}) && ${PYTHON} -m unittest -v "${modulename}.${TESTARGS}") exit $? fi ;; -- cgit v1.2.1