Files
mattermost/scripts/test.sh
Agniva De Sarker a83df931b9 Replace pipe with redirection to a subshell (#13409)
When the writing process sends an EAGAIN to the fd, tee dies.
We correct this behavior by redirecting the output to a subshell
which handles this correctly.

Relevant link here: https://serverfault.com/questions/369757/why-is-this-tee-losing-stdout
2019-12-17 14:58:25 +01:00

28 lines
741 B
Bash
Executable File

#!/usr/bin/env bash
set -o pipefail
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null && pwd )"
GO=$1
GOFLAGS=$2
PACKAGES=$3
TESTS=$4
TESTFLAGS=$5
PACKAGES_COMMA=$(echo $PACKAGES | tr ' ' ',')
echo "Packages to test: $PACKAGES"
find . -name 'cprofile*.out' -exec sh -c 'rm "{}"' \;
find . -type d -name data -not -path './vendor/*' | xargs rm -rf
$GO test $GOFLAGS -run=$TESTS $TESTFLAGS -v -timeout=2000s -covermode=count -coverpkg=$PACKAGES_COMMA -exec $DIR/test-xprog.sh $PACKAGES 2>&1 > >( tee output )
EXIT_STATUS=$?
cat output | $GOPATH/bin/go-junit-report > report.xml
rm output
find . -name 'cprofile*.out' -exec sh -c 'tail -n +2 "{}" >> cover.out ; rm "{}"' \;
rm -f config/*.crt
rm -f config/*.key
exit $EXIT_STATUS