Skip to content

Commit 306b589

Browse files
committed
Update query-result normalization logic to support plus repo name delimiter
The delimiter used in canonical repo names is changing from `~` to `+`.[^1] This logic, which tries to normalize query results for the purposes of diff-testing against golden results, label parsing seems unavoidable, so we fall back to the non-preferred approach of supporting both delimiters in our patterns. Also, refine the patterns to be more exact and better reflect the intent to only act agaisnt the repo-name part of each label: * anchor the patterns to match only at start of each label * only operate before the first `/` [^1]: bazelbuild/bazel#23127
1 parent 1c5f2eb commit 306b589

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

tests/integration/BUILD

+3-3
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ genrule(
3535
testonly = 1,
3636
srcs = [":testonly-deps"],
3737
outs = ["testonly-deps-sorted.txt"],
38-
cmd = "cat $< | sed -e 's|@@|@|g; s|\r||g' | sed -e 's|@.*~|@|g; s|\r||g' | sort > $@",
38+
cmd = "cat $< | sed -e 's|^@@|@|g; s|\r||g' | sed -e 's|^@[^/]*[+~]|@|g; s|\r||g' | sort > $@",
3939
)
4040

4141
diff_test(
@@ -62,7 +62,7 @@ genrule(
6262
testonly = 1,
6363
srcs = [":version_interval_deps"],
6464
outs = ["version-interval-deps-sorted.txt"],
65-
cmd = "cat $< | sed -e 's|@@|@|g; s|\r||g' | sed -e 's|@.*~|@|g; s|\r||g' | sort > $@",
65+
cmd = "cat $< | sed -e 's|^@@|@|g; s|\r||g' | sed -e 's|^@[^/]*[+~]|@|g; s|\r||g' | sort > $@",
6666
)
6767

6868
diff_test(
@@ -86,7 +86,7 @@ genrule(
8686
testonly = 1,
8787
srcs = [":forced-versions-deps"],
8888
outs = ["forced-versions-deps-sorted.txt"],
89-
cmd = "cat $< | sed -e 's|@@|@|g; s|\r||g' | sed -e 's|@.*~|@|g; s|\r||g' | sort > $@",
89+
cmd = "cat $< | sed -e 's|^@@|@|g; s|\r||g' | sed -e 's|^@[^/]*[+~]|@|g; s|\r||g' | sort > $@",
9090
)
9191

9292
diff_test(

tests/integration/override_targets/override_contains_additional_deps.sh

+2-2
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@ function clean_up_workspace_names() {
1818
local target="$2"
1919
# The first `sed` command replaces `@@` with `@`. The second extracts the visible name
2020
# from the bzlmod mangled workspace name
21-
cat "$file_name" | sed -e 's|@@|@|g; s|\r||g' | sed -e 's|@.*~|@|g; s|\r||g' | grep "$target"
22-
cat "$file_name" | sed -e 's|@@|@|g; s|\r||g' | sed -e 's|@.*~|@|g; s|\r||g' | grep -q "$target"
21+
cat "$file_name" | sed -e 's|^@@|@|g; s|\r||g' | sed -e 's|^@[^/]*[+~]|@|g; s|\r||g' | grep "$target"
22+
cat "$file_name" | sed -e 's|^@@|@|g; s|\r||g' | sed -e 's|^@[^/]*[+~]|@|g; s|\r||g' | grep -q "$target"
2323
}
2424

2525
# we should contain the original target

0 commit comments

Comments
 (0)