spread: fix unbound variable error
Metadata
Current evaluation
Merged a fix for an unbound variable error in spread's autopkgtest. The set -u flag caused failures on unset variables. The change uses the ${var:-} syntax to safely check variables, resolving the test failure. Approved and merged.
Suggested action: —
No scores available.
Issue body
After accidentally running spread's autopkgtest, an error occurred with
unbound variables.
```
...
Allocating ad-hoc ubuntu-16.04-amd64
/bin/bash: line 18: ADT_ARTIFACTS: unbound variable
...
```
Spread sets -u, which will causes incorrect behavior when checking
against an unset variable:
```
$ set +u
$ if [ -z "${unsetvariable}" ]; then echo "empty"; fi
empty
$ set -u
$ if [ -z "${unsetvariable}" ]; then echo "empty"; fi
bash: unsetvariable: unbound variable
```
Fix it by checking if set.
```
$ setvariable=set
$ if [ -z "${setvariable:-}" ]; then echo "empty"; fi
$ if [ -z "${unsetvariable:-}" ]; then echo "empty"; fi
empty
```
Simply do the same for ADT_ARTIFACTS, and allow the check to happen as
originally intended:
```
2019-08-22 17:34:40 Allocating autopkgtest:ubuntu-16.04-amd64...
2019-08-22 17:34:40 Cannot allocate autopkgtest:ubuntu-16.04-s390x:
adhoc only works inside autopkgtest
```
Signed-off-by: Chris Patterson <chris.patterson@canonical.com>
- [ ] Have you followed the [guidelines for contributing](https://github.com/snapcore/snapcraft/blob/master/CONTRIBUTING.md)?
- [ ] Have you signed the [CLA](http://www.ubuntu.com/legal/contributors/)?
- [ ] Have you successfully run `./runtests.sh static`?
- [ ] Have you successfully run `./runtests.sh tests/unit`?
-----
Evaluation history
| Date | Model | Scores | Action | Summary |
|---|---|---|---|---|
| qwen/qwen3.6-35b-a3b | — | — | Merged a fix for an unbound variable error in spread's autopkgtest. The set -u flag caused failures on unset variables. The change uses the ${var:-} syntax to safely check variables, resolving the test failure. Approved and merged. | |
| qwen3.6-35b-a3b-mtp-q6 | — | — | Merged fix for a spread autopkgtest unbound variable error. The script failed checking unset ADT_ARTIFACTS under set -u. Updated the check to use ${ADT_ARTIFACTS:-} syntax, safely handling unset variables and resolving the bash error. | |
| qwen3.6-35b-a3b-mtp-q6 | — | — | Merged fix for an unbound variable error in spread's autopkgtest. Updated the ADT_ARTIFACTS check to use ${ADT_ARTIFACTS:-}, safely handling unset variables under set -u while preserving intended allocation logic. |
Update history
No update history recorded yet.
Related issues
| Issue | Project | State | Summary | Similarity |
|---|---|---|---|---|
| #2188 tests: support running spread suite in autopkgtests | snapcraft | merged | Merged. Adds an autopkgtest suite to run the spread test suite during releases. CI failures were resolved by fixing missing build dependencies and temporarily disabling armhf execution. Approved by one reviewer and merged. |