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

gotestcover is deprecated #45

Open
pierrre opened this issue May 17, 2016 · 14 comments
Open

gotestcover is deprecated #45

pierrre opened this issue May 17, 2016 · 14 comments

Comments

@pierrre
Copy link

pierrre commented May 17, 2016

Please read https://github.com/pierrre/gotestcover#deprecated

@ruflin
Copy link

ruflin commented May 17, 2016

@pierrre Thanks for the heads up. I have to apply this to https://github.com/elastic/beats

@pierrre
Copy link
Author

pierrre commented May 17, 2016

@ruflin Are you OK with my new script? It does exactly the same thing.

@ruflin
Copy link

ruflin commented May 17, 2016

@pierrre Will test it in the next hours / days as soon as I get the time for it.

@ruflin
Copy link

ruflin commented May 17, 2016

@pierrre Only did a very brief test and got the error: `cannot use test profile flag with multiple packages``

Our code looks as following:

$(GOPATH)/bin/gotestcover $(RACE) -coverprofile=${COVERAGE_DIR}/unit.cov  ${GOPACKAGES}

I assume the package list is the problem. No sure if I should put this in case of go list?

@pierrre
Copy link
Author

pierrre commented May 17, 2016

@ruflin have you read the new script that replaces gotestcover? https://github.com/pierrre/gotestcover#deprecated

echo 'mode: atomic' > coverage.txt && go list ./... | xargs -n1 -I{} sh -c 'go test -covermode=atomic -coverprofile=coverage.tmp {} && tail -n +2 coverage.tmp >> coverage.txt' && rm coverage.tmp

@ruflin
Copy link

ruflin commented May 17, 2016

I wanted to paste the modified line of course that I tried out...

echo 'mode: atomic' > coverage.txt && go list ./... | xargs -n1 -I{} sh -c 'go test $(RACE) -coverprofile=${COVERAGE_DIR}/unit.cov  ${GOPACKAGES} && tail -n +2 coverage.tmp >> coverage.txt' && rm coverage.tmp

@pierrre
Copy link
Author

pierrre commented May 17, 2016

@pierrre
Copy link
Author

pierrre commented May 17, 2016

OK I understand.
What is ${GOPACKAGES} in your script?

No sure if I should put this in case of go list?

Yes, try that

@pierrre
Copy link
Author

pierrre commented May 17, 2016

Please try

echo 'mode: atomic' > ${COVERAGE_DIR}/unit.cov && go list ${GOPACKAGES} | xargs -n1 -I{} sh -c 'go test $(RACE) -covermode=atomic -coverprofile=coverage.tmp {} && tail -n +2 coverage.tmp >> ${COVERAGE_DIR}/unit.cov' && rm coverage.tmp

@ruflin
Copy link

ruflin commented May 17, 2016

Looks like this gets the job done. Thanks.

Now I need to find a way how to make this line shorter / less complex again as we have it multiple times: https://github.com/elastic/beats/blob/master/libbeat/scripts/Makefile#L124

@pierrre
Copy link
Author

pierrre commented May 17, 2016

You could paste this script in a bash file and run it each time you need it.
But it does not allow you to customize arguments for each call.

In my projects, I've copied/pasted this small script :)

@pierrre
Copy link
Author

pierrre commented May 17, 2016

I'm sorry if this deprecation notice is too abrupt for you.
But I find this new solution easier to maintain and more customizable.

(FYI I love Go and I hate bash scripts)

@ruflin
Copy link

ruflin commented May 17, 2016

@pierrre No worries, I really appreciate that you actively inform that the project will not be maintained anymore in the future and even provide a replacement script. The script will work quite well in our Makefiles, no worries.

I don't have it on top of my priority list as gotestcover works and I assume the repo will stay around a little bit.

@pierrre
Copy link
Author

pierrre commented May 17, 2016

Don't be afraid, I will not remove the repository :)

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

No branches or pull requests

2 participants