From 2ae600af3eba8b26b88de40cad1629682e608ac7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C5=82awomir=20B=C5=82auciak?= Date: Wed, 5 Nov 2025 12:13:53 +0000 Subject: [PATCH 1/2] Add test expression option to filter tests by their names MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Creates an interface for pytest test selection mechanism. Signed-off-by: Sławomir Błauciak --- scripts/test-triton.sh | 42 ++++++++++++++++++++++++++++++++++++++---- 1 file changed, 38 insertions(+), 4 deletions(-) diff --git a/scripts/test-triton.sh b/scripts/test-triton.sh index 2c172eafec..1446eefe0b 100755 --- a/scripts/test-triton.sh +++ b/scripts/test-triton.sh @@ -45,6 +45,7 @@ OPTION: --skip-list SKIPLIST --extra-skip-list-suffixes SEMICOLON-SEPARATED LIST OF SUFFIXES --select-from-file SELECTFILE + --test-expr EXPRESSION " err() { @@ -86,6 +87,7 @@ TRITON_TEST_IGNORE_ERRORS=false SKIP_PIP=false SKIP_PYTORCH=false TEST_UNSKIP=false +TEST_FILTER_EXPRESSION="" while (( $# != 0 )); do case "$1" in @@ -273,6 +275,10 @@ while (( $# != 0 )); do TRITON_TEST_SELECTFILE="$(realpath "$2")" shift 2 ;; + --test-expr) + TEST_FILTER_EXPRESSION="$2" + shift 2 + ;; --help) echo "$HELP" exit 0 @@ -342,12 +348,40 @@ 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 [[ -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 } From 766f046abf354892d4ec7197e91bf8f0e3e1886c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C5=82awomir=20B=C5=82auciak?= Date: Fri, 7 Nov 2025 13:18:14 +0000 Subject: [PATCH 2/2] Expose Python debugger option for failed tests Enables automatic running for Python debug for failed tests --- scripts/test-triton.sh | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/scripts/test-triton.sh b/scripts/test-triton.sh index 1446eefe0b..10e63328f6 100755 --- a/scripts/test-triton.sh +++ b/scripts/test-triton.sh @@ -46,6 +46,7 @@ OPTION: --extra-skip-list-suffixes SEMICOLON-SEPARATED LIST OF SUFFIXES --select-from-file SELECTFILE --test-expr EXPRESSION + --debug-fail " err() { @@ -88,6 +89,7 @@ SKIP_PIP=false SKIP_PYTORCH=false TEST_UNSKIP=false TEST_FILTER_EXPRESSION="" +TEST_DEBUG_FAIL=false while (( $# != 0 )); do case "$1" in @@ -279,6 +281,10 @@ while (( $# != 0 )); do TEST_FILTER_EXPRESSION="$2" shift 2 ;; + --debug-fail) + TEST_DEBUG_FAIL=true + shift + ;; --help) echo "$HELP" exit 0 @@ -376,6 +382,10 @@ run_pytest_command() { 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[@]}"