ci: fix using _section_switch and _uncollapsed_section_switch

Allow users to call `_section_switch` and `_uncollapsed_section_switch`
without previous section commands.

This can happen because `*-runner.sh` script can be composed in several
ways.

For example if `android-cts-runner.sh` is called without first calling
`cuttlefish-runner.sh`, where a `section_start` is issued, the
`uncollapsed_section_switch` command in `android-cts-runner.sh` will
fail with an error like:

  2025-07-02T08:42:33 /install/setup-test-env.sh: line 102: CURRENT_SECTION: unbound variable

Setting default empty values for `CURRENT_SECTION` makes it possible to
use the "section_switch" commands to also start a section for the first
time.

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/35907>
This commit is contained in:
Antonio Ospite 2025-07-02 10:55:25 +02:00 committed by Marge Bot
parent 32fe81a02b
commit 5a4c1e2502

4
.gitlab-ci/setup-test-env.sh Normal file → Executable file
View file

@ -88,7 +88,7 @@ function _section_end {
alias section_end="x_off; _section_end"
function _section_switch {
if [ -n "$CURRENT_SECTION" ]
if [ -n "${CURRENT_SECTION:-}" ]
then
build_section_end $CURRENT_SECTION
x_off
@ -99,7 +99,7 @@ function _section_switch {
alias section_switch="x_off; _section_switch"
function _uncollapsed_section_switch {
if [ -n "$CURRENT_SECTION" ]
if [ -n "${CURRENT_SECTION:-}" ]
then
build_section_end $CURRENT_SECTION
x_off