Go: Improve two tests#22027
Open
owen-mc wants to merge 2 commits into
Open
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR improves Go library tests by adding a dedicated CFG fixture for epilogue/defer/recover behavior and by restructuring logger-call test code so non-returning logging functions don’t accidentally make later call sites unreachable in the CFG/IR.
Changes:
- Add a new
epilogues.gofixture covering deferred calls (receiver/args evaluation timing), deferred function literals, andrecover()behavior. - Update CFG successor expectations to include the new epilogue-related nodes/edges.
- Refactor the LoggerCall stdlib/logrus fixtures to gate
Fatal*/Panic*calls behind a selector, keeping call sites reachable for analysis.
Show a summary per file
| File | Description |
|---|---|
| go/ql/test/library-tests/semmle/go/controlflow/ControlFlowGraph/NoretFunctions.expected | Regenerated expected results to account for the new CFG fixture’s impact on mayReturnNormally() results. |
| go/ql/test/library-tests/semmle/go/controlflow/ControlFlowGraph/epilogues.go | New CFG test fixture exercising epilogue/defer/recover cases. |
| go/ql/test/library-tests/semmle/go/controlflow/ControlFlowGraph/ControlFlowNode_getASuccessor.expected | Regenerated successor expectations to include CFG behavior for the new epilogue/recover scenarios. |
| go/ql/test/library-tests/semmle/go/concepts/LoggerCall/stdlib.go | Refactors stdlib logger calls into selector-based branches to avoid no-return calls dominating the function. |
| go/ql/test/library-tests/semmle/go/concepts/LoggerCall/main.go | Updates the stdlib test entrypoint to pass a selector value. |
| go/ql/test/library-tests/semmle/go/concepts/LoggerCall/logrus.go | Refactors some logrus no-return calls behind a selector to preserve reachability. |
Copilot's findings
- Files reviewed: 6/6 changed files
- Comments generated: 1
Comment on lines
+115
to
+118
| func epiRecoverUnnamed() { | ||
| defer epiRecover() | ||
| panic("boom") | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Two test improvements. I've pulled these two out of #21614 as they can be reviewed separately.