[ROCm][CI] Fix backslash-continuation in pytest marker re-quoting and treat exit code 5 as success (#35798)
Signed-off-by: Andreas Karatzas <akaratza@amd.com>
This commit is contained in:
@@ -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() {
|
|||||||
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() {
|
|||||||
|
|
||||||
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() {
|
|||||||
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
|
|||||||
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
|
|||||||
--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
|
||||||
|
|||||||
Reference in New Issue
Block a user