forked from mongodb/mongo-tools-common
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrunTests.sh
More file actions
executable file
·65 lines (55 loc) · 1.86 KB
/
runTests.sh
File metadata and controls
executable file
·65 lines (55 loc) · 1.86 KB
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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
#!/bin/bash
tags=""
if [ ! -z "$1" ]
then
tags="$@"
fi
# make sure we're in the directory where the script lives
SCRIPT_DIR="$(cd "$(dirname ${BASH_SOURCE[0]})" && pwd)"
cd $SCRIPT_DIR
OUTPUT_DIR="$SCRIPT_DIR/testing_output"
mkdir -p "$OUTPUT_DIR"
. ./set_goenv.sh
set_goenv || exit
# remove stale packages
rm -rf vendor/pkg
if [ "${TOOLS_TESTING_AWS_AUTH}" = "true" ]; then
echo "Running MONGODB-AWS authentication tests"
# load the script
shopt -s expand_aliases # needed for `urlencode` alias
[ -s "$(pwd)/prepare_mongodb_aws.sh" ] && source "$(pwd)/prepare_mongodb_aws.sh"
MONGODB_URI=${MONGODB_URI:-"mongodb://localhost"}
MONGODB_URI="${MONGODB_URI}:33333/aws?authMechanism=MONGODB-AWS"
if [[ -n ${SESSION_TOKEN} ]]; then
MONGODB_URI="${MONGODB_URI}&authMechanismProperties=AWS_SESSION_TOKEN:${SESSION_TOKEN}"
fi
fi;
export MONGOD=$MONGODB_URI
ec=0
# Run all tests depending on what flags are set in the environment
for i in $(find . -iname *.go | grep -v '^\./vendor/' | sed -e 's/\(.*\)\/.*\.go/\1/' | sort -u); do
echo "Testing ${i}/..."
COMMON_SUBPKG=$(basename $i)
COVERAGE_ARGS="";
if [ "$RUN_COVERAGE" = "true" ]; then
export COVERAGE_ARGS="-coverprofile=coverage_$COMMON_SUBPKG.out"
fi
if [ "$ON_EVERGREEN" = "true" ]; then
(cd $i && go test "$(print_tags $tags)" "$COVERAGE_ARGS" > "$OUTPUT_DIR/$COMMON_SUBPKG.suite")
exitcode=$?
cat "$OUTPUT_DIR/$COMMON_SUBPKG.suite"
# Evergreen looks for test files here
cp "$OUTPUT_DIR/$COMMON_SUBPKG.suite" "$SCRIPT_DIR"
else
(cd $i && go test "$(print_tags $tags)" "$COVERAGE_ARGS" )
exitcode=$?
fi
if [ $exitcode -ne 0 ]; then
echo "Error testing $i"
ec=1
fi
done
if [ -t /dev/stdin ]; then
stty sane
fi
exit $ec