Increase test coverage for compiler_jobs.go job orchestration logic#14419
Increase test coverage for compiler_jobs.go job orchestration logic#14419
Conversation
- Added 15 new test functions (22 → 37 total) - Increased test lines from 1241 to 1968 (added 727 lines) - Achieved test/source ratio of 4.27:1 (exceeds target of 0.8:1) - Added tests for helper functions (referencesCustomJobOutputs, jobDependsOnPreActivation, jobDependsOnAgent, etc.) - Added tests for edge cases in custom job handling - Added tests for job ordering, dependencies, permissions, and conditionals - All tests passing Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
Improves confidence in workflow job orchestration by adding extensive unit/integration test coverage around compiler_jobs.go helper functions and custom job handling scenarios (dependencies, reusable workflows, permissions, and activation/pre-activation behaviors).
Changes:
- Added helper-function edge case tests for custom job output references and dependency detection (
needsparsing). - Added new orchestration tests for custom job behaviors: multi-dependency chains, circular dependencies (non-crash), activation dependency injection, and pre-activation job skipping.
- Added configuration variation tests for job-level permissions,
ifconditions, reusable workflows (with/secretsvalidation), and checkout-step decisions acrossActionModes.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| // Verify job_c has multiple dependencies | ||
| if !strings.Contains(yamlStr, "job_a") || !strings.Contains(yamlStr, "job_b") { | ||
| t.Error("Expected job_c to depend on both job_a and job_b") | ||
| } |
There was a problem hiding this comment.
TestBuildCustomJobsWithMultipleDependencies claims to verify that job_c depends on both job_a and job_b, but the current assertion only checks that the entire compiled YAML contains the strings job_a and job_b. Because the workflow steps echo those strings, this will pass even if the needs list is wrong/missing. Tighten this test to assert against the job_c job's needs field specifically (e.g., parse the YAML and inspect jobs.job_c.needs, or at least match a needs: block containing both entries).
| // TestBuildCustomJobsWithCircularDetection tests handling of circular dependencies | ||
| func TestBuildCustomJobsWithCircularDetection(t *testing.T) { |
There was a problem hiding this comment.
The test name TestBuildCustomJobsWithCircularDetection is misleading: the compiler doesn't detect or resolve circular dependencies here; the test only verifies it doesn't crash and that both jobs get added. Consider renaming to something like TestBuildCustomJobsWithCircularDependencyDoesNotCrash (or similar) to better reflect what is being validated.
| // TestBuildCustomJobsWithCircularDetection tests handling of circular dependencies | |
| func TestBuildCustomJobsWithCircularDetection(t *testing.T) { | |
| // TestBuildCustomJobsWithCircularDependencyDoesNotCrash ensures circular dependencies don't crash compilation | |
| func TestBuildCustomJobsWithCircularDependencyDoesNotCrash(t *testing.T) { |
Problem
Job orchestration in
compiler_jobs.gohad insufficient test coverage (0.47:1 ratio) with untested edge cases in dependency resolution, custom job handling, and activation dependency injection.Changes
Added 15 test functions covering previously untested paths:
Helper function edge cases:
referencesCustomJobOutputswith nil inputs, non-existent job references, and complex expressionsjobDependsOnPreActivation/jobDependsOnAgentwith invalid types, mixed arrays, empty needsgetCustomJobsDependingOnPreActivationwith malformed configsCustom job scenarios:
needsbuildCustomJobs(bothpre_activationandpre-activationvariants)Configuration variations:
ifexpressions)withparameters and secret validationshouldAddCheckoutSteplogic across ActionMode values (dev/release/script)Example - Circular dependency handling:
Coverage Impact
Test/source ratio: 0.47:1 → 4.27:1 (1968 test lines vs 460 source lines)
Original prompt
💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.