Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 48 additions & 4 deletions scripts/test-triton.sh
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ OPTION:
--skip-list SKIPLIST
--extra-skip-list-suffixes SEMICOLON-SEPARATED LIST OF SUFFIXES
--select-from-file SELECTFILE
--test-expr EXPRESSION
--debug-fail
"

err() {
Expand Down Expand Up @@ -86,6 +88,8 @@ TRITON_TEST_IGNORE_ERRORS=false
SKIP_PIP=false
SKIP_PYTORCH=false
TEST_UNSKIP=false
TEST_FILTER_EXPRESSION=""
TEST_DEBUG_FAIL=false

while (( $# != 0 )); do
case "$1" in
Expand Down Expand Up @@ -273,6 +277,14 @@ while (( $# != 0 )); do
TRITON_TEST_SELECTFILE="$(realpath "$2")"
shift 2
;;
--test-expr)
TEST_FILTER_EXPRESSION="$2"
shift 2
;;
--debug-fail)
TEST_DEBUG_FAIL=true
shift
;;
--help)
echo "$HELP"
exit 0
Expand Down Expand Up @@ -342,12 +354,44 @@ run_unit_tests() {
}

run_pytest_command() {
if [[ -n "$TRITON_TEST_SELECTFILE" ]]; then
if pytest "$@" --collect-only > /dev/null 2>&1; then
pytest "$@"
local pytest_args=()
local pytest_expr=""

# Parse args to separate -k expression
local args=("$@")
for ((i=0; i<${#args[@]}; i++)); do
if [[ "${args[i]}" == "-k" ]]; then
pytest_expr="${args[i+1]}"
i=$((i + 1))
continue
fi
pytest_args+=("${args[i]}")
done

# Combine with TEST_FILTER_EXPRESSION
if [[ -n "$TEST_FILTER_EXPRESSION" ]]; then
if [[ -n "$pytest_expr" ]]; then
pytest_expr="($pytest_expr) and ($TEST_FILTER_EXPRESSION)"
else
pytest_expr="$TEST_FILTER_EXPRESSION"
fi
fi

# Apply -k expression if any
if [[ -n "$pytest_expr" ]]; then
pytest_args+=("-k" "$pytest_expr")
fi

if [[ "$TEST_DEBUG_FAIL" == true ]]; then
pytest_args+=("--pdb")
fi

if [[ -n "$TRITON_TEST_SELECTFILE" ]] || [[ -n "$pytest_expr" ]]; then
if pytest "${pytest_args[@]}" --collect-only > /dev/null 2>&1; then
pytest "${pytest_args[@]}"
fi
else
pytest "$@"
pytest "${pytest_args[@]}"
fi
}

Expand Down
Loading