Skip to content

Commit 9ccd114

Browse files
committed
Make test scripts more POSIX-friendly
1 parent 769f732 commit 9ccd114

File tree

2 files changed

+17
-15
lines changed

2 files changed

+17
-15
lines changed

tests/bin/run-tests-docker.sh

+8-7
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
1-
#!/usr/bin/env bash
1+
#!/usr/bin/env sh
2+
23
set -eu
34
unset CDPATH
4-
cd "$( dirname "${BASH_SOURCE[0]}" )/../.."
5+
cd "$( dirname "$0" )/../.."
56

67

7-
function usage() {
8+
usage() {
89
cat >&2 <<EOF
910
Build scitran-core image and run tests in a docker container
1011
@@ -20,11 +21,11 @@ EOF
2021
}
2122

2223

23-
function main() {
24+
main() {
2425
local DOCKER_BUILD=true
2526
local TEST_ARGS=
2627

27-
while [[ "$#" > 0 ]]; do
28+
while [ $# -gt 0 ]; do
2829
case "$1" in
2930
-B|--no-build) DOCKER_BUILD=false; ;;
3031
-h|--help) usage; exit 0 ;;
@@ -56,14 +57,14 @@ function main() {
5657
-e SCITRAN_PERSISTENT_DB_URI=mongodb://scitran-core-test-mongo:27017/scitran \
5758
-e SCITRAN_PERSISTENT_DB_LOG_URI=mongodb://scitran-core-test-mongo:27017/logs \
5859
-v $(pwd):/var/scitran/code/api \
59-
--entrypoint bash \
60+
--entrypoint sh \
6061
scitran-core:run-tests \
6162
/var/scitran/code/api/tests/bin/run-tests-ubuntu.sh \
6263
$TEST_ARGS
6364
}
6465

6566

66-
function clean_up() {
67+
clean_up() {
6768
local TEST_RESULT_CODE=$?
6869
set +e
6970

tests/bin/run-tests-ubuntu.sh

+9-8
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
1-
#!/usr/bin/env bash
1+
#!/usr/bin/env sh
2+
23
set -eu
34
unset CDPATH
4-
cd "$( dirname "${BASH_SOURCE[0]}" )/../.."
5+
cd "$( dirname "$0" )/../.."
56

67

7-
function usage() {
8+
usage() {
89
cat >&2 <<EOF
910
Run scitran-core tests
1011
@@ -35,15 +36,15 @@ EOF
3536
}
3637

3738

38-
function main() {
39+
main() {
3940
export RUN_ALL=true
4041
local RUN_LINT=false
4142
local RUN_UNIT=false
4243
local RUN_INTEG=false
4344
local RUN_ABAO=false
4445
local PYTEST_ARGS=
4546

46-
while [[ "$#" > 0 ]]; do
47+
while [ $# -gt 0 ]; do
4748
case "$1" in
4849
-l|--lint) RUN_ALL=false; RUN_LINT=true ;;
4950
-u|--unit) RUN_ALL=false; RUN_UNIT=true ;;
@@ -82,7 +83,7 @@ function main() {
8283
export SCITRAN_PERSISTENT_DB_LOG_URI=${SCITRAN_PERSISTENT_DB_LOG_URI:-"mongodb://localhost:$SCITRAN_PERSISTENT_DB_PORT/logs"}
8384
export SCITRAN_PERSISTENT_PATH=`mktemp -d`
8485
export SCITRAN_PERSISTENT_DATA_PATH="$SCITRAN_PERSISTENT_PATH/data"
85-
export SCITRAN_CORE_DRONE_SECRET=${SCITRAN_CORE_DRONE_SECRET:-$( openssl rand -base64 32 )}
86+
export SCITRAN_CORE_DRONE_SECRET=${SCITRAN_CORE_DRONE_SECRET:-T+27oHSKw+WQqT/rre+iaiIY4vNzav/fPStHqW/Eczk=}
8687

8788
if ${RUN_LINT}; then
8889
echo "Running pylint ..."
@@ -158,14 +159,14 @@ function main() {
158159
}
159160

160161

161-
function clean_up () {
162+
clean_up() {
162163
local TEST_RESULT_CODE=$?
163164
set +e
164165

165166
echo
166167
echo "Test return code = $TEST_RESULT_CODE"
167168

168-
if [[ -n "${API_PID:-}" ]]; then
169+
if [ "${API_PID:-}" ]; then
169170
# Killing uwsgi
170171
kill $API_PID
171172
wait 2> /dev/null

0 commit comments

Comments
 (0)