test_shell_command
Run a script as a test via the test
goal, with all dependencies packaged/copied available in the chroot.
Example BUILD file:
test_shell_command(
name="test",
tools=["test"],
command="test -r $CHROOT/some-data-file.txt",
execution_dependencies=["src/project/files:data"],
)
The command
may use the {chroot}
marker on the command line or in environment variables to get the root directory where any dependencies are materialized during execution.
In contrast to the run_shell_command
, this target is intended to run shell commands as tests and will only run them via the test
goal.
Backend: pants.backend.shell
command
str
Shell command to execute.
The command is executed as 'bash -c <command>'
by default. If you want to invoke a binary use exec -a $0 <binary> <args>
as the command so that the binary gets the correct argv[0]
set.
description
str | None
None
A human-readable description of the target.
Use pants list --documented ::
to see all targets with descriptions.
environment
str | None
'__local__'
Specify which environment target to consume environment-sensitive options from.
Once environments are defined in [environments-preview].names
, you can specify the environment for this target by its name. Any fields that are defined in that environment will override the values from options set by pants.toml
, command line values, or environment variables.
You can specify multiple valid environments by using parametrize
. If __local__
is specified, Pants will fall back to the local_environment
defined for the current platform, or no environment if no such environment exists.
execution_dependencies
Iterable[str] | None
None
The execution dependencies for this command.
Dependencies specified here are those required to make the command complete successfully (e.g. file inputs, packages compiled from other targets, etc), but NOT required to make the outputs of the command useful. Dependencies that are required to use the outputs produced by this command should be specified using the output_dependencies
field.
If this field is specified, dependencies from output_dependencies
will not be added to the execution sandbox.
See also output_dependencies
and runnable_dependencies
.
extra_env_vars
Iterable[str] | None
None
Additional environment variables to provide to the process.
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. fnmatch
globs like ENV_VAR_PREFIXED_*
can be used to copy multiple environment variables.
log_output
bool
False
Set to true if you want the output logged to the console.
output_directories
Iterable[str] | None
()
Specify full directories (including recursive descendants) of output to capture, relative to the value of workdir
.
For individual files, use output_files
. At least one of output_files
andoutput_directories
must be specified.
Relative paths (including ..
) may be used, as long as the path does not ascend further than the build root.
output_files
Iterable[str] | None
()
Specify the output files to capture, relative to the value of workdir
.
For directories, use output_directories
. At least one of output_files
andoutput_directories
must be specified.
Relative paths (including ..
) may be used, as long as the path does not ascend further than the build root.
outputs_match_mode
'all' | 'all_warn' | 'allow_empty' | 'at_least_one' | 'at_least_one_warn' | None
'all_warn'
Configure whether all, or some, of the values in the output_files
and output_directories
fields must actually match the outputs generated by the invoked process. These values are called "globs". Outputs may be matched by more than one glob.
Valid values are:
-
all_warn
: Log a warning if any glob fails to match an output. (In other words, all globs must match to avoid a warning.) This is the default value. -
all
: Ensure all globs match an output or else raise an error. -
at_least_one_warn
: Log a warning if none of the globs match an output. -
at_least_one
: Ensure at least one glob matches an output or else raise an error. -
allow_empty
: Allow empty digests (which means nothing was captured). This disables checking that globs match outputs.
path_env_modify
'append' | 'off' | 'prepend' | None
'prepend'
When executing the command of an adhoc_tool
or shell_command
target, Pants may augment the PATH
environment variable with the location of any binary shims created for tools
and for any runnable dependencies.
Modification of the PATH
environment variable can be configured as follows: - prepend
: Prepend the extra path components to any existing PATH
value. - append
: Append the extra path componenets to any existing PATH
value. - off
: Do not modify the existing PATH
value.
root_output_directory
str | None
'/'
Adjusts the location of files output by this target, when consumed as a dependency.
Values are relative to the build root, except in the following cases:
.
specifies the location of theBUILD
file.- Values beginning with
./
are relative to the location of theBUILD
file. /
or the empty string specifies the build root.- Values beginning with
/
are also relative to the build root.
runnable_dependencies
Iterable[str] | None
None
The runnable dependencies for this command.
Dependencies specified here are those required to exist on the PATH
to make the command complete successfully (interpreters specified in a #!
command, etc). Note that these dependencies will be made available on the PATH
with the name of the target.
See also output_dependencies
and execution_dependencies
.