Skip to content

Commit

Permalink
test-example, test-stub: clean up build directory after each
Browse files Browse the repository at this point in the history
The build dir is not cached in Travis, so we can and should clean it up
locally. Otherwise, it could cause problems if files from a previous
build get included into a new build.

We put it in xhaskell to have it be in a consistent location: stack
checks whether the path has changed, so it needs to be in a stable path.
  • Loading branch information
petertseng committed Feb 1, 2017
1 parent 0028f8e commit beb05ce
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
10 changes: 9 additions & 1 deletion bin/test-example
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,16 @@ exercisedir=$(cd "$exampledir/../.." && pwd)
exercisename=$(basename "$exercisedir")
xhaskell=$(cd "$(dirname "$0")/.." && pwd)

buildfolder="${TRAVIS_BUILD_DIR:-$xhaskell}/build/${exercisename}/${examplename}"
# We would ideally use a tmpdir here,
# but stack will invalidate its cache if the path changes,
# so the best alternative seems to be to put it in xhaskell.
buildfolder="${xhaskell}/build/${exercisename}/${examplename}"
mkdir -p "${buildfolder}"
cleanup() {
rm -r "${xhaskell}/build"
}
trap cleanup EXIT INT TERM

cp -R -L ${exercisedir}/stack.yaml ${exercisedir}/test ${exampledir}/* "${buildfolder}"

cd $buildfolder
Expand Down
10 changes: 9 additions & 1 deletion bin/test-stub
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,16 @@ exercisename=$(basename "$exercisedir")
examplename="stub"
xhaskell=$(cd "$(dirname "$0")/.." && pwd)

buildfolder="${TRAVIS_BUILD_DIR:-$xhaskell}/build/${exercisename}/${examplename}"
# We would ideally use a tmpdir here,
# but stack will invalidate its cache if the path changes,
# so the best alternative seems to be to put it in xhaskell.
buildfolder="${xhaskell}/build/${exercisename}/${examplename}"
mkdir -p "${buildfolder}"
cleanup() {
rm -r "${xhaskell}/build"
}
trap cleanup EXIT INT TERM

cp -R -L ${exercisedir}/stack.yaml ${exercisedir}/package.yaml ${exercisedir}/src ${exercisedir}/test "${buildfolder}"

cd $buildfolder
Expand Down

0 comments on commit beb05ce

Please sign in to comment.