Add CLI runner goroutine leak test - #7582
Conversation
WalkthroughThe test harness now starts its shared HTTP server only for benchmarks and adds a forked CLI runner test that executes a local template, closes the runner, and verifies that no unexpected goroutines remain. ChangesCLI test reliability
Estimated code review effort: 3 (Moderate) | ~20 minutes Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@cmd/nuclei/main_benchmark_test.go`:
- Line 64: Update the argument check around the benchmark-detection logic to
match only the exact -test.bench flag or arguments beginning with -test.bench=.
Do not treat -test.benchmem or -test.benchtime as benchmark-selection flags, so
they do not start the shared server.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro Plus
Run ID: cafa4fc4-81fb-49f8-9e1f-adf797ade358
⛔ Files ignored due to path filters (1)
cmd/nuclei/testdata/leaktest/basic-http.yamlis excluded by!**/*.yaml
📒 Files selected for processing (2)
cmd/nuclei/main_benchmark_test.gocmd/nuclei/main_leak_test.go
|
|
||
| func isBenchmarkRun() bool { | ||
| for _, arg := range os.Args[1:] { | ||
| if strings.HasPrefix(arg, "-test.bench") { |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
Match only the benchmark-selection flag.
This also matches -test.benchmem and -test.benchtime, so unit runs using either flag still start the shared server. Restrict the match to -test.bench or -test.bench=....
Proposed fix
- if strings.HasPrefix(arg, "-test.bench") {
+ if arg == "-test.bench" || strings.HasPrefix(arg, "-test.bench=") {📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| if strings.HasPrefix(arg, "-test.bench") { | |
| if arg == "-test.bench" || strings.HasPrefix(arg, "-test.bench=") { |
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@cmd/nuclei/main_benchmark_test.go` at line 64, Update the argument check
around the benchmark-detection logic to match only the exact -test.bench flag or
arguments beginning with -test.bench=. Do not treat -test.benchmem or
-test.benchtime as benchmark-selection flags, so they do not start the shared
server.
Summary
ParseOptions→New→RunEnumeration→Close)-test.benchso unit leak checks are not pollutedCloses #5121
Summary by CodeRabbit