go-test
Options for Go tests.
Backend: pants.backend.experimental.go
Config section: [go-test]
Basic options
args
--go-test-args="[<shell_str>, <shell_str>, ...]", ... -- [<shell_str> [<shell_str> [...]]]PANTS_GO_TEST_ARGS[go-test]
args = [
<shell_str>,
<shell_str>,
...,
]
[]Arguments to pass directly to Go test binary, e.g. --go-test-args='-run TestFoo -v'.
Known Go test options will be transformed into the form expected by the test binary, e.g. -v becomes -test.v. Run go help testflag from the Go SDK to learn more about the options supported by Go test binaries.
block_profile
--[no-]go-test-block-profilePANTS_GO_TEST_BLOCK_PROFILE[go-test]
block_profile = <bool>
FalseCapture a goroutine blocking profile from the execution of the test runner. The profile will be written to the file block.out in the test extra output directory. The test binary will also be written to the test extra output directory.
cover_mode
--go-test-cover-mode=<GoCoverMode>PANTS_GO_TEST_COVER_MODE[go-test]
cover_mode = <GoCoverMode>
set, count, atomicdefault:
setCoverage mode to use when running Go tests with coverage analysis enabled via --test-use-coverage. Valid values are set, count, and atomic:
set: bool: does this statement run?count: int: how many times does this statement run?atomic: int: count, but correct in multithreaded tests; significantly more expensive.
coverage_html
--[no-]go-test-coverage-htmlPANTS_GO_TEST_COVERAGE_HTML[go-test]
coverage_html = <bool>
TrueIf true, then convert coverage reports to HTML format and write a coverage.html file next to the raw coverage data.
coverage_packages
--go-test-coverage-packages="['<str>', '<str>', ...]"PANTS_GO_TEST_COVERAGE_PACKAGES[go-test]
coverage_packages = [
'<str>',
'<str>',
...,
]
[]A list of "import path patterns" for determining which import paths will be instrumented for code coverage.
From go help packages:
An import path is a pattern if it includes one or more "..." wildcards, each of which can match any string, including the empty string and strings containing slashes. Such a pattern expands to all package directories found in the GOPATH trees with names matching the patterns.
To make common patterns more convenient, there are two special cases. First, /... at the end of the pattern can match an empty string, so that net/... matches both net and packages in its subdirectories, like net/http. Second, any slash-separated pattern element containing a wildcard never participates in a match of the "vendor" element in the path of a vendored package, so that ./... does not match packages in subdirectories of ./vendor or ./mycode/vendor, but ./vendor/... and ./mycode/vendor/... do. Note, however, that a directory named vendor that itself contains code is not a vendored package: cmd/vendor would be a command named vendor, and the pattern cmd/... matches it. See golang.org/s/go15vendor for more about vendoring.
This option is similar to the go test -coverpkg option, but without support currently for reserved import path patterns like std and all.
cpu_profile
--[no-]go-test-cpu-profilePANTS_GO_TEST_CPU_PROFILE[go-test]
cpu_profile = <bool>
FalseCapture a CPU profile from the execution of the test runner. The profile will be written to the file cpu.out in the test extra output directory. The test binary will also be written to the test extra output directory.
force_asan
--[no-]go-test-force-asanPANTS_GO_TEST_FORCE_ASAN[go-test]
force_asan = <bool>
FalseIf true, then always enable interoperation between Go and the C/C++ "address sanitizer" when running tests regardless of the test-by-test asan field on the relevant go_package target.
See https://github.com/google/sanitizers/wiki/AddressSanitizer for additional information about the C/C++ address sanitizer.
force_msan
--[no-]go-test-force-msanPANTS_GO_TEST_FORCE_MSAN[go-test]
force_msan = <bool>
FalseIf true, then always enable interoperation between Go and the C/C++ "memory sanitizer" when running tests regardless of the test-by-test msan field on the relevant go_package target.
See https://github.com/google/sanitizers/wiki/MemorySanitizer for additional information about the C/C++ memory sanitizer.
force_race
--[no-]go-test-force-racePANTS_GO_TEST_FORCE_RACE[go-test]
force_race = <bool>
FalseIf true, then always enable the Go data race detector when running tests regardless of the test-by-test test_race field on the relevant go_package target.
See https://go.dev/doc/articles/race_detector for additional information about the Go data race detector.
mem_profile
--[no-]go-test-mem-profilePANTS_GO_TEST_MEM_PROFILE[go-test]
mem_profile = <bool>
FalseCapture an allocation profile from the execution of the test runner after tests have passed. The profile will be written to the file mem.out in the test extra output directory. The test binary will also be written to the test extra output directory.
mutex_profile
--[no-]go-test-mutex-profilePANTS_GO_TEST_MUTEX_PROFILE[go-test]
mutex_profile = <bool>
FalseCapture a mutex contention profile from the execution of the test runner when all tests are complete. The profile will be written to the file mutex.out in the test extra output directory. The test binary will also be written to the test extra output directory.
skip
--[no-]go-test-skipPANTS_GO_TEST_SKIP[go-test]
skip = <bool>
FalseIf true, don't use Go test binary when running pants test.
trace
--[no-]go-test-tracePANTS_GO_TEST_TRACE[go-test]
trace = <bool>
FalseCapture an execution trace from the execution of the test runner. The trace will be written to the file trace.out in the test extra output directory.
Advanced options
coverage_output_dir
--go-test-coverage-output-dir=<str>PANTS_GO_TEST_COVERAGE_OUTPUT_DIR[go-test]
coverage_output_dir = <str>
{distdir}/coverage/go/{target_spec}Path to write the Go coverage reports to. Must be relative to the build root.
Replacements:
{distdir}is replaced with the Pantsdistdir.{target_spec}is replaced with the address of the applicablego_packagetarget with/characters replaced with dots (.).{import_path}is replaced with the applicable package's import path. Subdirectories will be made for any path components separated by/characters.{import_path_escaped}is replaced with the applicable package's import path but with slashes converted to underscores. This is deprecated and only exists to support behavior from earlier versions.
output_test_binary
--[no-]go-test-output-test-binaryPANTS_GO_TEST_OUTPUT_TEST_BINARY[go-test]
output_test_binary = <bool>
FalseWrite the test binary to the test extra output directory.
This is similar to the go test -c option, but will still run the underlying test.
Deprecated options
None
Related subsystems
None