vspd/run_tests.sh
Jamie Holdstock 42d91752f5 build: Rename root pkg path vars.
This renames the variables in the script that runs tests against all
modules to better reflect reality as of the latest versions of Go.

In particular, instead of referring to `ROOTPATH`, it now uses `ROOTPKG`
to better indicate that it is the name of root package as opposed to a
file path to it.
2022-11-26 09:46:36 +08:00

40 lines
886 B
Bash
Executable File

#!/bin/bash
#
# Copyright (c) 2020-2022 The Decred developers
# Use of this source code is governed by an ISC
# license that can be found in the LICENSE file.
#
# usage:
# ./run_tests.sh
set -e
go version
# run tests on all modules
ROOTPKG=$(go list -m)
ROOTPKGPATTERN=$(echo $ROOTPKG | sed 's/\\/\\\\/g' | sed 's/\//\\\//g')
MODPATHS=$(go list -m all | grep "^$ROOTPKGPATTERN" | cut -d' ' -f1)
for module in $MODPATHS; do
echo "==> ${module}"
env GORACE="halt_on_error=1" go test -race ${module}/...
# check linters
MODNAME=$(echo $module | sed -E -e "s/^$ROOTPKGPATTERN//" \
-e 's,^/,,' -e 's,/v[0-9]+$,,')
if [ -z "$MODNAME" ]; then
MODNAME=.
fi
# run commands in the module directory as a subshell
(
cd $MODNAME
# run linter
golangci-lint run
)
done
echo "------------------------------------------"
echo "Tests completed successfully!"