Conversation
- Add tests for collectPackageIncludesRecursive covering: * Single includes * Optional includes with missing files * Include with section references * Nested includes * Duplicate include handling * Circular reference protection * Whitespace variations - Add tests for copyIncludeDependenciesFromPackageWithForce covering: * Single dependency copying * Skipping existing files without force flag * Overwriting with force flag * Optional missing file handling * Content comparison (skip if identical) * Nested directory creation * FileTracker integration (created/modified tracking) - Add tests for includePattern regex validation Coverage improvements: - collectPackageIncludesRecursive: 14.7% → 79.4% (+64.7%) - copyIncludeDependenciesFromPackageWithForce: 6.1% → 78.8% (+72.7%) - Overall: 68.0% → 68.2% (+0.2%)
There was a problem hiding this comment.
Pull Request Overview
This PR adds comprehensive unit test coverage for two critical functions in pkg/cli/packages.go that were previously undertested: collectPackageIncludesRecursive() (14.7% → 79.4% coverage) and copyIncludeDependenciesFromPackageWithForce() (6.1% → 78.8% coverage). These functions handle recursive include directive parsing and file copying operations for package-based workflows.
Key Changes
- Added 519 lines of test code covering 107 test cases across multiple scenarios
- Implemented table-driven tests for include dependency collection with nested, optional, and circular reference handling
- Added tests for file copying operations including force flag behavior, content comparison, and FileTracker integration
- Included regex pattern validation tests for the
@includedirective parsing
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| filepath.Walk(targetDir, func(path string, info os.FileInfo, err error) error { | ||
| if err == nil && !info.IsDir() { | ||
| fileCount++ | ||
| } | ||
| return nil | ||
| }) |
There was a problem hiding this comment.
The filepath.Walk function can return an error, but this implementation ignores it by always returning nil in the walk function. The error parameter should be checked, and if non-nil, the function should return it immediately to stop the walk and propagate the error.
Consider updating to:
err := filepath.Walk(targetDir, func(path string, info os.FileInfo, err error) error {
if err != nil {
return err
}
if !info.IsDir() {
fileCount++
}
return nil
})
if err != nil {
t.Errorf("Failed to walk target directory: %v", err)
}| filepath.Walk(targetDir, func(path string, info os.FileInfo, err error) error { | |
| if err == nil && !info.IsDir() { | |
| fileCount++ | |
| } | |
| return nil | |
| }) | |
| err = filepath.Walk(targetDir, func(path string, info os.FileInfo, err error) error { | |
| if err != nil { | |
| return err | |
| } | |
| if !info.IsDir() { | |
| fileCount++ | |
| } | |
| return nil | |
| }) | |
| if err != nil { | |
| t.Errorf("Failed to walk target directory: %v", err) | |
| } |
Daily Test Coverage Improver - Include Dependency Functions
This PR adds comprehensive unit tests for previously untested functions in
pkg/cli/packages.go.Summary of Changes
Added
pkg/cli/packages_test.gowith 519 lines of test code covering two critical low-coverage functions:collectPackageIncludesRecursive()Tests@includedirective processing@include? with missing filescopyIncludeDependenciesFromPackageWithForce()TestsincludePatternRegex Tests@includeand@include? patternsProblems Found
During coverage analysis, I identified two critical functions in
pkg/cli/packages.gowith very low test coverage:collectPackageIncludesRecursive()- 14.7% coveragecopyIncludeDependenciesFromPackageWithForce()- 6.1% coverageThese functions handle complex file system operations including:
The low coverage created risk for edge case failures and regression bugs.
Actions Taken
Created comprehensive unit tests covering:
All tests follow Go testing best practices:
t.TempDir()Test Coverage Results
Replicating the Test Coverage Measurements
Possible Other Areas for Future Improvement
Based on coverage analysis, here are high-value targets for future test additions:
CLI Package (low-hanging fruit):
pkg/cli/init_command.go- 0% coverage - Init command functionalitypkg/cli/jq.go- 0% coverage - JQ filtering utilitypkg/cli/mcp.go- 0% coverage - MCP command entry pointpkg/cli/mcp_server.go- 0% coverage - MCP server managementpkg/cli/status.go- 0% coverage - Workflow status displaypkg/cli/update_command.go- 9.6% coverage - Update commandWorkflow Package:
7.
pkg/workflow/npm_validation.go- 0% coverage - NPM package validation8.
pkg/workflow/pip_validation.go- 0% coverage - PIP package validation9.
pkg/cli/packages.go:listWorkflowsInPackage- 42.9% coverage - Workflow listingVerification
All tests run successfully: