Commit 167c2f3
committed
fix(tests,health): isolate HOME in E2E gates + detect empty version segment (#1490)
Two Critical issues surfaced in CI (e2e-plugin-hooks/3.11) that the
local pre-push check missed because the developer/runner HOME leaked
into pytest subprocess invocations:
1. **TestHudInstallE2ERegressionGate all 4 scenarios FAILED on CI**
with `assert "CB v" in out` because
``hud_version.get_fresh_version``'s tier-1 lookup reads
``~/.claude/plugins/installed_plugins.json`` and CI has none. The
render therefore produced ``CB | Ready 🟢 | ...`` — a silent
half-broken state where every module imports successfully but the
version segment is empty. Locally the same test passed only
because the developer's real ``~/.claude/plugins/installed_plugins.json``
(v5.6.1) leaked into the subprocess.
Fix: the test now writes a stub
``installed_plugins.json`` into the tmpdir fake home and invokes
the subprocess with ``env={"HOME": str(home), ...}`` so all three
version-resolution tiers (tier 1 installed_plugins.json, tier 2
plugin.json, tier 3 hud_state) see the isolated environment.
Assertion is strengthened to ``CB v<expected_version>`` with
``expected_version`` read from ``plugin.json`` so future
bump-version.sh runs auto-gate. A ``.version`` stamp assertion
is also added per scenario.
The simulation shell script (commit 8) was already hardened this
way; this commit brings the pytest E2E suite to parity so CI and
local runs agree.
2. **check_hud_installation smoke test did not detect empty version**
— it only compared against the literal fallback face, so the
``CB | Ready ...`` half-broken state returned PASS even though
the user would see a status line with a missing version segment.
Fix: ``check_hud_installation`` now detects ``"CB "`` without
``"CB v"`` in the rendered output and returns FAIL with a clear
message ("HUD rendered empty version segment — hud_version
fallback chain broken"). The subprocess call also pins
``HOME=self._home_dir`` so the diagnostic honours the
HealthChecker's configured home directory rather than leaking the
CI runner's real home. A new regression test
``test_fail_when_version_segment_is_empty`` stubs a script that
prints the half-broken line and asserts the check FAILs.
3. **test_pass_with_real_plugin_install** (health_check green-path
gate) now writes the same fake ``installed_plugins.json`` so the
subprocess check_hud_installation invokes can resolve the plugin
version inside the isolated environment.
Local verification:
$ python3 -m pytest tests/test_session_start_hud.py tests/test_health_check.py -v
... 56 passed in 0.90s
$ bash packages/claude-code-plugin/scripts/verify-install-simulation.sh
[verify-install-simulation] PASS: full status line rendered (v5.6.2)
Refs #14901 parent 0ab3378 commit 167c2f3
3 files changed
Lines changed: 134 additions & 4 deletions
File tree
- packages/claude-code-plugin
- hooks/lib
- tests
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
306 | 306 | | |
307 | 307 | | |
308 | 308 | | |
309 | | - | |
| 309 | + | |
| 310 | + | |
| 311 | + | |
| 312 | + | |
| 313 | + | |
| 314 | + | |
| 315 | + | |
| 316 | + | |
| 317 | + | |
| 318 | + | |
| 319 | + | |
| 320 | + | |
| 321 | + | |
| 322 | + | |
310 | 323 | | |
311 | 324 | | |
312 | 325 | | |
313 | 326 | | |
314 | 327 | | |
315 | 328 | | |
316 | 329 | | |
| 330 | + | |
317 | 331 | | |
318 | | - | |
| 332 | + | |
| 333 | + | |
319 | 334 | | |
320 | 335 | | |
321 | 336 | | |
322 | 337 | | |
323 | 338 | | |
| 339 | + | |
| 340 | + | |
| 341 | + | |
| 342 | + | |
| 343 | + | |
| 344 | + | |
| 345 | + | |
| 346 | + | |
| 347 | + | |
| 348 | + | |
| 349 | + | |
324 | 350 | | |
325 | 351 | | |
326 | 352 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
415 | 415 | | |
416 | 416 | | |
417 | 417 | | |
| 418 | + | |
| 419 | + | |
| 420 | + | |
| 421 | + | |
| 422 | + | |
| 423 | + | |
| 424 | + | |
| 425 | + | |
| 426 | + | |
| 427 | + | |
| 428 | + | |
| 429 | + | |
| 430 | + | |
| 431 | + | |
| 432 | + | |
| 433 | + | |
| 434 | + | |
| 435 | + | |
| 436 | + | |
| 437 | + | |
| 438 | + | |
| 439 | + | |
| 440 | + | |
| 441 | + | |
| 442 | + | |
| 443 | + | |
| 444 | + | |
418 | 445 | | |
419 | 446 | | |
420 | 447 | | |
421 | 448 | | |
422 | 449 | | |
423 | 450 | | |
424 | 451 | | |
| 452 | + | |
425 | 453 | | |
426 | 454 | | |
427 | 455 | | |
| |||
437 | 465 | | |
438 | 466 | | |
439 | 467 | | |
| 468 | + | |
| 469 | + | |
| 470 | + | |
| 471 | + | |
| 472 | + | |
| 473 | + | |
| 474 | + | |
| 475 | + | |
| 476 | + | |
| 477 | + | |
| 478 | + | |
| 479 | + | |
| 480 | + | |
| 481 | + | |
| 482 | + | |
| 483 | + | |
| 484 | + | |
| 485 | + | |
| 486 | + | |
| 487 | + | |
| 488 | + | |
| 489 | + | |
| 490 | + | |
| 491 | + | |
| 492 | + | |
| 493 | + | |
440 | 494 | | |
441 | 495 | | |
442 | 496 | | |
| |||
450 | 504 | | |
451 | 505 | | |
452 | 506 | | |
| 507 | + | |
Lines changed: 51 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
362 | 362 | | |
363 | 363 | | |
364 | 364 | | |
| 365 | + | |
| 366 | + | |
| 367 | + | |
| 368 | + | |
| 369 | + | |
| 370 | + | |
| 371 | + | |
| 372 | + | |
| 373 | + | |
| 374 | + | |
| 375 | + | |
| 376 | + | |
| 377 | + | |
| 378 | + | |
| 379 | + | |
| 380 | + | |
| 381 | + | |
| 382 | + | |
| 383 | + | |
| 384 | + | |
| 385 | + | |
| 386 | + | |
| 387 | + | |
| 388 | + | |
| 389 | + | |
| 390 | + | |
| 391 | + | |
| 392 | + | |
| 393 | + | |
365 | 394 | | |
366 | 395 | | |
367 | 396 | | |
| |||
405 | 434 | | |
406 | 435 | | |
407 | 436 | | |
408 | | - | |
| 437 | + | |
| 438 | + | |
| 439 | + | |
| 440 | + | |
409 | 441 | | |
410 | 442 | | |
411 | 443 | | |
| |||
416 | 448 | | |
417 | 449 | | |
418 | 450 | | |
| 451 | + | |
| 452 | + | |
| 453 | + | |
| 454 | + | |
| 455 | + | |
| 456 | + | |
419 | 457 | | |
420 | 458 | | |
421 | 459 | | |
422 | 460 | | |
423 | 461 | | |
424 | 462 | | |
| 463 | + | |
425 | 464 | | |
426 | 465 | | |
427 | 466 | | |
| |||
436 | 475 | | |
437 | 476 | | |
438 | 477 | | |
439 | | - | |
| 478 | + | |
| 479 | + | |
| 480 | + | |
| 481 | + | |
| 482 | + | |
| 483 | + | |
440 | 484 | | |
441 | 485 | | |
| 486 | + | |
| 487 | + | |
| 488 | + | |
| 489 | + | |
| 490 | + | |
0 commit comments