1
0
Fork 0
arangodb/scripts/unittest

79 lines
2.0 KiB
Bash
Executable File

#!/usr/bin/env bash
export PID=$$
export GLIBCXX_FORCE_NEW=1
SED=sed
isMac=0
if test "$(uname)" == "Darwin"; then
isMac=1
SED=gsed
fi
if test -n "$ORIGINAL_PATH"; then
# running in cygwin...
PS='\'
export EXT=".exe"
else
export EXT=""
PS='/'
fi;
export PORT=`expr 1024 + $RANDOM`
NUMA=""
if $(which numactl > /dev/null 2>&1); then
NUMA="numactl --interleave=all"
fi
if [ `uname -s` == "Darwin" ]; then
EXEC_PATH="$(dirname "$(dirname "$0")")"
else
EXEC_PATH="$(dirname "$(dirname "$(readlink -m "$0")")")"
fi
declare -a EXTRA_ARGS
if [ -z "${ARANGOSH}" ]; then
if [ -x build/bin/arangosh -a ! -d build/bin/arangosh ]; then
ARANGOSH="build/bin/arangosh${EXT}"
elif [ -x bin/arangosh -a ! -d bin/arangosh ]; then
ARANGOSH="bin/arangosh${EXT}"
elif [ -x arangosh -a ! -d arangosh ]; then
ARANGOSH="arangosh${EXT}"
elif [ -x usr/bin/arangosh -a ! -d usr/bin/arangosh ]; then
ARANGOSH="usr/bin/arangosh${EXT}"
else
ARANGOSH="$(find "${EXEC_PATH}" -name "arangosh${EXT}" -perm -001 -type f | head -n 1)"
[ -x "${ARANGOSH}" ] || {
echo "$0: cannot locate arangosh"
exit 1
}
fi
fi
[ "$(uname -s)" != "Darwin" -a -x "${ARANGOSH}" ] && ARANGOSH="$(readlink -m "${ARANGOSH}")"
[ "$(uname -s)" = "Darwin" -a -x "${ARANGOSH}" ] && ARANGOSH="$(cd -P -- "$(dirname -- "${ARANGOSH}")" && pwd -P)/$(basename -- "${ARANGOSH}")"
[[ " $@ " =~ "--build" ]] || {
BUILD_PATH="$(dirname "$(dirname "${ARANGOSH}")")"
BUILD_PATH="${BUILD_PATH#${EXEC_PATH}/}"
if test -n "$ORIGINAL_PATH"; then
# running in cygwin...
BUILD_PATH=$(cygpath --windows "$BUILD_PATH")
fi
EXTRA_ARGS=("--build" "${BUILD_PATH}")
}
(
cd "${EXEC_PATH}"
exec $NUMA $ARANGOSH \
-c etc${PS}relative${PS}arangosh.conf \
--log.level warning \
--server.endpoint tcp://127.0.0.1:${PORT} \
--javascript.allow-external-process-control true \
--javascript.execute UnitTests${PS}unittest.js \
-- \
"$@" "${EXTRA_ARGS[@]}"
)