Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit fc57173

Browse files
committed
Let upgrade-pylib command to invetigate failing tests
1 parent 8126d2a commit fc57173

File tree

2 files changed

+58
-5
lines changed

2 files changed

+58
-5
lines changed
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
---
2+
allowed-tools: Bash(python3:*), Bash(cargo run:*), Read, Grep, Glob, Bash(git add:*), Bash(git commit:*)
3+
---
4+
5+
# Investigate Test Failure
6+
7+
Investigate why a specific test is failing and determine if it can be fixed or needs an issue.
8+
9+
## Arguments
10+
- `$ARGUMENTS`: Failed test identifier (e.g., `test_inspect.TestGetSourceBase.test_getsource_reload`)
11+
12+
## Steps
13+
14+
1. **Analyze failure cause**
15+
- Read the test code
16+
- Analyze failure message/traceback
17+
- Check related RustPython code
18+
19+
2. **Verify behavior in CPython**
20+
- Run the test with `python3 -m unittest` to confirm expected behavior
21+
- Document the expected output
22+
23+
3. **Determine fix feasibility**
24+
- **Simple fix** (import issues, small logic bugs): Fix and commit
25+
- **Complex fix** (major unimplemented features): Collect issue info and report to user
26+
27+
4. **For complex issues - Collect issue information**
28+
Following `.github/ISSUE_TEMPLATE/report-incompatibility.md` format:
29+
30+
- **Feature**: Description of missing/broken Python feature
31+
- **Minimal reproduction code**: Smallest code that reproduces the issue
32+
- **CPython behavior**: Result when running with python3
33+
- **RustPython behavior**: Result when running with cargo run
34+
- **Python Documentation link**: Link to relevant CPython docs
35+
36+
Report collected information to the user. Issue creation is done only upon user request.
37+
38+
Example issue creation command:
39+
```
40+
gh issue create --template report-incompatibility.md --title "..." --body "..."
41+
```

.claude/commands/upgrade-pylib.md

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -48,15 +48,27 @@ This helps improve the tooling for future upgrades.
4848
- **Do NOT restore other diff changes** - these are likely upstream CPython changes, not RustPython-specific modifications
4949
- When restoring, preserve the original context and formatting
5050

51-
3. **Mark remaining test failures with auto-mark**
51+
3. **Investigate test failures with subagent**
52+
- First, run tests to collect the list of failures:
53+
```
54+
cargo run --release -- -m unittest test.$ARGUMENTS -v 2>&1 | grep -E "^(FAIL|ERROR):"
55+
```
56+
- For each failure, use the Task tool with `general-purpose` subagent to investigate:
57+
- Subagent should follow the `/investigate-test-failure` skill workflow
58+
- Pass the failed test identifier as the argument (e.g., `test_inspect.TestGetSourceBase.test_getsource_reload`)
59+
- If subagent can fix the issue easily: fix and commit
60+
- If complex issue: subagent collects issue info and reports back (issue creation on user request only)
61+
- Using subagent prevents context pollution in the main conversation
62+
63+
4. **Mark remaining test failures with auto-mark**
5264
- Run: `python3 scripts/update_lib auto-mark Lib/test/test_$ARGUMENTS.py --mark-failure`
5365
- Or for directory: `python3 scripts/update_lib auto-mark Lib/test/test_$ARGUMENTS/ --mark-failure`
5466
- This will:
5567
- Run tests and mark ALL failing tests with `@unittest.expectedFailure`
5668
- Remove `@unittest.expectedFailure` from tests that now pass
5769
- **Note**: The `--mark-failure` flag marks all failures including regressions. Review the changes before committing.
5870
59-
4. **Handle panics manually**
71+
5. **Handle panics manually**
6072
- If any tests cause panics/crashes (not just assertion failures), they need `@unittest.skip` instead:
6173
```python
6274
@unittest.skip("TODO: RUSTPYTHON; panics with 'index out of bounds'")
@@ -65,7 +77,7 @@ This helps improve the tooling for future upgrades.
6577
```
6678
- auto-mark cannot detect panics automatically - check the test output for crash messages
6779
68-
5. **Handle class-specific failures**
80+
6. **Handle class-specific failures**
6981
- If a test fails only in the C implementation (TestCFoo) but passes in the Python implementation (TestPyFoo), or vice versa, move the marker to the specific subclass:
7082
```python
7183
# Base class - no marker here
@@ -82,9 +94,9 @@ This helps improve the tooling for future upgrades.
8294
return super().test_something()
8395
```
8496
85-
6. **Commit the test fixes**
97+
7. **Commit the test fixes**
8698
- Run: `git add -u && git commit -m "Mark failing tests"`
87-
- This creates a separate commit for the test markers added in steps 2-5
99+
- This creates a separate commit for the test markers added in steps 2-6
88100
89101
## Example Usage
90102
```

0 commit comments

Comments
 (0)