Skip to content

Improve coverage of exec() package-loading error paths #31

@mcriley821

Description

@mcriley821

Summary

exec() (simplemock.go:160-341) contains several error branches that are only reachable by running the full binary and are not covered by any focused test. The package-loading section is the hardest to reach via E2E because it requires simulating failures in the Go toolchain or type-checker.

Uncovered error paths

Line Condition
203–206 packages.Load() returns a non-nil error
207–210 packages.Load() returns an empty package list
212–219 Loaded package has parse errors or type errors (pkg.Errors)
221–224 filepath.Abs() fails and the fallback path is used
258–261 Type-checker lookup succeeds but the object is not a *types.TypeName

Proposed approach

Refactor exec() to accept a loadFunc parameter (or similar interface) so that packages.Load can be swapped for a stub in tests. This would allow each error branch to be triggered without needing a full Go toolchain or real source files.

Alternatively, add integration-style tests that set up minimal on-disk Go packages in t.TempDir() and invoke exec() directly.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions