forked from mongodb/mongo-tools
-
Notifications
You must be signed in to change notification settings - Fork 0
/
runTests.sh
executable file
·52 lines (45 loc) · 1.53 KB
/
runTests.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
50
51
52
#!/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
# build binaries for any tests that expect them for blackbox testing
./build.sh $tags
ec=0
# Run all tests depending on what flags are set in the environment
# TODO: mongotop needs a test
# Note: Does not test mongoreplay
for i in legacy/failpoint legacy/json legacy/log legacy/options legacy/util mongostat mongofiles mongoexport mongoimport mongorestore mongodump mongotop bsondump ; 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 $(buildflags) -ldflags "$(print_ldflags)" $tags -tags "$(print_tags $TOOLS_BUILD_TAGS)" "$COVERAGE_ARGS" > "$OUTPUT_DIR/$COMMON_SUBPKG.suite")
exitcode=$?
cat "$OUTPUT_DIR/$COMMON_SUBPKG.suite"
else
(cd $i && go test $(buildflags) -ldflags "$(print_ldflags)" "$(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