Repository navigation
Commit 1eaa3c0
authored
test: Warm PowerShell before Windows round trips (#380)
TestReprPwshWindowsValidation fails intermittently on windows-latest
with subprocess.TimeoutExpired after 10 seconds. The first PowerShell
launch on a fresh hosted runner pays a one-time cold start that can
exceed the 10-second per-call timeout in _pwsh_eval, so whichever test
launches PowerShell first is killed, and a killed launch can leave the
next one cold too. Run 38812686088 (PR #379, a CHANGELOG-only change)
lost the first four tests of the class this way, each at about 10.1 s,
while the other nine passed. The same timeout appears in 8 of the last
60 Code Quality runs, on Python 3.10, 3.12, 3.13 and 3.14, and run
35389550086 passed on rerun at the same SHA.
Add a class-scoped autouse fixture that pays the cold start once, with
a 120-second deadline, through the same _pwsh_eval path the tests use:
a .ps1 file run with -File that calls Write-Output. It asserts the
output, so a broken PowerShell still fails the class instead of being
skipped. The per-call timeout stays at 10 seconds and no test
assertion changes. Mark the class timeout(180), because pytest-timeout
counts class-scoped fixture setup against the first test and the
project-wide --timeout=30 would otherwise cut a long warm-up short.
Verified on macOS with PowerShell 7.6.7 behind a shim that simulates
the cold start. The class is Windows-only, so this is a simulation,
not a Windows reproduction. Without the fix, a 41 s cold start fails
the same four tests as run 38812686088, at 10.01 s each, and a 12 s
cold start fails test_pwsh_string_simple_roundtrip alone. With the fix
both pass 13/13, and the cold start lands in the first test's setup.
Each of these mutants fails the class under a 41 s cold start: no
warm-up, a 10 s warm-up deadline, and no timeout marker.
Only repeated green Code Quality runs on real Windows runners prove
the fix. At roughly one failure in 50 Windows jobs, one green run is
weak evidence.
Signed-off-by: David Leong <116610336+leongdl@users.noreply.github.com>1 parent 5765225 commit 1eaa3c0
1 file changed
Lines changed: 13 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
650 | 650 | | |
651 | 651 | | |
652 | 652 | | |
| 653 | + | |
| 654 | + | |
653 | 655 | | |
654 | 656 | | |
655 | 657 | | |
656 | | - | |
| 658 | + | |
| 659 | + | |
| 660 | + | |
| 661 | + | |
| 662 | + | |
| 663 | + | |
| 664 | + | |
| 665 | + | |
| 666 | + | |
| 667 | + | |
657 | 668 | | |
658 | 669 | | |
659 | 670 | | |
| |||
667 | 678 | | |
668 | 679 | | |
669 | 680 | | |
670 | | - | |
| 681 | + | |
671 | 682 | | |
672 | 683 | | |
673 | 684 | | |
| |||
0 commit comments