@@ -28,10 +28,16 @@ if [ "$TOOLCHAIN" = "nightly" ] ; then
2828 rustup component add rust-src
2929fi
3030
31+ # Print GHA workflow commands
32+ echo_if_ci () {
33+ # Discard stderr so the "set -x" trace doesn't show up
34+ { [ -n " ${CI:- } " ] && echo " $1 " ; } 2> /dev/null
35+ }
36+
3137# Run the tests for a specific target
3238test_target () {
33- target=" ${1} "
34- no_dist=" ${2 :- 0} "
39+ target=" $1 "
40+ no_dist=" $2 "
3541
3642 RUSTFLAGS=" ${RUSTFLAGS:- } "
3743
@@ -269,7 +275,13 @@ case "$rust" in
269275 * ) supports_wasi_pn=0 ;;
270276esac
271277
272- for target in $targets ; do
278+ some_tests_run=0
279+
280+ # Apply the `FILTER` variable, do OS-specific tasks, and run a target
281+ filter_and_run () {
282+ target=" $1 "
283+ no_dist=" ${2:- 0} "
284+
273285 if echo " $target " | grep -q " $filter " ; then
274286 if [ " $os " = " windows" ]; then
275287 TARGET=" $target " ./ci/install-rust.sh
@@ -282,27 +294,28 @@ for target in $targets; do
282294
283295 # `wasm32-wasip2` only exists in recent versions of Rust
284296 if [ " $target " = " wasm32-wasip2" ] && [ " $supports_wasi_pn " = " 0" ]; then
285- continue
297+ return
286298 fi
287299
288- test_target " $target "
289- test_run =1
300+ test_target " $target " " $no_dist "
301+ some_tests_run =1
290302 fi
303+ }
304+
305+ for target in $targets ; do
306+ echo_if_ci " ::group::Target: $target "
307+ filter_and_run " $target "
308+ echo_if_ci " ::endgroup::"
291309done
292310
293311for target in ${no_dist_targets:- } ; do
294- if echo " $target " | grep -q " $filter " ; then
295- if [ " $os " = " windows" ]; then
296- TARGET=" $target " ./ci/install-rust.sh
297- fi
298-
299- test_target " $target " 1
300- test_run=1
301- fi
312+ echo_if_ci " ::group::Target: $target "
313+ filter_and_run " $target " 1
314+ echo_if_ci " ::endgroup::"
302315done
303316
304317# Make sure we didn't accidentally filter everything
305- if [ " ${test_run :- } " != 1 ]; then
318+ if [ " $some_tests_run " != 1 ]; then
306319 echo " No tests were run"
307320 exit 1
308321fi
0 commit comments