gentle-flower-25372
04/03/2024, 9:20 PM# pants.toml
[pytest]
args = ["-m", "not integration"]
How it's being picked up and processed by the runner (it's splitting the one arg into two):
"./pytest_runner.pex_pex_shim.sh", "-m", "not", "integration"
broad-processor-92400
04/03/2024, 9:59 PMPyTest
subsystem's args
-> ArgListOption
-> ShellStrListOption
-> uses of shell_str
-> https://github.com/pantsbuild/pants/blob/2e010cd20a3b1cf2586923ee2863dd1be5f5497d/src/python/pants/option/custom_types.py#L194-L199
indicates that it's apparently intentionally splitting up each element of the list with shlex.split
, so to fix your immediate problem args = ["-m", "'not integration'"]
likely works.
It's... unconventional that it takes a list of args, but still splits each element!gentle-flower-25372
04/03/2024, 10:47 PMwide-midnight-78598
04/03/2024, 10:50 PMunconventional that it takes a list of args, but still splits each element!I was gonna say the opposite - most command lines/tooling I've used do something similar. I just always assumed it was a bash thing in the end which required the double escapes
gentle-flower-25372
04/03/2024, 10:55 PMbroad-processor-92400
04/03/2024, 11:13 PMbash -c ...
)
2. an array, where each element is taken literally
Two examples:
• Python's subprocess.run
(https://docs.python.org/3/library/subprocess.html#subprocess.run) has:
a. 1 with shell=True
: subprocess.run("echo hello", shell=True)
passes that string as is to a shell, and so runs echo
with arg hello
b. 2 with the default shell=False
: subprocess.run(["echo hello"])
attempts to run a binary called echo hello
, which likely doesn't exist
• Docker RUN
and other similar commands (https://docs.docker.com/reference/dockerfile/#shell-and-exec-form) has:
◦ 1 when passed text directly: RUN echo hello
◦ 2 when passed an array: RUN ["echo hello"]
Pants is doing a third thing, where it takes an array but splits each element, so ["echo hello"]
is equivalent to ["echo", "hello"]
.wide-midnight-78598
04/03/2024, 11:28 PM