Skip to content
Merged
Show file tree
Hide file tree
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
1 change: 1 addition & 0 deletions .github/labeler.yml
Original file line number Diff line number Diff line change
Expand Up @@ -146,5 +146,6 @@ tests:
- 'pytest.ini'
# NOTE: This directory also contains DSA, FLA operator tests
- 'tests/**'
- 'benchmark/**'
# TODO: Move test scripts to tests/scripts
- 'tools/**'
35 changes: 21 additions & 14 deletions tools/test-op.sh
Original file line number Diff line number Diff line change
Expand Up @@ -27,30 +27,29 @@ fi
# Test cases that needs to run quick cpu tests
NO_QUICK_CPU_TESTS=(
"tests/ks_tests.py"
"tests/test_conv3d.py"
"tests/test_convolution_ops.py"
"tests/test_distribution_ops.py"
"tests/test_enable_api.py"
"tests/test_libentry.py"
"tests/test_pointwise_type_promotion.py"
"tests/test_quant.py"
"tests/test_shape_utils.py"
"tests/test_tensor_wrapper.py"
"tests/test_vllm_ops.py"
)

# Extract test cases from CHANGED_FILES
TEST_CASES=()
PERF_TEST_CASES=()
TEST_CASES_CPU=()
for item in $CHANGED_FILES; do
case $item in
# tests/test_DSA/*)
# skip DSA test for now
# ;;
tests/test_quant.py)
# skip because it always fail
;;
tests/*) TEST_CASES+=($item)
tests/*)
TEST_CASES+=($item)
;;
benchmark/*)
PERF_TEST_CASES+=($item)
;;
esac

# filter out tests that do not need quick CPU mode tests
Expand All @@ -69,7 +68,7 @@ for item in $CHANGED_FILES; do
done

# Skip tests if no tests file is found
if [ ${#TEST_CASES[@]} -eq 0 ]; then
if [ ${#TEST_CASES[@]} -eq 0 && ${#PERF_TEST_CASES[@]} -eq 0 ]; then
exit 0
fi

Expand All @@ -78,13 +77,21 @@ coverage erase

echo "Running unit tests for ${TEST_CASES[@]}"
# TODO(Qiming): Check if utils test should use a different data file
coverage run -m pytest -s ${EXTRA_OPTS} ${TEST_CASES[@]}
for item in "${TEST_CASES[@]}"; do
coverage run -m pytest -s ${EXTRA_OPTS} ${item}
done

# Run quick-cpu test if necessary
if [[ ${#TEST_CASES_CPU[@]} -ne 0 ]]; then
echo "Running quick-cpu mode unit tests for ${TEST_CASES_CPU[@]}"
coverage run -m pytest -s ${EXTRA_OPTS} ${TEST_CASES_CPU[@]} --ref=cpu --quick
fi
for item in "${TEST_CASES_CPU[@]}"; do
echo "Running quick-cpu mode unit tests for ${item}"
coverage run -m pytest -s ${EXTRA_OPTS} ${item} --ref=cpu --quick
done

# Run benchmark test if necessary
for item in "${PERF_TEST_CASES[@]}"; do
echo "Running benchmark tests for ${item}"
pytest -s --level core --record log ${item}
done

# Process coverage data only when full-range testing
# Coverage data HTML dumped to `htmlcov/` by default
Expand Down
Loading