Commit f4957e6
fix(testing): respect TestRunRequest.exclude when running tests
The VS Code Test Explorer API specifies that TestRunRequest.exclude
contains tests the user has marked as excluded (e.g., via filtering).
Per the API contract, "exclusions should apply after inclusions."
Previously, the Python extension ignored request.exclude entirely,
causing "Run Tests" to run all tests even when the user had filtered
the Test Explorer view. This fix adds exclude handling at two levels:
1. In getTestItemsForWorkspace(): Filter out excluded items before
passing to the test adapter (checks ancestors for top-level items)
2. In WorkspaceTestAdapter.executeTests(): Pre-expand the exclude set
to include all descendants, then pass to getTestCaseNodes() which
skips excluded nodes with O(1) set lookups during traversal
Also adds a visited set to getTestCaseNodes() to avoid expanding
the same node multiple times when includes contains overlapping items.
Fixes the issue where filtering tests in Test Explorer (e.g., by tag)
and clicking "Run Tests" would still run all tests.
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>1 parent c8b6f50 commit f4957e6
File tree
3 files changed
+74
-13
lines changed- src/client/testing/testController
- common
3 files changed
+74
-13
lines changedLines changed: 57 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
498 | 498 | | |
499 | 499 | | |
500 | 500 | | |
501 | | - | |
| 501 | + | |
| 502 | + | |
| 503 | + | |
| 504 | + | |
| 505 | + | |
| 506 | + | |
| 507 | + | |
| 508 | + | |
| 509 | + | |
| 510 | + | |
| 511 | + | |
| 512 | + | |
| 513 | + | |
| 514 | + | |
| 515 | + | |
| 516 | + | |
| 517 | + | |
| 518 | + | |
| 519 | + | |
| 520 | + | |
| 521 | + | |
| 522 | + | |
| 523 | + | |
| 524 | + | |
| 525 | + | |
| 526 | + | |
| 527 | + | |
| 528 | + | |
| 529 | + | |
| 530 | + | |
| 531 | + | |
| 532 | + | |
| 533 | + | |
| 534 | + | |
| 535 | + | |
| 536 | + | |
| 537 | + | |
| 538 | + | |
| 539 | + | |
| 540 | + | |
| 541 | + | |
| 542 | + | |
| 543 | + | |
| 544 | + | |
| 545 | + | |
| 546 | + | |
| 547 | + | |
| 548 | + | |
| 549 | + | |
| 550 | + | |
| 551 | + | |
| 552 | + | |
| 553 | + | |
| 554 | + | |
| 555 | + | |
| 556 | + | |
502 | 557 | | |
503 | 558 | | |
504 | 559 | | |
505 | 560 | | |
506 | 561 | | |
507 | 562 | | |
508 | | - | |
| 563 | + | |
509 | 564 | | |
510 | 565 | | |
511 | 566 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
34 | 34 | | |
35 | 35 | | |
36 | 36 | | |
37 | | - | |
| 37 | + | |
38 | 38 | | |
39 | 39 | | |
40 | 40 | | |
| |||
507 | 507 | | |
508 | 508 | | |
509 | 509 | | |
| 510 | + | |
510 | 511 | | |
511 | 512 | | |
512 | 513 | | |
| 514 | + | |
513 | 515 | | |
514 | 516 | | |
515 | | - | |
| 517 | + | |
516 | 518 | | |
517 | 519 | | |
518 | 520 | | |
| |||
566 | 568 | | |
567 | 569 | | |
568 | 570 | | |
| 571 | + | |
569 | 572 | | |
570 | 573 | | |
571 | 574 | | |
| |||
Lines changed: 12 additions & 9 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
9 | 9 | | |
10 | 10 | | |
11 | 11 | | |
12 | | - | |
| 12 | + | |
13 | 13 | | |
14 | 14 | | |
15 | 15 | | |
| |||
47 | 47 | | |
48 | 48 | | |
49 | 49 | | |
| 50 | + | |
50 | 51 | | |
51 | 52 | | |
52 | 53 | | |
| |||
57 | 58 | | |
58 | 59 | | |
59 | 60 | | |
60 | | - | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
61 | 65 | | |
62 | | - | |
| 66 | + | |
| 67 | + | |
63 | 68 | | |
64 | | - | |
65 | | - | |
| 69 | + | |
66 | 70 | | |
67 | | - | |
| 71 | + | |
68 | 72 | | |
69 | | - | |
| 73 | + | |
70 | 74 | | |
71 | 75 | | |
72 | | - | |
| 76 | + | |
73 | 77 | | |
74 | 78 | | |
75 | | - | |
76 | 79 | | |
77 | 80 | | |
78 | 81 | | |
| |||
0 commit comments