-
Notifications
You must be signed in to change notification settings - Fork 542
/
env.sh
49 lines (40 loc) · 1.42 KB
/
env.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#!/usr/bin/env bash
# A bash script for setting up environment for DeepDive tests that is supposed to be sourced from every .bats
: ${TEST_DEBUG:=}
# find out the path to the root of DeepDive's source tree
DEEPDIVE_TEST_ROOT=$(cd "$(dirname "${BASH_SOURCE:-$0}")" && pwd)
DEEPDIVE_SOURCE_ROOT=$(cd "$DEEPDIVE_TEST_ROOT/.." && pwd)
# determine the DeepDive installation to run tests against (defaults to the staged one)
: ${DEEPDIVE_HOME:=$(cd "$DEEPDIVE_SOURCE_ROOT" && echo "$PWD"/dist/stage)}
# make sure there's actually DeepDive to test against
# TODO more sophisticated detection
[[ -d "$DEEPDIVE_HOME" ]] || {
echo >&2 "$DEEPDIVE_HOME: No DeepDive installation found."
case $DEEPDIVE_HOME in
*/dist/stage)
echo >&2 'Did you forget to run `make test-build` first?'
esac
false
}
# configure PATH and CLASSPATH for tests
# TODO reuse shell/deepdive
PATH="$DEEPDIVE_HOME/util:$DEEPDIVE_HOME/bin:$DEEPDIVE_HOME/lib/bundled/.all/bin:$PATH"
! [[ -r "$DEEPDIVE_HOME"/env.sh ]] || source "$DEEPDIVE_HOME"/env.sh
export \
DEEPDIVE_TEST_ROOT \
DEEPDIVE_SOURCE_ROOT \
DEEPDIVE_HOME \
PATH \
CLASSPATH \
TEST_DEBUG \
#
# some BATS utilities for testing
keeping_output_of() {
if [[ -n $TEST_DEBUG ]]; then
# keep output of given command when debugging
"$@" | tee "$BATS_TEST_FILENAME".$BATS_TEST_NUMBER.actual
else
# otherwise, just run
"$@"
fi
}