Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support go modules #94

Merged
merged 32 commits into from
Oct 12, 2018
Merged

Support go modules #94

merged 32 commits into from
Oct 12, 2018

Conversation

joefitzgerald
Copy link
Collaborator

@joefitzgerald joefitzgerald commented Sep 13, 2018

This PR is intended to support go modules and set the stage for future changes (namely, to permit a variety of different fake types to be generated).

In effect, it's a total rewrite.

  • We have switched from go/ast to text/template to generate the output from counterfeiter. This means that in the future, people will be able to write their own templates and supply them to counterfeiter.
  • We have switched from go/parser to go/packages to load types. go/packages is module aware.
    • The go team officially supports N-1 (at the time of this PR, go 1.11 is out, and the go team support go 1.10 and go 1.11. This means that counterfeiter is only tested to work with go 1.10 or go 1.11 at the time of this PR (although we expect to support future versions.
  • counterfeiter is now a go module

We would very much appreciate it if you can try out this branch and validate that your tests continue to function after using it.

Outstanding items:

  • Support "package mode" (generate an interface and fake for an entire package)
  • Ensure Windows CI succeeds
  • Remove unused code
  • Enhance test coverage; we've used an integration / acceptance test approach for the rewrite, and now we need to lock things in so we can refactor
  • Ensure integration tests work in go 1.11 module mode

Fixes #90

@vito
Copy link
Collaborator

vito commented Sep 19, 2018

Looking forward to this! Just tried the branch out on Concourse, and noticed that the templates should be using text/template rather than html/template, otherwise the fakes end up with &lt;-chan foo instead of <-chan foo. 🙂 Aside from that everything worked!

vito added a commit to concourse/concourse that referenced this pull request Sep 19, 2018
fyi: had to locally change it to use text/template rather than
html/template. see
maxbrunsfeld/counterfeiter#94 (comment)
for more info.
@joefitzgerald
Copy link
Collaborator Author

Nice catch on the html/template error @vito, thanks! I think it may have happened as I extracted the templates into their own files.

Have quite a bit more progress to push up tomorrow.

- they are problematic given the future direction of modules
- they are packages that are locally vendored
- we could add this back if we vendored a real package hosted somewhere on the internets, and have associated module definitions
@joefitzgerald joefitzgerald changed the title WIP: Support go modules Support go modules Oct 11, 2018
@joefitzgerald joefitzgerald merged commit d68f4b0 into master Oct 12, 2018
@maxbrunsfeld
Copy link
Owner

Awesome work on this @joefitzgerald and @zmb3!

@joefitzgerald
Copy link
Collaborator Author

golang/go#24661

@joefitzgerald joefitzgerald deleted the support-go-modules branch October 12, 2018 17:40
@glyn
Copy link
Contributor

glyn commented Nov 8, 2018

Thanks so much for this PR. It provided an escape route when moving some code to a go modules repo and found that mockery was broken.

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.

5 participants