test
pants test [args]
Run tests.
Backend: pants.core
Config section: [test]
Basic options
attempts_default
--test-attempts-default=<int>PANTS_TEST_ATTEMPTS_DEFAULT[test]
attempts_default = <int>
1The number of attempts to run tests, in case of a test failure. Tests that were retried will include the number of attempts in the summary output.
debug
--[no-]test-debugPANTS_TEST_DEBUG[test]
debug = <bool>
FalseRun tests sequentially in an interactive process. This is necessary, for example, when you add breakpoints to your code.
debug_adapter
--[no-]test-debug-adapterPANTS_TEST_DEBUG_ADAPTER[test]
debug_adapter = <bool>
FalseRun tests sequentially in an interactive process, using a Debug Adapter (https://microsoft.github.io/debug-adapter-protocol/) for the language if supported.
The interactive process used will be immediately blocked waiting for a client before continuing.
This option implies --debug.
extra_env_vars
--test-extra-env-vars="['<str>', '<str>', ...]"PANTS_TEST_EXTRA_ENV_VARS[test]
extra_env_vars = [
'<str>',
'<str>',
...,
]
[]Additional environment variables to include in test processes. Entries are strings in the form ENV_VAR=value to use explicitly; or just ENV_VAR to copy the value of a variable in Pants's own environment.
test_extra_env_vars on local_environment, docker_environment, or remote_environmenttargets.force
--[no-]test-forcePANTS_TEST_FORCE[test]
force = <bool>
FalseForce the tests to run, even if they could be satisfied from cache.
open_coverage
--[no-]test-open-coveragePANTS_TEST_OPEN_COVERAGE[test]
open_coverage = <bool>
FalseIf a coverage report file is generated, open it on the local system if the system supports this.
output
--test-output=<ShowOutput>PANTS_TEST_OUTPUT[test]
output = <ShowOutput>
all, failed, nonedefault:
failedShow stdout/stderr for these tests.
shard
--test-shard=<str>PANTS_TEST_SHARD[test]
shard = <str>
A shard specification of the form "k/N", where N is a positive integer and k is a non-negative integer less than N.
If set, the request input targets will be deterministically partitioned into N disjoint subsets of roughly equal size, and only the k'th subset will be used, with all others discarded.
Useful for splitting large numbers of test files across multiple machines in CI. For example, you can run three shards with --shard=0/3, --shard=1/3, --shard=2/3.
Note that the shards are roughly equal in size as measured by number of files. No attempt is made to consider the size of different files, the time they have taken to run in the past, or other such sophisticated measures.
timeouts
--[no-]test-timeoutsPANTS_TEST_TIMEOUTS[test]
timeouts = <bool>
TrueEnable test target timeouts. If timeouts are enabled then test targets with a timeout= parameter set on their target will time out after the given number of seconds if not completed. If no timeout is set, then either the default timeout is used or no timeout is configured.
use_coverage
--[no-]test-use-coveragePANTS_TEST_USE_COVERAGE[test]
use_coverage = <bool>
FalseGenerate a coverage report if the test runner supports it.
Advanced options
batch_size
--test-batch-size=<int>PANTS_TEST_BATCH_SIZE[test]
batch_size = <int>
128The target maximum number of files to be included in each run of batch-enabled test runners.
Some test runners can execute tests from multiple files in a single run. Test implementations will return all tests that can run together as a single group - and then this may be further divided into smaller batches, based on this option. This is done:
- to avoid OS argument length limits (in processes which don't support argument files)
- to support more stable cache keys than would be possible if all files were operated on in a single batch
- to allow for parallelism in test runners which don't have internal parallelism, or -- if they do support internal parallelism -- to improve scheduling behavior when multiple processes are competing for cores and so internal parallelism cannot be used perfectly
In order to improve cache hit rates (see 2.), batches are created at stable boundaries, and so this value is only a "target" max batch size (rather than an exact value).
NOTE: This parameter has no effect on test runners/plugins that do not implement support for batched testing.
experimental_report_test_result_info
--[no-]test-experimental-report-test-result-infoPANTS_TEST_EXPERIMENTAL_REPORT_TEST_RESULT_INFO[test]
experimental_report_test_result_info = <bool>
FalseReport information about the test results.
For now, it reports only the source from where the test results were fetched. When running tests, they may be executed locally or remotely, but if there are results of previous runs available, they may be retrieved from the local or remote cache, or be memoized. Knowing where the test results come from might be useful when evaluating the efficiency of the cache and the nature of the changes in the source code that may lead to frequent cache invalidations.
report
--[no-]test-reportPANTS_TEST_REPORT[test]
report = <bool>
FalseWrite test reports to --report-dir.
report_dir
--test-report-dir=<str>PANTS_TEST_REPORT_DIR[test]
report_dir = <str>
{distdir}/test/reportsPath to write test reports to. Must be relative to the build root.
show_rerun_command
--[no-]test-show-rerun-commandPANTS_TEST_SHOW_RERUN_COMMAND[test]
show_rerun_command = <bool>
TrueIf tests fail, show an appropriate pants test ... invocation to rerun just those tests.
This is to make it easy to run those tests on a new machine (for instance, run tests locally if they fail in CI): caching of successful tests means that rerunning the exact same command on the same machine will already automatically only rerun the failures.
This defaults to True when running in CI (as determined by the CI environment variable being set) but False elsewhere.
timeout_default
--test-timeout-default=<int>PANTS_TEST_TIMEOUT_DEFAULT[test]
timeout_default = <int>
NoneThe default timeout (in seconds) for a test target if the timeout field is not set on the target.
timeout_maximum
--test-timeout-maximum=<int>PANTS_TEST_TIMEOUT_MAXIMUM[test]
timeout_maximum = <int>
NoneThe maximum timeout (in seconds) that may be used on a test target.
Deprecated options
None