Skip to content

Commit

Permalink
Make test scripts more POSIX-friendly
Browse files Browse the repository at this point in the history
  • Loading branch information
ambrussimon committed Nov 17, 2017
1 parent 769f732 commit 0c74af1
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 13 deletions.
15 changes: 8 additions & 7 deletions tests/bin/run-tests-docker.sh
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
#!/usr/bin/env bash
#!/usr/bin/env sh

set -eu
unset CDPATH
cd "$( dirname "${BASH_SOURCE[0]}" )/../.."
cd "$( dirname "$0" )/../.."


function usage() {
usage() {
cat >&2 <<EOF
Build scitran-core image and run tests in a docker container
Expand All @@ -20,11 +21,11 @@ EOF
}


function main() {
main() {
local DOCKER_BUILD=true
local TEST_ARGS=

while [[ "$#" > 0 ]]; do
while [ $# -gt 0 ]; do
case "$1" in
-B|--no-build) DOCKER_BUILD=false; ;;
-h|--help) usage; exit 0 ;;
Expand Down Expand Up @@ -56,14 +57,14 @@ function main() {
-e SCITRAN_PERSISTENT_DB_URI=mongodb://scitran-core-test-mongo:27017/scitran \
-e SCITRAN_PERSISTENT_DB_LOG_URI=mongodb://scitran-core-test-mongo:27017/logs \
-v $(pwd):/var/scitran/code/api \
--entrypoint bash \
--entrypoint sh \
scitran-core:run-tests \
/var/scitran/code/api/tests/bin/run-tests-ubuntu.sh \
$TEST_ARGS
}


function clean_up() {
clean_up() {
local TEST_RESULT_CODE=$?
set +e

Expand Down
13 changes: 7 additions & 6 deletions tests/bin/run-tests-ubuntu.sh
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
#!/usr/bin/env bash
#!/usr/bin/env sh

set -eu
unset CDPATH
cd "$( dirname "${BASH_SOURCE[0]}" )/../.."


function usage() {
usage() {
cat >&2 <<EOF
Run scitran-core tests
Expand Down Expand Up @@ -35,15 +36,15 @@ EOF
}


function main() {
main() {
export RUN_ALL=true
local RUN_LINT=false
local RUN_UNIT=false
local RUN_INTEG=false
local RUN_ABAO=false
local PYTEST_ARGS=

while [[ "$#" > 0 ]]; do
while [ $# -gt 0 ]; do
case "$1" in
-l|--lint) RUN_ALL=false; RUN_LINT=true ;;
-u|--unit) RUN_ALL=false; RUN_UNIT=true ;;
Expand Down Expand Up @@ -158,14 +159,14 @@ function main() {
}


function clean_up () {
clean_up() {
local TEST_RESULT_CODE=$?
set +e

echo
echo "Test return code = $TEST_RESULT_CODE"

if [[ -n "${API_PID:-}" ]]; then
if [ "${API_PID:-}" ]; then
# Killing uwsgi
kill $API_PID
wait 2> /dev/null
Expand Down

0 comments on commit 0c74af1

Please sign in to comment.