Skip to content

Fix unit tests aborting on bash 3.2 - #1505

Open
corioliskraft wants to merge 1 commit into
stackitcloud:mainfrom
corioliskraft:fix/test-sh-empty-array-under-nounset
Open

Fix unit tests aborting on bash 3.2#1505
corioliskraft wants to merge 1 commit into
stackitcloud:mainfrom
corioliskraft:fix/test-sh-empty-array-under-nounset

Conversation

@corioliskraft

Copy link
Copy Markdown

How to categorize this PR?

/kind bug

What this PR does / why we need it:

Script hack/test.sh sets nounset at line 4 and expands test_flags at line 27. Outside
CI that array is empty, and bash 3.2 treats the expansion of an empty array as an unbound
variable. Therefore make verify aborts before it runs a test:

./hack/test.sh ./cmd/... ./pkg/...
> Unit Tests
./hack/test.sh: line 27: test_flags[@]: unbound variable
make: *** [test] Error 1

macOS ships bash 3.2.57 as /bin/bash, so every contributor on a stock macOS machine hits
this at CONTRIBUTING step 4.

This PR guards the expansion, so it disappears when the array is empty. This matches the
${timeout_flag:+...} guard in the same line. Prow is not affected either way, because
there CI and ARTIFACTS are set and test_flags is never empty.

Which issue(s) this PR fixes:

Fixes #1504

Special notes for your reviewer:

The behavior of the guard on bash 3.2.57:

$ /bin/bash -c 'set -u; a=(); echo "before"; echo ${a[@]+"${a[@]}"}; echo "after"'
before

after
$ /bin/bash -c 'set -u; a=(one two); printf "[%s]\n" ${a[@]+"${a[@]}"}'
[one]
[two]

The second command shows that the elements stay separate arguments. The form uses + and
not :+, because the test must be "set" and not "set and not empty".

make verify passes on macOS 15.7.7, arm64, with bash 3.2.57.

Breaking changes:

None.

@ske-prow ske-prow Bot added kind/bug Bug do-not-merge/invalid-commit-message Indicates that a PR should not merge because it has an invalid commit message. labels Aug 18, 2026
@ske-prow

ske-prow Bot commented Aug 18, 2026

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
Once this PR has been reviewed and has the lgtm label, please assign robinschneider for approval. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@ske-prow

ske-prow Bot commented Aug 18, 2026

Copy link
Copy Markdown

Welcome @corioliskraft!

It looks like this is your first PR to stackitcloud/cloud-provider-stackit 🎉.

You will be prompted by a bot to use commands during the review process. Do not be afraid to follow the prompts! It is okay to experiment. Here is the bot commands documentation.

You can also check if stackitcloud/cloud-provider-stackit has its own contribution guidelines.

Thank you, and welcome to SKE. 😃

@ske-prow ske-prow Bot added the needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. label Aug 18, 2026
@ske-prow

ske-prow Bot commented Aug 18, 2026

Copy link
Copy Markdown

Hi @corioliskraft. Thanks for your PR.

I'm waiting for a stackitcloud member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work.

Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

Details

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

@ske-prow ske-prow Bot added the size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. label Aug 18, 2026
Script hack/test.sh sets nounset and expands test_flags at line 27.
Outside CI that array is empty, and bash 3.2 treats the expansion of an
empty array as an unbound variable, so make verify aborts before it runs
a test. macOS ships bash 3.2.57 as /bin/bash.

Guard the expansion so it disappears when the array is empty. This
matches the ${timeout_flag:+...} guard in the same line.
@corioliskraft
corioliskraft force-pushed the fix/test-sh-empty-array-under-nounset branch from 881283c to 33dc20b Compare August 18, 2026 14:20
@ske-prow ske-prow Bot removed the do-not-merge/invalid-commit-message Indicates that a PR should not merge because it has an invalid commit message. label Aug 18, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

kind/bug Bug needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. size/XS Denotes a PR that changes 0-9 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

make verify fails on stock macOS: "test_flags[@]: unbound variable" in hack/test.sh

1 participant