Skip to content

Commit f2f3a9c

Browse files
test(hack): restore the direct yq form in the selector install tests
The programs were rewritten to start at select() to get past a checkbashisms false positive: it reads a `.` adjacent to a quote as a POSIX `source` with arguments, and reported it on the continuation line rather than on the yq call, so the shape had to be contorted twice before the warning went quiet. sh_posix_gate now reads the quoting and suppresses that class when the dot is inside quotes, keeping it for a real `. ./lib.sh arg` where dash silently discards the arguments. So the contortion has nothing left to buy, and the query goes back to the form that says what it means. Behaviour is unchanged; the same fields are selected either way. Assisted-By: Claude <[email protected]> Signed-off-by: Myasnikov Daniil <[email protected]>
1 parent 30b5c07 commit f2f3a9c

1 file changed

Lines changed: 7 additions & 9 deletions

File tree

‎hack/select-install_test.bats‎

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -251,13 +251,11 @@ YAML
251251
# Unique metadata.name, not a file count: the script partitions names, and a
252252
# sources file holding two documents would make a file count disagree for a
253253
# reason that has nothing to do with the complement.
254-
# Two shapes here are deliberate, both to keep checkbashisms quiet: the yq
255-
# program starts with `select(` rather than a bare `.`, and it is held in a
256-
# variable rather than inlined. checkbashisms reads a leading or trailing
257-
# `.` next to a quote as a POSIX `source`, and sh_posix_gate denies a commit
258-
# that adds one.
259-
names_q='select(.metadata.name != null and .metadata.name != "") | .metadata.name'
260-
total=$(yq -rN "$names_q" packages/core/platform/sources/*.yaml | sort -u | wc -l | tr -d ' ')
254+
# Unique metadata.name, not a file count: the script partitions names, and a
255+
# sources file holding two documents would make a file count disagree for a
256+
# reason that has nothing to do with the complement.
257+
total=$(yq -rN '.metadata.name | select(. != null and . != "")' \
258+
packages/core/platform/sources/*.yaml | sort -u | wc -l | tr -d ' ')
261259
keep=$(hack/select-install.sh "postgres" | wc -w | tr -d ' ')
262260
drop=$(hack/select-install.sh --disabled "postgres" | wc -w | tr -d ' ')
263261
sum=$((keep + drop))
@@ -284,8 +282,8 @@ YAML
284282
# backupstrategy-controller), so the test asserted nothing at all.
285283
@test "disabled mode: no kept package has a dependency in the complement" {
286284
deps=$(mktemp)
287-
edges_q='select(.metadata.name != null) | .metadata.name as $n | .spec.variants[]?.dependsOn[]? | select(length > 0) | $n + " " + .'
288-
yq -rN "$edges_q" packages/core/platform/sources/*.yaml > "$deps"
285+
yq -rN '.metadata.name as $n | .spec.variants[]?.dependsOn[]? | select(. != null and . != "") | $n + " " + .' \
286+
packages/core/platform/sources/*.yaml > "$deps"
289287

290288
for suite in $(find hack/e2e-chainsaw -mindepth 2 -maxdepth 2 -name chainsaw-test.yaml \
291289
| sed -e 's,^hack/e2e-chainsaw/,,' -e 's,/chainsaw-test\.yaml$,,'); do

0 commit comments

Comments
 (0)