Skip to content

Commit

Permalink
[ test ] Set IDRIS2_PREFIX to a local dir when testing
Browse files Browse the repository at this point in the history
  • Loading branch information
buzden committed Oct 3, 2023
1 parent 46a2dc1 commit f303d9e
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 5 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ idris2docs_venv
/ipkg/build

/tests/**/build
/tests/**/prefix
/tests/**/output*
/tests/**/*.so
/tests/**/*.dylib
Expand Down
1 change: 0 additions & 1 deletion tests/idris2/pkg/pkg010/run
Original file line number Diff line number Diff line change
@@ -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=
Expand Down
4 changes: 0 additions & 4 deletions tests/idris2/pkg/pkg016/run
Original file line number Diff line number Diff line change
Expand Up @@ -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
21 changes: 21 additions & 0 deletions tests/testutils.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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 "$@"
Expand Down Expand Up @@ -36,6 +37,26 @@ else
test_dir="$(pwd)"
fi

# Set variables for hygiene testing
if [ -n "$IDRIS2_PREFIX" -a -z "$PREFIX_CHANGED" ]; 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:$NEW_PP"
export IDRIS2_LIBS="$OLD_PP/libs:$NEW_PP/libs"
export IDRIS2_DATA="$OLD_PP/support:$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
# Useful for consistency of output between machines
# Usage: run SomeTest.idr | filter_test_dir
Expand Down

0 comments on commit f303d9e

Please sign in to comment.