Unverified Commit 18c29c74 authored by Andreas Karatzas's avatar Andreas Karatzas Committed by GitHub
Browse files

[ROCm][CI] Fix backslash-continuation in pytest marker re-quoting and treat...


[ROCm][CI] Fix backslash-continuation in pytest marker re-quoting and treat exit code 5 as success (#35798)
Signed-off-by: default avatarAndreas Karatzas <akaratza@amd.com>
parent 96fc0950
...@@ -99,6 +99,15 @@ is_multi_node() { ...@@ -99,6 +99,15 @@ is_multi_node() {
return 1 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 # Pytest marker/keyword re-quoting
# #
...@@ -135,8 +144,9 @@ re_quote_pytest_markers() { ...@@ -135,8 +144,9 @@ re_quote_pytest_markers() {
local collecting=false local collecting=false
local marker_buf="" local marker_buf=""
# Flatten newlines for consistent tokenization # Strip backslash-newline continuations, then flatten remaining newlines
local flat="${input//$'\n'/ }" local flat="${input//$'\\\n'/ }"
flat="${flat//$'\n'/ }"
# Disable globbing to prevent *.py etc. from expanding during read -ra # Disable globbing to prevent *.py etc. from expanding during read -ra
local restore_glob local restore_glob
...@@ -164,6 +174,9 @@ re_quote_pytest_markers() { ...@@ -164,6 +174,9 @@ re_quote_pytest_markers() {
local is_boundary=false local is_boundary=false
case "$word" in case "$word" in
# Line-continuation artifact
"\\")
is_boundary=true ;;
# Command separators # Command separators
"&&"|"||"|";"|"|") "&&"|"||"|";"|"|")
is_boundary=true ;; is_boundary=true ;;
...@@ -204,6 +217,9 @@ re_quote_pytest_markers() { ...@@ -204,6 +217,9 @@ re_quote_pytest_markers() {
if [[ "$word" == "-m" || "$word" == "-k" ]]; then if [[ "$word" == "-m" || "$word" == "-k" ]]; then
output+="${word} " output+="${word} "
collecting=true collecting=true
# Drop stray backslash tokens silently
elif [[ "$word" == "\\" ]]; then
:
else else
output+="${word} " output+="${word} "
fi fi
...@@ -453,7 +469,9 @@ if is_multi_node "$commands"; then ...@@ -453,7 +469,9 @@ if is_multi_node "$commands"; then
done done
/bin/bash -c "${composite_command}" /bin/bash -c "${composite_command}"
exit_code=$?
cleanup_network cleanup_network
handle_pytest_exit "$exit_code"
else else
echo "Multi-node job detected but failed to parse bracket command syntax." echo "Multi-node job detected but failed to parse bracket command syntax."
echo "Expected format: prefix ; [node0_cmd1, node0_cmd2] && [node1_cmd1, node1_cmd2]" echo "Expected format: prefix ; [node0_cmd1, node0_cmd2] && [node1_cmd1, node1_cmd2]"
...@@ -480,4 +498,7 @@ else ...@@ -480,4 +498,7 @@ else
--name "${container_name}" \ --name "${container_name}" \
"${image_name}" \ "${image_name}" \
/bin/bash -c "${commands}" /bin/bash -c "${commands}"
exit_code=$?
handle_pytest_exit "$exit_code"
fi fi
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment