Skip to content

Fix destination package directory lookup - #249

Open
jihtsan wants to merge 1 commit into
matryer:mainfrom
jihtsan:codex/241-package-directory-lookup
Open

jihtsan wants to merge 1 commit into
matryer:mainfrom
jihtsan:codex/241-package-directory-lookup

Conversation

@jihtsan

@jihtsan jihtsan commented Oct 16, 2026

Copy link
Copy Markdown

Explicit destination-package lookup passes pkgInDir arguments in reverse order. It also uses the source import path as a filesystem directory. As a result, -pkg source or a matching child package cannot be recognized, and generated mocks can import their own package and fail to compile.

Pass the source directory separately, check package name and directory in the right order, and construct returned import paths with slash-based path.Join. An external source_test package must remain distinct from source, so it retains the source import rather than being treated as the same package.

Fixes #241.

Validation on macOS arm64, Go 1.26.6:

  • On unchanged base, two package-lookup cases and two generated-code compilation cases fail; all new cases pass with this change.
  • Actual moq CLI: same-package and child-package outputs fail to compile before the fix and compile after it; external _test output compiles both before and after.
  • GOTOOLCHAIN=go1.26.6 go build -o <bin>/moq ., then PATH=<bin>:$PATH GOTOOLCHAIN=go1.26.6 go test -race ./...: pass. Putting the freshly built binary on PATH is required by the existing vendored go:generate test, matching CI's install step.
  • GOTOOLCHAIN=go1.26.6 go vet ./...: pass.
  • CI's golint command exits successfully. Its eight warnings are all in unchanged fixtures and exactly match the unchanged base. No fixture cleanup is included.

Windows, Linux and the newer Go matrix were not run locally. AI-assisted implementation and review; the generated-code and race checks above were executed locally.

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.

SAST. Possible mismatched call arguments in internal/registry/registry.go

1 participant