diff --git a/.buildkite/scripts/hardware_ci/run-amd-test.sh b/.buildkite/scripts/hardware_ci/run-amd-test.sh index aa84d0e8aae9..8895771f0a40 100755 --- a/.buildkite/scripts/hardware_ci/run-amd-test.sh +++ b/.buildkite/scripts/hardware_ci/run-amd-test.sh @@ -99,6 +99,15 @@ is_multi_node() { return 1 } +handle_pytest_exit() { + local exit_code=$1 + if [ "$exit_code" -eq 5 ]; then + echo "Pytest exit code 5 (no tests collected) - treating as success." + exit 0 + fi + exit "$exit_code" +} + ############################################################################### # Pytest marker/keyword re-quoting # @@ -135,8 +144,9 @@ re_quote_pytest_markers() { local collecting=false local marker_buf="" - # Flatten newlines for consistent tokenization - local flat="${input//$'\n'/ }" + # Strip backslash-newline continuations, then flatten remaining newlines + local flat="${input//$'\\\n'/ }" + flat="${flat//$'\n'/ }" # Disable globbing to prevent *.py etc. from expanding during read -ra local restore_glob @@ -164,6 +174,9 @@ re_quote_pytest_markers() { local is_boundary=false case "$word" in + # Line-continuation artifact + "\\") + is_boundary=true ;; # Command separators "&&"|"||"|";"|"|") is_boundary=true ;; @@ -204,6 +217,9 @@ re_quote_pytest_markers() { if [[ "$word" == "-m" || "$word" == "-k" ]]; then output+="${word} " collecting=true + # Drop stray backslash tokens silently + elif [[ "$word" == "\\" ]]; then + : else output+="${word} " fi @@ -453,7 +469,9 @@ if is_multi_node "$commands"; then done /bin/bash -c "${composite_command}" + exit_code=$? cleanup_network + handle_pytest_exit "$exit_code" else echo "Multi-node job detected but failed to parse bracket command syntax." echo "Expected format: prefix ; [node0_cmd1, node0_cmd2] && [node1_cmd1, node1_cmd2]" @@ -480,4 +498,7 @@ else --name "${container_name}" \ "${image_name}" \ /bin/bash -c "${commands}" + + exit_code=$? + handle_pytest_exit "$exit_code" fi