Skip to content

Fix os.Exit in goroutines, Makefile macOS compat, and JSON round-trip tests#107

Open
briansumma wants to merge 2 commits into
gildas:masterfrom
briansumma:develop-pr
Open

Fix os.Exit in goroutines, Makefile macOS compat, and JSON round-trip tests#107
briansumma wants to merge 2 commits into
gildas:masterfrom
briansumma:develop-pr

Conversation

@briansumma
Copy link
Copy Markdown

Summary

  • Fix os.Exit calls in goroutines and error pathscmd/profile/authorize.go called os.Exit(1) inside a goroutine, preventing cleanup; cmd/pullrequest/create.go used os.Exit(1) instead of returning errors through Cobra. Both now propagate errors properly.

  • Fix Makefile test target for macOS compatibility — The test target used $(COVERAGE_OUT) as a prerequisite, which relied on GNU Make 4 features unavailable in macOS default make. Inlined the test recipe so make test works out of the box. Also migrated tool installation from deprecated go get to go install with @latest.

  • Fix JSON round-trip test failuresMarshalJSON on Commit and User structs emitted zero-value fields (author: {}, date: "0001-01-01...") that were absent in the original API fixtures, causing TestCanUnmarshal assertions to fail. Added omitempty-style nil guards so marshal output matches unmarshal input.

Test plan

  • go build ./... passes
  • go vet ./... passes
  • TestPullRequestSuite/TestCanUnmarshal passes
  • TestPullRequestSuite/TestCanUnmarshalWithNilDestinationRepository passes
  • Full test suite (make test on GNU Make 4+)
  • Verify make coverage-report produces XML output

briansumma and others added 2 commits June 1, 2026 17:14
- cmd/profile/authorize.go: Replace os.Exit(1) in goroutine with
  sending error to result channel, allowing proper cleanup
- cmd/pullrequest/create.go: Replace fmt.Fprintf+os.Exit(1) with
  return err for proper error propagation through Cobra
- main.go: Add comment clarifying .env load error is expected

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Makefile:
- Inline test recipe to avoid $(COVERAGE_OUT) prerequisite requiring
  GNU Make 4 features unavailable on macOS default make
- Add coverage-report target and restore GOCOV/GOCOVXML variables
- Add coverage-report to .PHONY declaration
- Use go install with @latest instead of deprecated go get for tools

Tests:
- cmd/commit: Fix MarshalJSON to omit zero-value fields, fixing
  round-trip assertion failures in TestCanUnmarshal
- cmd/user: Fix MarshalJSON to use time pointer for omitempty
- testdata/: Update branch, commit, and pullrequest fixtures to
  match actual Bitbucket API response structure

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant