github.com/haalcala/mattermost-server-change-repo@v0.0.0-20210713015153-16753fbeee5f/scripts/test.sh (about)

     1  #!/usr/bin/env bash
     2  set -o pipefail
     3  
     4  DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null && pwd )"
     5  
     6  GO=$1
     7  GOFLAGS=$2
     8  PACKAGES=$3
     9  TESTS=$4
    10  TESTFLAGS=$5
    11  GOBIN=$6
    12  
    13  PACKAGES_COMMA=$(echo $PACKAGES | tr ' ' ',')
    14  
    15  echo "Packages to test: $PACKAGES"
    16  find . -name 'cprofile*.out' -exec sh -c 'rm "{}"' \;
    17  find . -type d -name data -not -path './vendor/*' -not -path './data' | xargs rm -rf
    18  
    19  $GO test $GOFLAGS -run=$TESTS $TESTFLAGS -v -timeout=20m -covermode=count -coverpkg=$PACKAGES_COMMA -exec $DIR/test-xprog.sh $PACKAGES 2>&1 > >( tee output )
    20  EXIT_STATUS=$?
    21  
    22  cat output | $GOBIN/go-junit-report > report.xml
    23  rm output
    24  find . -name 'cprofile*.out' -exec sh -c 'tail -n +2 "{}" >> cover.out ; rm "{}"' \;
    25  rm -f config/*.crt
    26  rm -f config/*.key
    27  
    28  exit $EXIT_STATUS