When editing a lot of areas of the Juju source code, sometimes you just want to know did I break any other tests inside Juju without running go test -v ./... -check.v
in the root of the project.
One solution that I’m playing around with is taking advantage of -c
argument to go test
.
The following script runs and compiles the test code without running any tests:
Note: the script will use all your CPUs minus 1, so your system won’t come to a halt.
#!/bin/bash
# Copyright 2019 Canonical Ltd.
# Licensed under the AGPLv3, see LICENCE file for details.
go_test () {
go test -c -run=nope $1
}
export -f go_test
MAX_CPU="$(($(nproc --all)-1))"
go list -f '{{.Dir}}' github.com/juju/juju/... | xargs -n 1 -P $MAX_CPU bash -c 'go_test "$@"' --
Although it’s slow, it’s still faster than running CI to check the damage or using go test -v ./... -check.v