Skip to content

Commit 989e82c

Browse files
authored
Run tests individually (#1847)
<!-- .github/pull_request_template.md --> ## πŸ“Œ Description - Tests now run individually instead as opposed to with entire directry - This helps avoid IMAs to propagate to other tests - Also moved unlisted tests into their proper category ## πŸ” Related Issues <!-- Link any related issues here --> ## πŸš€ Pull Request Checklist Thank you for contributing to FlashInfer! Before we review your pull request, please make sure the following items are complete. ### βœ… Pre-commit Checks - [x] I have installed `pre-commit` by running `pip install pre-commit` (or used your preferred method). - [x] I have installed the hooks with `pre-commit install`. - [x] I have run the hooks manually with `pre-commit run --all-files` and fixed any reported issues. > If you are unsure about how to set up `pre-commit`, see [the pre-commit documentation](https://pre-commit.com/). ## πŸ§ͺ Tests - [x] Tests have been added or updated as needed. - [ ] All tests are passing (`unittest`, etc.). ## Reviewer Notes <!-- Optional: anything you'd like reviewers to focus on, concerns, etc. -->
1 parent b6e4da8 commit 989e82c

File tree

4 files changed

+40
-76
lines changed

4 files changed

+40
-76
lines changed

β€Žpytest.iniβ€Ž

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
[pytest]
2-
norecursedirs = test_helpers, unlisted
2+
norecursedirs = test_helpers

β€Žscripts/task_test_blackwell_kernels.shβ€Ž

Lines changed: 39 additions & 75 deletions
Original file line numberDiff line numberDiff line change
@@ -35,43 +35,44 @@ if [ -f "./pytest.ini" ]; then
3535
fi
3636
fi
3737

38-
echo "Finding test subdirectories in tests/ directory..."
38+
echo "Finding all test_*.py files in tests/ directory..."
3939

40-
# Find all subdirectories that contain test_*.py files
41-
ALL_TEST_DIRS=$(find tests/ -name "test_*.py" -type f -exec dirname {} \; | sort -u)
40+
# Find all test_*.py files
41+
ALL_TEST_FILES=$(find tests/ -name "test_*.py" -type f | sort)
42+
43+
# Filter out excluded files based on directory exclusions
44+
TEST_FILES=""
45+
for test_file in $ALL_TEST_FILES; do
46+
exclude_file=false
47+
test_dir=$(dirname "$test_file")
4248

43-
# Filter out excluded directories
44-
TEST_DIRS=""
45-
for test_dir in $ALL_TEST_DIRS; do
46-
exclude_dir=false
4749
for excluded_dir in $EXCLUDED_DIRS; do
4850
excluded_dir=$(echo "$excluded_dir" | xargs) # trim whitespace
4951
if [ -n "$excluded_dir" ]; then
50-
# Check if this directory should be excluded
52+
# Check if this file's directory should be excluded
5153
if [[ "$test_dir" == *"/$excluded_dir" ]] || [[ "$test_dir" == "tests/$excluded_dir" ]] || [[ "$test_dir" == *"/$excluded_dir/"* ]]; then
52-
exclude_dir=true
54+
exclude_file=true
5355
break
5456
fi
5557
fi
5658
done
5759

58-
if [ "$exclude_dir" = false ]; then
59-
TEST_DIRS="$TEST_DIRS $test_dir"
60+
if [ "$exclude_file" = false ]; then
61+
TEST_FILES="$TEST_FILES $test_file"
6062
fi
6163
done
6264

6365
# Clean up whitespace
64-
TEST_DIRS=$(echo "$TEST_DIRS" | xargs)
66+
TEST_FILES=$(echo "$TEST_FILES" | xargs)
6567

66-
if [ -z "$TEST_DIRS" ]; then
67-
echo "No test directories found in tests/ directory (after exclusions)"
68+
if [ -z "$TEST_FILES" ]; then
69+
echo "No test files found in tests/ directory (after exclusions)"
6870
exit 1
6971
fi
7072

71-
echo "Found test directories:"
72-
for test_dir in $TEST_DIRS; do
73-
test_count=$(find "$test_dir" -maxdepth 1 -name "test_*.py" -type f | wc -l)
74-
echo " $test_dir ($test_count test files)"
73+
echo "Found test files:"
74+
for test_file in $TEST_FILES; do
75+
echo " $test_file"
7576
done
7677
echo ""
7778

@@ -84,81 +85,44 @@ if [ "$DRY_RUN" == "true" ]; then
8485
echo "DRY RUN: Tests that would be executed"
8586
echo "=========================================="
8687

87-
for test_dir in $TEST_DIRS; do
88-
if [ "$test_dir" == "tests/utils" ] || [ "$test_dir" == "tests/comm" ]; then
89-
# Run utils and comm tests individually for debugging
90-
echo ""
91-
echo "πŸ“ NOTE: $test_dir will be run individually for debugging"
92-
test_files=$(find "$test_dir" -maxdepth 1 -name "test_*.py" -type f | sort)
93-
for test_file in $test_files; do
94-
TOTAL_TESTS=$((TOTAL_TESTS + 1))
95-
echo "$TOTAL_TESTS. pytest $test_file"
96-
done
97-
else
98-
# Run other directories as groups
99-
TOTAL_TESTS=$((TOTAL_TESTS + 1))
100-
test_count=$(find "$test_dir" -maxdepth 1 -name "test_*.py" -type f | wc -l)
101-
echo "$TOTAL_TESTS. pytest $test_dir (contains $test_count test files)"
102-
fi
88+
for test_file in $TEST_FILES; do
89+
TOTAL_TESTS=$((TOTAL_TESTS + 1))
90+
echo "$TOTAL_TESTS. pytest $PYTEST_FLAGS $test_file"
10391
done
10492

10593
echo ""
10694
echo "=========================================="
10795
echo "DRY RUN SUMMARY"
10896
echo "=========================================="
109-
echo "Total test commands that would be executed: $TOTAL_TESTS"
97+
echo "Total test files that would be executed: $TOTAL_TESTS"
11098
echo ""
11199
echo "To actually run the tests, execute without --dry-run:"
112100
echo " $0"
113101
echo "Or set DRY_RUN=false $0"
114102
else
115-
for test_dir in $TEST_DIRS; do
116-
if [ "$test_dir" == "tests/utils" ] || [ "$test_dir" == "tests/comm" ]; then
117-
# Run utils and comm tests individually for debugging
118-
echo "=========================================="
119-
echo "Running $test_dir individually for debugging"
120-
echo "=========================================="
121-
122-
test_files=$(find "$test_dir" -maxdepth 1 -name "test_*.py" -type f | sort)
123-
for test_file in $test_files; do
124-
echo "Running: pytest $test_file"
125-
TOTAL_TESTS=$((TOTAL_TESTS + 1))
126-
127-
if pytest "$test_file" $PYTEST_FLAGS; then
128-
echo "βœ… PASSED: $test_file"
129-
PASSED_TESTS=$((PASSED_TESTS + 1))
130-
else
131-
echo "❌ FAILED: $test_file"
132-
FAILED_TESTS="$FAILED_TESTS\n - $test_file"
133-
EXIT_CODE=1
134-
fi
135-
echo ""
136-
done
137-
else
138-
# Run other directories as groups
139-
echo "=========================================="
140-
echo "Running: pytest $test_dir"
141-
echo "=========================================="
142-
143-
TOTAL_TESTS=$((TOTAL_TESTS + 1))
144-
145-
if pytest "$test_dir" $PYTEST_FLAGS; then
146-
echo "βœ… PASSED: $test_dir"
147-
PASSED_TESTS=$((PASSED_TESTS + 1))
148-
else
149-
echo "❌ FAILED: $test_dir"
150-
FAILED_TESTS="$FAILED_TESTS\n - $test_dir"
151-
EXIT_CODE=1
152-
fi
103+
for test_file in $TEST_FILES; do
104+
echo "=========================================="
105+
echo "Running: pytest $PYTEST_FLAGS $test_file"
106+
echo "=========================================="
153107

154-
echo ""
108+
TOTAL_TESTS=$((TOTAL_TESTS + 1))
109+
110+
if pytest $PYTEST_FLAGS "$test_file"; then
111+
echo "βœ… PASSED: $test_file"
112+
PASSED_TESTS=$((PASSED_TESTS + 1))
113+
else
114+
echo "❌ FAILED: $test_file"
115+
FAILED_TESTS="$FAILED_TESTS\n - $test_file"
116+
EXIT_CODE=1
155117
fi
118+
119+
echo ""
156120
done
157121

158122
echo "=========================================="
159123
echo "TEST SUMMARY"
160124
echo "=========================================="
161-
echo "Total test commands executed: $TOTAL_TESTS"
125+
echo "Total test files executed: $TOTAL_TESTS"
162126
echo "Passed: $PASSED_TESTS"
163127
echo "Failed: $((TOTAL_TESTS - PASSED_TESTS))"
164128

File renamed without changes.
File renamed without changes.

0 commit comments

Comments
Β (0)