[ test ] Set IDRIS2_PREFIX to a local dir when testing

This commit is contained in:
Denis Buzdalov 2023-10-03 15:48:39 +03:00 committed by G. Allais
parent 847b525189
commit 567f019230
4 changed files with 24 additions and 5 deletions

1
.gitignore vendored
View File

@ -18,6 +18,7 @@ idris2docs_venv
/ipkg/build
/tests/**/build
/tests/**/prefix
/tests/**/output*
/tests/**/*.so
/tests/**/*.dylib

View File

@ -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=

View File

@ -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

View File

@ -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