Skip to content

Commit 47d2726

Browse files
committed
use pytest-skip plugin for selection in the test script
Removes --text-expr argument and replaces it with --select <name> Refactors --pdb pytest call into pytest-utils.sh Signed-off-by: Sławomir Błauciak <[email protected]>
1 parent 4f5bb10 commit 47d2726

File tree

2 files changed

+20
-42
lines changed

2 files changed

+20
-42
lines changed

scripts/pytest-utils.sh

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,16 @@ pytest() {
3838
pytest_extra_args+=(
3939
"--select-from-file=$TRITON_TEST_SELECTFILE"
4040
)
41+
elif [[ -n $TRITON_TEST_SELECT ]]; then
42+
pytest_extra_args+=(
43+
"--select-test=$TRITON_TEST_SELECT"
44+
)
45+
fi
46+
47+
if [[ $TRITON_TEST_DEBUG_FAIL = true ]]; then
48+
pytest_extra_args+=(
49+
"--pdb"
50+
)
4151
fi
4252

4353
if [[ ! -f $TRITON_TEST_SELECTFILE && -v TRITON_TEST_SUITE && -f $TRITON_TEST_SKIPLIST_DIR/$TRITON_TEST_SUITE.txt ]]; then

scripts/test-triton.sh

Lines changed: 10 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ OPTION:
4545
--skip-list SKIPLIST
4646
--extra-skip-list-suffixes SEMICOLON-SEPARATED LIST OF SUFFIXES
4747
--select-from-file SELECTFILE
48-
--test-expr EXPRESSION
48+
--select NAME
4949
--debug-fail
5050
"
5151

@@ -88,8 +88,8 @@ TRITON_TEST_IGNORE_ERRORS=false
8888
SKIP_PIP=false
8989
SKIP_PYTORCH=false
9090
TEST_UNSKIP=false
91-
TEST_FILTER_EXPRESSION=""
92-
TEST_DEBUG_FAIL=false
91+
TRITON_TEST_SELECT=""
92+
TRITON_TEST_DEBUG_FAIL=false
9393

9494
while (( $# != 0 )); do
9595
case "$1" in
@@ -277,12 +277,12 @@ while (( $# != 0 )); do
277277
TRITON_TEST_SELECTFILE="$(realpath "$2")"
278278
shift 2
279279
;;
280-
--test-expr)
281-
TEST_FILTER_EXPRESSION="$2"
280+
--select)
281+
TRITON_TEST_SELECT="$2"
282282
shift 2
283283
;;
284284
--debug-fail)
285-
TEST_DEBUG_FAIL=true
285+
TRITON_TEST_DEBUG_FAIL=true
286286
shift
287287
;;
288288
--help)
@@ -354,44 +354,12 @@ run_unit_tests() {
354354
}
355355

356356
run_pytest_command() {
357-
local pytest_args=()
358-
local pytest_expr=""
359-
360-
# Parse args to separate -k expression
361-
local args=("$@")
362-
for ((i=0; i<${#args[@]}; i++)); do
363-
if [[ "${args[i]}" == "-k" ]]; then
364-
pytest_expr="${args[i+1]}"
365-
i=$((i + 1))
366-
continue
367-
fi
368-
pytest_args+=("${args[i]}")
369-
done
370-
371-
# Combine with TEST_FILTER_EXPRESSION
372-
if [[ -n "$TEST_FILTER_EXPRESSION" ]]; then
373-
if [[ -n "$pytest_expr" ]]; then
374-
pytest_expr="($pytest_expr) and ($TEST_FILTER_EXPRESSION)"
375-
else
376-
pytest_expr="$TEST_FILTER_EXPRESSION"
377-
fi
378-
fi
379-
380-
# Apply -k expression if any
381-
if [[ -n "$pytest_expr" ]]; then
382-
pytest_args+=("-k" "$pytest_expr")
383-
fi
384-
385-
if [[ "$TEST_DEBUG_FAIL" == true ]]; then
386-
pytest_args+=("--pdb")
387-
fi
388-
389-
if [[ -n "$TRITON_TEST_SELECTFILE" ]] || [[ -n "$pytest_expr" ]]; then
390-
if pytest "${pytest_args[@]}" --collect-only > /dev/null 2>&1; then
391-
pytest "${pytest_args[@]}"
357+
if [[ -n "$TRITON_TEST_SELECTFILE" ]] || [[ -n "$TRITON_TEST_SELECT" ]]; then
358+
if pytest "$@" --collect-only > /dev/null 2>&1; then
359+
pytest "$@"
392360
fi
393361
else
394-
pytest "${pytest_args[@]}"
362+
pytest "$@"
395363
fi
396364
}
397365

0 commit comments

Comments
 (0)