github.com/lestrrat-go/jwx/v2@v2.0.21/tools/test.sh (about)

     1  #!/bin/bash
     2  
     3  ROOT=$(cd $(dirname $0)/..; pwd -P)
     4  DST="$ROOT/coverage.out"
     5  if [[ -e "$DST" ]]; then
     6  	rm "$DST"
     7  fi
     8  
     9  testopts=($TESTOPTS)
    10  
    11  tmpfile=coverage.out.tmp
    12  case "$MODE" in
    13  	"cover")
    14  		testopts+=("-coverpkg=./...")
    15  		testopts+=("-coverprofile=$tmpfile")
    16  		;;
    17  	"short")
    18  		testopts+=("-short")
    19  		;;
    20  esac
    21  
    22  failures=0
    23  echo "mode: atomic" > "$DST"
    24  for dir in . ./examples ./bench/performance ./cmd/jwx; do
    25  	testout=$(mktemp /tmp/jwx-test.XXXXX)
    26  	pushd "$dir" > /dev/null
    27  	go test -race -json ${testopts[@]} ./... > $testout
    28  	if [[ "$?" != "0" ]]; then
    29  		failures=$((failures+1))
    30  	fi
    31  	tparse -file="$testout"
    32  	rm "$testout"
    33  	if [[ -e "$tmpfile" ]]; then
    34  		cat "$tmpfile" | tail -n +2 | grep -v "internal/jose" | grep -v "internal/jwxtest" | grep -v "internal/cmd" >> "$DST"
    35  		rm "$tmpfile"
    36  	fi
    37  	popd > /dev/null
    38  done
    39  
    40  if [[ "$failures" != "0" ]]; then
    41  	exit 1
    42  fi