diff --git a/.gitignore b/.gitignore index 0f4b63115..8c797335d 100644 --- a/.gitignore +++ b/.gitignore @@ -18,6 +18,7 @@ idris2docs_venv /ipkg/build /tests/**/build +/tests/**/prefix /tests/**/output* /tests/**/*.so /tests/**/*.dylib diff --git a/tests/idris2/pkg/pkg010/run b/tests/idris2/pkg/pkg010/run index 1135ebaaa..1a4d91f79 100755 --- a/tests/idris2/pkg/pkg010/run +++ b/tests/idris2/pkg/pkg010/run @@ -1,6 +1,5 @@ . ../../../testutils.sh -export IDRIS2_PACKAGE_PATH=$IDRIS2_PREFIX/$NAME_VERSION export IDRIS2_PREFIX=$test_dir/currently/nonexistent/dir/ export IDRIS2_INC_CGS= diff --git a/tests/idris2/pkg/pkg016/run b/tests/idris2/pkg/pkg016/run index 7b26a4531..367a8ff68 100644 --- a/tests/idris2/pkg/pkg016/run +++ b/tests/idris2/pkg/pkg016/run @@ -6,7 +6,3 @@ idris2 --install baz.ipkg > /dev/null idris2 --build test.ipkg build/exec/test - -rm -r "${IDRIS2_PREFIX}"/idris2-*/foo-0 -rm -r "${IDRIS2_PREFIX}"/idris2-*/bar-0 -rm -r "${IDRIS2_PREFIX}"/idris2-*/baz-0 diff --git a/tests/testutils.sh b/tests/testutils.sh index 6dcb4179b..7f64eb64f 100755 --- a/tests/testutils.sh +++ b/tests/testutils.sh @@ -9,6 +9,7 @@ idris2="$1" # Delete build files between runs to prevent unexpected differences. # As this is at the top-level, this is run when this script is imported. rm -rf build +rm -rf prefix idris2() { $idris2 --no-banner --console-width 0 --no-color "$@" @@ -32,8 +33,30 @@ sed_literal() { # Folder containing the currently running test if [ "$OS" = "windows" ]; then test_dir="$(cygpath -m "$(pwd)")" + SEP=";" else test_dir="$(pwd)" + SEP=":" +fi + +# Set variables for hygiene testing +if [ -z "$PREFIX_CHANGED" ] && [ -n "$IDRIS2_PREFIX" ]; then + OLD_PREFIX="$IDRIS2_PREFIX" + NEW_PREFIX="$test_dir/prefix" + + OLD_PP="$OLD_PREFIX/$NAME_VERSION" + NEW_PP="$NEW_PREFIX/$NAME_VERSION" + + # Set where to look to installed stuff + export IDRIS2_PACKAGE_PATH="$OLD_PP$SEP$NEW_PP" + export IDRIS2_LIBS="$OLD_PP/libs$SEP$NEW_PP/libs" + export IDRIS2_DATA="$OLD_PP/support$SEP$NEW_PP/support" + + # Set where to install stuff + export IDRIS2_PREFIX="$NEW_PREFIX" + + # Save from re-sourcing this file several times + export PREFIX_CHANGED=1 fi # Remove test directory from output