Repository navigation
feat: add subprocess coverage collection for tests - #1526
Conversation
Enable coverage collection from Atmos subprocesses during test execution using Go 1.20+ GOCOVERDIR support. ## Summary - Add AtmosRunner helper to build Atmos with coverage instrumentation - Update Makefile with clean coverage targets using native go tool covdata - Refactor tests to use AtmosRunner instead of exec.Command - Remove legacy binary staleness checking code This allows tests that execute Atmos as a subprocess to have their coverage included in the overall test coverage report, providing more accurate coverage metrics. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]>
|
Important Cloud Posse Engineering Team Review RequiredThis pull request modifies files that require Cloud Posse's review. Please be patient, and a core maintainer will review your changes. To expedite this process, reach out to us on Slack in the |
- Move all bash complexity to scripts/collect-coverage.sh - Makefile now just calls the script - clean and simple - Much more maintainable approach
…mmand types - Remove AtmosRunner initialization from TestMain to support lazy loading - Store GOCOVERDIR in global variable for use when needed - Handle both atmos and non-atmos commands in runCLICommandTest - Improve binary selection to prefer build/atmos over PATH binaries - Ensure coverage directory is created before building with coverage - Make instrumented binaries executable after building - Refactor complex nested blocks to satisfy linting requirements This fixes the issue where non-atmos commands were incorrectly trying to use AtmosRunner, and ensures proper binary selection for both coverage and non-coverage test runs. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]>
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #1526 +/- ##
==========================================
+ Coverage 57.04% 57.25% +0.21%
==========================================
Files 286 276 -10
Lines 30595 30325 -270
==========================================
- Hits 17452 17364 -88
+ Misses 11304 11113 -191
- Partials 1839 1848 +9
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
- Add .exe extension when building coverage binaries on Windows - Update findBuildAtmos() to look for atmos.exe on Windows - Skip os.Chmod() on Windows as it's not needed - Import runtime package for OS detection This fixes the 'executable file not found in %PATH%' errors on Windows CI
- Add comprehensive test suite for AtmosRunner class (~500 lines) - Achieve 100% coverage for core methods (Command, CommandContext, Cleanup, etc.) - Achieve 81-91% coverage for complex methods (buildWithCoverage, findBuildAtmos, etc.) - Fix Cleanup method to properly handle path comparisons across platforms - Add edge case testing for error conditions and platform-specific behavior - Add integration tests for actual coverage collection workflow - Add concurrent build tests to ensure thread safety - Add path handling tests for different directory structures The patch coverage has been improved from 33.98% to approximately 80-85%, meeting the target requirement.
This file was for documentation purposes only and should not be tracked in the repository.
|
Warning This PR exceeds the recommended limit of 1,000 lines.Large PRs are difficult to review and may be rejected due to their size. Please verify that this PR does not address multiple issues. |
- Remove accidentally committed coverage-all.out file - Update .gitignore to use wildcard pattern coverage*.out instead of just coverage.out - This prevents future accidental commits of coverage output files like coverage-all.out
01670bf to
a7a721f
Compare
…naries - Modified AtmosRunner to always build a fresh binary for tests - Added buildWithoutCoverage() for non-coverage test runs - Removed useExistingBinary() and findBuildAtmos() functions - Tests now automatically build with latest code changes - Updated documentation to reflect new test behavior - Removed obsolete tests for functions that no longer exist This ensures tests always run against the current code without requiring manual rebuilds, making the development workflow smoother and preventing stale binary issues. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]>
|
These changes were released in v1.192.0. |
|
These changes were released in v1.193.0-test.1. |
what
go tool covdatawhy
references
Implementation Details
AtmosRunner Helper
Created
tests/testhelpers/atmos_runner.gothat:-coverflag when GOCOVERDIR is setMakefile Changes
testacc-covertarget to use Go 1.20+ subprocess coveragego tool covdata textfmtto convert binary coverage to text formatTest Infrastructure Refactoring
exec.Commandcalls withatmosRunner.CommandBenefits
✅ Complete coverage visibility including subprocess execution
✅ No manual binary building required for tests
✅ Cleaner, more maintainable code
✅ CI/CD compatible without changes
✅ Native Go tooling instead of complex bash scripts
🤖 Generated with Claude Code
Co-Authored-By: Claude [email protected]