bazelbuild/bazel

`@` character in label causes parsing issue with `--flaky_test_attempts`

Open

#19,447 创建于 2023年9月7日

在 GitHub 查看
 (1 评论) (0 反应) (0 负责人)Java (4,465 fork)batch import
P3help wantedteam-CLItype: bug

仓库指标

Star
 (25,384 star)
PR 合并指标
 (平均合并 22天 20小时) (30 天内合并 77 个 PR)

描述

Description of the bug:

According to the documentation, @ is a valid character in target labels - https://bazel.build/concepts/labels#target-names

@ is also the character used to separate target labels from the number of attempts when using --flaky_test_attempts - https://bazel.build/reference/command-line-reference#flag--flaky_test_attempts

Alternate syntax: regex_filter@flaky_test_attempts. Where flaky_test_attempts is as above and regex_filter stands for a list of include and exclude regular expression patterns (Also see --runs_per_test). Example: --flaky_test_attempts=//foo/.*,-//foo/bar/.*@3 deflakes all tests in //foo/ except those under foo/bar three times

If you try to use this @ syntax in --flaky_test_attempts with a label that includes an @ sign, CLI argument parsing fails.

$ bazel test //... --flaky_test_attempts=//foo:v@lid-target@3
ERROR: While parsing option --flaky_test_attempts=//foo:v@lid-target@3: '//foo:v@lid-target@3' has a non-numeric value

This is due to this line of code here - https://github.com/bazelbuild/bazel/blob/7e0df68aa4d11307dff8571ebce11d37c79c170c/src/main/java/com/google/devtools/build/lib/analysis/config/PerLabelOptions.java#L50 - which uses the first @ to split the string.

Which category does this issue belong to?

CLI

What's the simplest, easiest way to reproduce this bug? Please provide a minimal example if possible.

In any repo

$ bazel test //... --flaky_test_attempts=//foo:v@lid-target@3

Confirm that you get an error.

Which operating system are you running Bazel on?

Linux

What is the output of bazel info release?

release 6.3.2

If bazel info release returns development version or (@non-git), tell us how you built Bazel.

N/A

What's the output of git remote get-url origin; git rev-parse master; git rev-parse HEAD ?

N/A

Is this a regression? If yes, please try to identify the Bazel commit where the bug was introduced.

Not as far as I know

Have you found anything relevant by searching the web?

Google didn't turn up anything

Any other information, logs, or outputs that you want to share?

No response

贡献者指南