build: Enforce shellcheck(1) on all Bats tests#1331
build: Enforce shellcheck(1) on all Bats tests#1331debarshiray merged 4 commits intocontainers:mainfrom
Conversation
Otherwise https://www.shellcheck.net/ would complain: Line 28: run --separate-stderr $TOOLBOX --version ^------^ SC2086 (info): Double quote to prevent globbing and word splitting. See: https://www.shellcheck.net/wiki/SC2086 containers#1331
26e6560 to
7cc4772
Compare
|
Build succeeded. ✔️ unit-test SUCCESS in 9m 23s |
Otherwise https://www.shellcheck.net/ would complain: Line 28: run --separate-stderr $TOOLBOX --version ^------^ SC2086 (info): Double quote to prevent globbing and word splitting. See: https://www.shellcheck.net/wiki/SC2086 containers#1331
7cc4772 to
9e88266
Compare
|
Build succeeded. ✔️ unit-test SUCCESS in 9m 07s |
Otherwise https://www.shellcheck.net/ would complain: Line 28: run --separate-stderr $TOOLBOX --version ^------^ SC2086 (info): Double quote to prevent globbing and word splitting. See: https://www.shellcheck.net/wiki/SC2086 containers#1331
9e88266 to
f2efbfb
Compare
|
Build failed. ✔️ unit-test SUCCESS in 9m 04s |
|
Wow! Looks like a network problem caused |
|
recheck |
|
Build succeeded. ✔️ unit-test SUCCESS in 9m 32s |
Otherwise https://www.shellcheck.net/ would complain: Line 28: run --separate-stderr $TOOLBOX --version ^------^ SC2086 (info): Double quote to prevent globbing and word splitting. See: https://www.shellcheck.net/wiki/SC2086 containers#1331
f2efbfb to
8985f12
Compare
|
Build failed. ✔️ unit-test SUCCESS in 10m 25s |
Otherwise https://www.shellcheck.net/ would complain: Line 28: run --separate-stderr $TOOLBOX --version ^------^ SC2086 (info): Double quote to prevent globbing and word splitting. See: https://www.shellcheck.net/wiki/SC2086 containers#1331
8985f12 to
73e756f
Compare
|
Build failed. ❌ unit-test RETRY_LIMIT in 55s |
Otherwise https://www.shellcheck.net/ would complain: Line 28: run --separate-stderr $TOOLBOX --version ^------^ SC2086 (info): Double quote to prevent globbing and word splitting. See: https://www.shellcheck.net/wiki/SC2086 containers#1331
73e756f to
66cd03d
Compare
|
This is odd: Doesn't look like anything to do with Toolbx. |
|
Build failed. ❌ unit-test RETRY_LIMIT in 1m 00s |
Otherwise https://www.shellcheck.net/ would complain: Line 218: source <(echo "$output") ^---------------^ SC1090 (warning): ShellCheck can't follow non-constant source. Use a directive to specify location. See: https://www.shellcheck.net/wiki/SC1090 containers#1331
66cd03d to
e5ea6b9
Compare
|
Build succeeded. ✔️ unit-test SUCCESS in 10m 03s |
Otherwise https://www.shellcheck.net/ would complain: Line 28: run --separate-stderr $TOOLBOX --version ^------^ SC2086 (info): Double quote to prevent globbing and word splitting. See: https://www.shellcheck.net/wiki/SC2086 containers#1331
|
Build succeeded. ✔️ unit-test SUCCESS in 10m 09s |
These files aren't marked as executable, and shouldn't be, because they aren't meant to be standalone executable scripts. They're meant to be part of a test suite driven by Bats. Therefore, it doesn't make sense for them to have shebangs, because it gives the opposite impression. The shebangs were actually being used by external tools like Coverity to deduce the shell when running shellcheck(1). Shellcheck's inline 'shell' directive is a more obvious way to achieve that. containers#1331
|
Build failed. ❌ unit-test RETRY_LIMIT in 36s |
The setup_suite.bash file is meant to be written in Bash, and is not supposed to have any Bats-specific syntax. That's why it has the *.bash suffix, not *.bats. If Bats finds a setup_suite.bash file, when running the test suite, it uses Bash's source(1) builtin to read the file. This is a cosmetic change. The Bats syntax is a superset of the Bash syntax. Therefore, it didn't make a difference to external tools like Coverity that use the shebang to deduce the shell for shellcheck(1). Secondly setup_suite.bash isn't meant to be an executable script and, hence, the shebang has no effect on how the file is used. However, it's still a commonly used hint about the contents of the file, and it's better to be accurate than misleading. A subsequent commit will replace the shebangs in the test suite with ShellCheck's 'shell' directives. Fallout from 7a387dc containers#1331
These files aren't marked as executable, and shouldn't be, because they aren't meant to be standalone executable scripts. They're meant to be part of a test suite driven by Bats. Therefore, it doesn't make sense for them to have shebangs, because it gives the opposite impression. The shebangs were actually being used by external tools like Coverity to deduce the shell when running shellcheck(1). Shellcheck's inline 'shell' directive is a more obvious way to achieve that. containers#1331
Otherwise https://www.shellcheck.net/ would complain: Line 28: run --separate-stderr $TOOLBOX --version ^------^ SC2086 (info): Double quote to prevent globbing and word splitting. See: https://www.shellcheck.net/wiki/SC2086 containers#1331
Otherwise https://www.shellcheck.net/ would complain: Line 339: pull_distro_image $(get_system_id) $(get_system_version) ^--------------^ SC2046 (warning): Quote this to prevent word splitting. See: https://www.shellcheck.net/wiki/SC2046 containers#1331
Otherwise https://www.shellcheck.net/ would complain: Line 143: assert_line --index 0 "~/.bash_profile read" ^------------------^ SC2088 (warning): Tilde does not expand in quotes. Use $HOME. See: https://www.shellcheck.net/wiki/SC2088 This is a false positive. There's no need for the tilde to be expanded because it's not being used for any file system operation. It's merely a human-readable string. However, it's easier to change the string to use $HOME than littering the file with ShellCheck's inline 'disable' directives. containers#1331
Otherwise https://www.shellcheck.net/ would complain: Line 33: assert [ ${#stderr_lines[@]} -eq 0 ] ^-----------------^ SC2154 (warning): stderr_lines is referenced but not assigned. See: https://www.shellcheck.net/wiki/SC2154 containers#1331
Otherwise https://www.shellcheck.net/ would complain: Line 624: local system_id="$(get_system_id)" ^-------^ SC2155 (warning): Declare and assign separately to avoid masking return values. See: https://www.shellcheck.net/wiki/SC2155 containers#1331
ed80022 to
c5ab2cf
Compare
|
Build failed. ❌ unit-test FAILURE in 8m 46s |
Bats' 'run' helper is not necessary to merely check if a command succeeded or not [1]. In this case, it's idiomatic to use the command as the condition for an 'if' branch. [1] https://bats-core.readthedocs.io/en/stable/writing-tests.html containers#1378
This removes any ambiguities and makes it clear what value is being returned. containers#1378
Otherwise https://www.shellcheck.net/ would complain: Line 343: if [ "$status" -ne 0 ]; then ^-----^ SC2154 (warning): status is referenced but not assigned. See: https://www.shellcheck.net/wiki/SC2154 containers#1378
c5ab2cf to
4ebaea6
Compare
|
Build failed. ✔️ unit-test SUCCESS in 8m 27s |
|
There are still some test failures on Fedora Rawhide. For example: I believe these are because of changes in various other components in Fedora 39, which we need to track down one by one and work out a fix. In the mean time, I am going to temporarily override these failures. |
No description provided.