diff options
-rwxr-xr-x | check | 15 | ||||
-rw-r--r-- | yarns/morph.shell-lib | 11 |
2 files changed, 23 insertions, 3 deletions
@@ -2,7 +2,7 @@ # # Run test suite for morph. # -# Copyright (C) 2011-2013 Codethink Limited +# Copyright (C) 2011-2014 Codethink Limited # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -71,10 +71,21 @@ fi python setup.py clean check # Run scenario tests with yarn, if yarn is available. +# +# Yarn cleans up the environment when it runs tests, and this removes +# PYTHONPATH from the environment. However, we need our tests to have +# the PYTHONPATH, so that we can get them to, for example, use the right +# versions of updated dependencies. The immediate current need is to +# be able to get them to use an updated version of cliapp, but it is +# a general need. +# +# We solve this by using the yarn --env option, allowing us to tell yarn +# explicitly which environment variables to set in addition to the set +# it sets anyway. if command -v yarn > /dev/null then - yarn -s yarns/morph.shell-lib yarns/*.yarn + yarn --env "PYTHONPATH=$PYTHONPATH" -s yarns/morph.shell-lib yarns/*.yarn fi # cmdtest tests. diff --git a/yarns/morph.shell-lib b/yarns/morph.shell-lib index 265e7c78..4ce8c2f8 100644 --- a/yarns/morph.shell-lib +++ b/yarns/morph.shell-lib @@ -19,6 +19,15 @@ # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +# Add $SRCDIR to PYTHONPATH. + +case "$PYTHONPATH" in + '') PYTHONPATH="$SRCDIR)" ;; + *) PYTHONPATH="$SRCDIR:$PYTHONPATH" ;; +esac +export PYTHONPATH + + # Run Morph from the source tree, ignoring any configuration files. # This way the test suite is not affected by any configuration the user # or system may have. Instead, we'll use the `$DATADIR/morph.conf` file, @@ -28,7 +37,7 @@ run_morph() { { set +e - PYTHONPATH="$SRCDIR" "$SRCDIR"/morph \ + "$SRCDIR"/morph \ --cachedir-min-space=0 --tempdir-min-space=0 \ --no-default-config --config "$DATADIR/morph.conf" "$@" \ 2> "$DATADIR/result-$1" |