Skip to content

Commit 69417a3

Browse files
committed
Add test expression option to filter tests by their names
Creates an interface for pytest test selection mechanism. Signed-off-by: Sławomir Błauciak <slawomir.blauciak@intel.com>
1 parent 9e23713 commit 69417a3

File tree

1 file changed

+15
-3
lines changed

1 file changed

+15
-3
lines changed

scripts/test-triton.sh

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +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
4849
"
4950

5051
err() {
@@ -86,6 +87,7 @@ TRITON_TEST_IGNORE_ERRORS=false
8687
SKIP_PIP=false
8788
SKIP_PYTORCH=false
8889
TEST_UNSKIP=false
90+
TRITON_TEST_EXPRESSION=""
8991

9092
while (( $# != 0 )); do
9193
case "$1" in
@@ -273,6 +275,10 @@ while (( $# != 0 )); do
273275
TRITON_TEST_SELECTFILE="$(realpath "$2")"
274276
shift 2
275277
;;
278+
--test-expr)
279+
TRITON_TEST_EXPRESSION="$2"
280+
shift 2
281+
;;
276282
--help)
277283
echo "$HELP"
278284
exit 0
@@ -342,12 +348,18 @@ run_unit_tests() {
342348
}
343349

344350
run_pytest_command() {
351+
local pytest_args=("$@")
352+
353+
if [[ -n "$TRITON_TEST_EXPRESSION" ]]; then
354+
pytest_args+=(-k "$TRITON_TEST_EXPRESSION")
355+
fi
356+
345357
if [[ -n "$TRITON_TEST_SELECTFILE" ]]; then
346-
if pytest "$@" --collect-only > /dev/null 2>&1; then
347-
pytest "$@"
358+
if pytest "${pytest_args[@]}" --collect-only > /dev/null 2>&1; then
359+
pytest "${pytest_args[@]}"
348360
fi
349361
else
350-
pytest "$@"
362+
pytest "${pytest_args[@]}"
351363
fi
352364
}
353365

0 commit comments

Comments
 (0)