dazzling-diamond-4749
09/10/2021, 1:22 AMPopen and just bash. Popen(shell=True) has the same output as bash
This is how I set up the command
tag_filters = [f'--filter-tag-regex="{x}"' for x in test_group.filter_expression()]
filter_args = [
"./pants",
"filter",
"--filter-target-type=python_tests",
"--filter-granularity=file"
*tag_filters,
"::"
]
Calling with
filter_process = subprocess.Popen(
filter_args,
stdout=subprocess.PIPE,
)
Pants seems to just ignore the tags that I'm trying to filter
If I do
filter_process = subprocess.Popen(
" ".join(filter_args),
stdout=subprocess.PIPE,
shell=True,
)
the result is as expected
Maybe I'm doing something silly?hundreds-father-404
09/10/2021, 1:28 AM" " escaping? With how Python arg handling works, I suspect that Pants thinks the tag includes the " characterdazzling-diamond-4749
09/10/2021, 1:28 AMhundreds-father-404
09/10/2021, 1:29 AMfilter goal, you can leave off the filter part - --target-type instead of --filter-target-type)hundreds-father-404
09/10/2021, 1:30 AMsubprocess.run() instead of Popen might make a difference? That waits for the process to finish. (And a really nice API in general!)dazzling-diamond-4749
09/10/2021, 1:31 AMshell=Truedazzling-diamond-4749
09/10/2021, 1:31 AMdazzling-diamond-4749
09/10/2021, 1:32 AMPANTS_CONCURRENT . CI runner is triggered by ./pants run ci:runnerhundreds-father-404
09/10/2021, 1:33 AM./pants --tag=<blah blah> help global and looking at the setting for --taghundreds-father-404
09/10/2021, 1:33 AMhelp globaldazzling-diamond-4749
09/10/2021, 1:36 AMdazzling-diamond-4749
09/10/2021, 1:36 AMhundreds-father-404
09/10/2021, 1:38 AM❯ ./pants --filter-tag-regex=blah help filter
...
--filter-tag-regex="[[+-]regex1,regex2,..., [+-]regex1,regex2,..., ...]"
PANTS_FILTER_TAG_REGEX
tag_regex
default: []
current value: [
"blah"
] (from command-line flag)
Filter on targets with tags matching these regexes.
looks like that's written to stdoutdazzling-diamond-4749
09/10/2021, 1:39 AMhundreds-father-404
09/10/2021, 1:39 AMdazzling-diamond-4749
09/10/2021, 1:40 AMcurrent value: [
"-big",
"-integ",
"-manual"
] (from command-line flag)dazzling-diamond-4749
09/10/2021, 1:41 AMdazzling-diamond-4749
09/10/2021, 1:43 AMcurrent value: [
"-big",
"-integ",
"-manual"
] (from command-line flag)dazzling-diamond-4749
09/10/2021, 1:45 AMdazzling-diamond-4749
09/10/2021, 1:45 AMhundreds-father-404
09/10/2021, 1:46 AMdazzling-diamond-4749
09/10/2021, 1:46 AM"\"-big\""dazzling-diamond-4749
09/10/2021, 1:46 AMhundreds-father-404
09/10/2021, 1:47 AMdazzling-diamond-4749
09/10/2021, 1:48 AMyou have to escape with quotes when shell=False?Not sure, I was playing with a few switches at the same time. No idea which one had which effect
dazzling-diamond-4749
09/10/2021, 1:49 AMhundreds-father-404
09/10/2021, 1:50 AM- is what throws things offwitty-crayon-22786
09/10/2021, 4:15 PMshell=Falsewitty-crayon-22786
09/10/2021, 4:15 PMwitty-crayon-22786
09/10/2021, 4:16 PM./pants --something="blah" … in a shell (say, bash), bash eats the quotes (tokenizes) before invoking the child processwitty-crayon-22786
09/10/2021, 4:17 PMshell=False , you are expected to pre-tokenize everything… so passing "--something=blah blah blah" for shell=False is fine and with pass “blah blah blah” for the flag, because you have pre-tokenized it