Skip to content

Comments

refactor(coverage): improve coverage inside lifecycle hooks#574

Merged
Chemaclass merged 11 commits intoTypedDevs:mainfrom
omargallob:feat/omgallob/improve-coverage
Feb 22, 2026
Merged

refactor(coverage): improve coverage inside lifecycle hooks#574
Chemaclass merged 11 commits intoTypedDevs:mainfrom
omargallob:feat/omgallob/improve-coverage

Conversation

@omargallob
Copy link
Contributor

@omargallob omargallob commented Dec 28, 2025

📚 Description

Enable coverage tracking inside lifecycle hooks (set_up, tear_down, set_up_before_script, tear_down_after_script) so that code executed during test setup/teardown is properly attributed in coverage reports.

🔖 Changes

  • Enable coverage trap inside execute_file_hook and execute_test_hook in runner.sh
  • Add fallback to src/ when auto-discovery yields no coverage paths
  • Add acceptance tests for hook coverage functionality
  • Simplify DEBUG trap to avoid redundant should_track calls

✅ To-do list

  • I updated the CHANGELOG.md to reflect the new feature or fix
  • I updated the documentation to reflect the changes

@omargallob omargallob force-pushed the feat/omgallob/improve-coverage branch from dcb2d83 to acd1cc5 Compare December 28, 2025 12:46
@omargallob omargallob changed the title test: improve coverage refactor(coverage): improve coverage inside lifecycle hooks Dec 28, 2025
The src/ fallback is already handled in runner.sh after auto-discovery.
Having it in both places is redundant since runner.sh calls init()
after setting BASHUNIT_COVERAGE_PATHS.
The complex trap was:
- Redundant: record_line already calls should_track internally
- Semantically incorrect: used LINENO from frame 0 with BASH_SOURCE[1]
- Adding overhead: extra function call on every line executed

Revert to simple, efficient trap.
- Add SC2034 disable for environment variables used by bashunit
- Use explicit BASHUNIT_COVERAGE_PATHS="src/" instead of relying on fallback
Chemaclass added a commit that referenced this pull request Dec 29, 2025
The coverage tracking in lifecycle hooks feature causes parallel
test runs to hang indefinitely in GitHub Actions CI.

This reverts all changes from PR #574 until the root cause of
the parallel test hangs can be identified and fixed.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Chemaclass added a commit to omargallob/bashunit that referenced this pull request Dec 29, 2025
test runs to hang indefinitely in GitHub Actions CI.

This reverts all changes from PR TypedDevs#574 until the root cause of
the parallel test hangs can be identified and fixed.
@Chemaclass Chemaclass force-pushed the feat/omgallob/improve-coverage branch 3 times, most recently from 2521779 to 3d8b8ec Compare December 29, 2025 16:03
@Chemaclass Chemaclass force-pushed the main branch 2 times, most recently from e1804db to 526f6ec Compare February 9, 2026 23:48
Chemaclass and others added 5 commits February 22, 2026 02:38
Add timeout-minutes: 10 to 5 CI jobs that were missing it (alpine,
simple-output, simple/extended-output-parallel, strict-mode). Narrow
coverage hooks test scope from src/ to src/globals.sh, reducing runtime
from ~55s to ~2s.
…rallel hangs

Coverage enable/disable calls inside execute_file_hook and
execute_test_hook (which use set -eE + ERR trap) caused parallel
test runs to hang indefinitely on bash 5.2 in CI.

Move coverage trap management to caller functions where set -eE
is not active: run_set_up_before_script, run_tear_down_after_script,
and run_test's subshell (before set_up for test-level hooks).
The parent bashunit process exports BASHUNIT_PARALLEL_RUN=true when
running with --parallel. The coverage_hooks_test.sh subprocess inherits
this, causing it to run in parallel mode unintentionally, which leads
to hangs in CI.
@Chemaclass Chemaclass force-pushed the feat/omgallob/improve-coverage branch from ebd7805 to 63e7b6a Compare February 22, 2026 14:18
BSD date -j -f "%Y-%m-%d" fills time from current clock, causing
flaky parallel tests when two calls cross a second boundary. Append
00:00:00 to date-only inputs for deterministic conversion.

Also upgrade Bash 3.0 CI image from debian:bullseye-slim (EOL) to
debian:bookworm-slim for reliable package availability.
@Chemaclass Chemaclass added the refactoring Refactoring or cleaning related label Feb 22, 2026
@Chemaclass Chemaclass merged commit 2a2e24f into TypedDevs:main Feb 22, 2026
44 of 46 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

refactoring Refactoring or cleaning related

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants