decred.org/dcrdex@v1.0.5/run_tests.sh (about)

     1  #!/usr/bin/env bash
     2  set -ex
     3  
     4  dir=$(pwd)
     5  
     6  GV=$(go version | sed "s/^.*go\([0-9.]*\).*/\1/")
     7  echo "Go version: $GV"
     8  
     9  # Ensure html templates pass localization.
    10  go generate -x ./client/webserver/site # no -write
    11  
    12  # list of all modules to test
    13  modules=". /dex/testing/loadbot /client/cmd/bisonw-desktop"
    14  
    15  # For each module, run go mod tidy, build and run test.
    16  for m in $modules
    17  do
    18  	cd "$dir/$m"
    19  
    20  	# Run `go mod tidy` and fail if the git status of go.mod and/or
    21  	# go.sum changes. Only do this for the latest Go version.
    22  	if [[ "$GV" =~ ^1.25 ]]; then
    23  		MOD_STATUS=$(git status --porcelain go.mod go.sum)
    24  		go mod tidy
    25  		UPDATED_MOD_STATUS=$(git status --porcelain go.mod go.sum)
    26  		if [ "$UPDATED_MOD_STATUS" != "$MOD_STATUS" ]; then
    27  			echo "$m: running 'go mod tidy' modified go.mod and/or go.sum"
    28  		git diff --unified=0 go.mod go.sum
    29  			exit 1
    30  		fi
    31  	fi
    32  
    33  	# run tests
    34  	env GORACE="halt_on_error=1" go test -race -short ./...
    35  done
    36  
    37  cd "$dir"
    38  
    39  # Print missing Core notification translations.
    40  go run ./client/core/localetest/main.go
    41  
    42  # -race in go tests above requires cgo, but disable it for the compile tests below
    43  export CGO_ENABLED=0
    44  go build ./...
    45  go build -tags harness -o /dev/null ./client/cmd/simnet-trade-tests
    46  go build -tags systray -o /dev/null ./client/cmd/bisonw
    47  
    48  go test -c -o /dev/null -tags live ./client/webserver
    49  go test -c -o /dev/null -tags harness ./client/asset/dcr
    50  go test -c -o /dev/null -tags electrumlive ./client/asset/btc
    51  go test -c -o /dev/null -tags harness ./client/asset/btc/livetest
    52  go test -c -o /dev/null -tags harness ./client/asset/ltc
    53  go test -c -o /dev/null -tags harness ./client/asset/bch
    54  go test -c -o /dev/null -tags harness ./client/asset/firo
    55  go test -c -o /dev/null -tags harness ./client/asset/eth
    56  go test -c -o /dev/null -tags rpclive ./client/asset/eth
    57  go test -c -o /dev/null -tags harness ./client/asset/zec
    58  go test -c -o /dev/null -tags harness ./client/asset/dash
    59  go test -c -o /dev/null -tags harness ./client/asset/firo
    60  go test -c -o /dev/null -tags rpclive ./client/asset/polygon
    61  go test -c -o /dev/null -tags live ./dex/testing/firo/test
    62  go test -c -o /dev/null -tags live ./server/noderelay
    63  go test -c -o /dev/null -tags dcrlive ./server/asset/dcr
    64  go test -c -o /dev/null -tags btclive ./server/asset/btc
    65  go test -c -o /dev/null -tags ltclive ./server/asset/ltc
    66  go test -c -o /dev/null -tags bchlive ./server/asset/bch
    67  go test -c -o /dev/null -tags dogelive ./server/asset/doge
    68  go test -c -o /dev/null -tags zeclive ./server/asset/zec
    69  go test -c -o /dev/null -tags zcllive ./server/asset/zcl
    70  go test -c -o /dev/null -tags firolive ./server/asset/firo
    71  go test -c -o /dev/null -tags harness ./server/asset/eth
    72  go test -c -o /dev/null -tags pgonline ./server/db/driver/pg
    73  
    74  # Return to initial directory.
    75  cd "$dir"
    76  # golangci-lint (github.com/golangci/golangci-lint) is used to run each
    77  # static checker.
    78  
    79  # check linters
    80  golangci-lint -c ./.golangci.yml run