Skip to content

Commit

Permalink
version 2
Browse files Browse the repository at this point in the history
  • Loading branch information
AshburnLee committed Jun 14, 2024
1 parent b2e9c5a commit 4ce54b4
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 65 deletions.
22 changes: 22 additions & 0 deletions python/test/conftest.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# content of conftest.py
import os
import pytest

def pytest_configure(config):
if os.getenv('TEST_UNSKIP') == 'false':
pass
else:
# define a function that do nothing
def unskip(reason=None, allow_module_level=False):
pass
# save the original 'pytest.skip' to config._skip_f
config._skip_f = pytest.skip
# replace 'pytest.skip' with 'pass' call
pytest.skip = unskip

def pytest_unconfigure(config):
if os.getenv('TEST_UNSKIP') == 'false':
pass
else:
# restore 'pytest.skip'
pytest.skip = config._skip_f
7 changes: 2 additions & 5 deletions scripts/pytest-utils.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ TRITON_TEST_SKIPLIST_DIR="$(cd "$TRITON_TEST_SKIPLIST_DIR" && pwd)"
CURRENT_SKIPLIST_DIR="$SCRIPTS_DIR/skiplist/current"

pytest() {
pytest_extra_args=("--timeout=15") # need pytest-timeout installed
pytest_extra_args=()

if [[ -v TRITON_TEST_SUITE && $TRITON_TEST_REPORTS = true ]]; then
mkdir -p "$TRITON_TEST_REPORTS_DIR"
Expand All @@ -36,11 +36,8 @@ pytest() {
sed -e '/^#/d' "$TRITON_TEST_SKIPLIST_DIR/$TRITON_TEST_SUITE.txt" > "$CURRENT_SKIPLIST_DIR/$TRITON_TEST_SUITE.txt"
pytest_extra_args+=(
"--deselect-from-file=$CURRENT_SKIPLIST_DIR/$TRITON_TEST_SUITE.txt"
"--select-fail-on-missing"
)
# this argument results in execution error when enable unskip test
if [ "$TEST_UNSKIP" = false ]; then
pytest_extra_args+=("--select-fail-on-missing")
fi
fi

python3 -u -m pytest "${pytest_extra_args[@]}" "$@" || $TRITON_TEST_IGNORE_ERRORS
Expand Down
45 changes: 0 additions & 45 deletions scripts/replace_skip_calls.py

This file was deleted.

21 changes: 6 additions & 15 deletions scripts/test-triton.sh
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ export TRITON_PROJ=$BASE/intel-xpu-backend-for-triton
export TRITON_PROJ_BUILD=$TRITON_PROJ/python/build
export SCRIPTS_DIR=$(cd $(dirname "$0") && pwd)

python3 -m pip install lit pytest pytest-xdist pytest-rerunfailures pytest-select pytest-timeout setuptools==69.5.1
python3 -m pip install lit pytest pytest-xdist pytest-rerunfailures pytest-select setuptools==69.5.1

if [ "$TRITON_TEST_WARNING_REPORTS" == true ]; then
python3 -m pip install git+https://github.com/kwasd/pytest-capturewarnings-ng@v1.2.0
Expand Down Expand Up @@ -145,16 +145,13 @@ run_core_tests() {
echo "***************************************************"
echo "****** Running Triton Core tests ******"
echo "***************************************************"
if [ "$TEST_UNSKIP" = true ]; then
CORE_TEST_DIR=$TRITON_PROJ/tmp/python/test/unit
else
CORE_TEST_DIR=$TRITON_PROJ/python/test/unit
fi
CORE_TEST_DIR=$TRITON_PROJ/python/test/unit

if [ ! -d "${CORE_TEST_DIR}" ]; then
echo "Not found '${CORE_TEST_DIR}'. Build Triton please" ; exit 3
fi
cd ${CORE_TEST_DIR}
export TEST_UNSKIP

TRITON_DISABLE_LINE_INFO=1 TRITON_TEST_SUITE=language \
pytest -vvv -n 8 --device xpu language/ --ignore=language/test_line_info.py --ignore=language/test_subprocess.py
Expand Down Expand Up @@ -182,11 +179,9 @@ run_regression_tests() {
echo "***************************************************"
echo "****** Running Triton Regression tests ******"
echo "***************************************************"
if [ "$TEST_UNSKIP" = true ]; then
REGRESSION_TEST_DIR=$TRITON_PROJ/tmp/python/test/regression
else
REGRESSION_TEST_DIR=$TRITON_PROJ/python/test/regression
fi
REGRESSION_TEST_DIR=$TRITON_PROJ/python/test/regression
export TEST_UNSKIP

if [ ! -d "${REGRESSION_TEST_DIR}" ]; then
echo "Not found '${REGRESSION_TEST_DIR}'. Build Triton please" ; exit 3
fi
Expand Down Expand Up @@ -221,10 +216,6 @@ run_tutorial_tests() {
}

test_triton() {
# generate dir ${TRITON_PROJ}/tmp/python/test/
if [ "$TEST_UNSKIP" = true ]; then
python ${SCRIPTS_DIR}/replace_skip_calls.py
fi
if [ "$TEST_UNIT" = true ]; then
run_unit_tests
fi
Expand Down

0 comments on commit 4ce54b4

Please sign in to comment.