fix: wire --judge flag through and stop Action from hanging#2
Merged
Conversation
The --judge flag was parsed but ignored: Action always checked through a hardcoded AZEnvPhpJudge, so the proxyjudge.us default never took effect and --judge azenv.php / --judge proxyjudge.us behaved identically. Add ResolveJudge, which looks the name up in the Judges registry and errors on an unknown name (listing the valid ones). Action now resolves the judge from --judge before starting the worker pool, aborts on an unknown name (checking nothing), and passes the resolved judge to every worker. While adding a regression test, Action was found to hang forever: it never closed the proxyAddrs channel, so the workers' range loops never ended and wg.Wait blocked after the feed was exhausted. Close the channel after the feed loop so the program exits as specified. Extract NewApp so the cmd binary and tests share the same flag wiring, and cover both fixes with tests (TestResolveJudge, TestApp_UnknownJudge). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Welcome to Codecov 🎉Once you merge this PR into your default branch, you're all set! Codecov will compare coverage reports and display results in all future pull requests. Thanks for integrating Codecov - We've got you covered ☂️ |
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.
What & why
The
--judgeflag was parsed but ignored —Actionalways checked through ahardcoded
AZEnvPhpJudge, so the documentedproxyjudge.usdefault never tookeffect and
--judge azenv.php/--judge proxyjudge.usbehaved identically.Changes
ResolveJudge(name) (Judge, error)+judgeNames()injudges.go:resolve the flag against the
Judgesregistry; an unknown name errors andlists the valid names.
Actionresolves the judge from--judgebefore the worker pool, abortson an unknown name (nothing is probed), and passes the resolved judge to every
worker. The
proxyjudge.usdefault now actually applies.Actionnever closedproxyAddrs, sothe workers'
rangeloops never ended andwg.Wait()blocked forever — theCLI hung after processing all proxies. Added
close(proxyAddrs)after the feedloop. It had gone unnoticed because
Actionhad no test.NewApp()so the binary and tests share the same flag wiring.Tests (TDD)
TestApp_UnknownJudge—--judge foomust error; was RED on the old code(ignored the flag, then hung 60s), now green.
TestResolveJudge— valid names resolve, unknown errors with the list.go test ./... -race,go vet,gofmt -l,golangci-lint runallclean.
🤖 Generated with Claude Code