I am facing the same issue.
I have go binary running in a docker container (built using -cover 
-covermode=atomic)
I am doing API testing by calling HTTP / grpc endpoints to the service (and 
comparing the response - an independent tool is doing this using curl / 
grpcurl)

I see that covmeta file is created, but when tests are running, covcounter 
are not generated.

Now, for graceful shutdown, I tried docker compose down - but this is not 
working.

Would someone be able to help?

On Wednesday, July 12, 2023 at 5:48:31 PM UTC+5:30 savita juyal wrote:

> Thank you so much Brian for helping me identify the problem. Now I am 
> using kill -2 to pass SIGINT to the process, with this program is exiting 
> politely and we are getting covcounter files. 
>
> Regards
> Savita Juyal
> On Tuesday, July 11, 2023 at 7:18:57 PM UTC+5:30 Brian Candler wrote:
>
>> Why are you using kill -9?  That doesn't allow the process any time to 
>> tidy up whilst exiting.
>>
>> But also see https://go.dev/testing/coverage/#FAQ
>>
>> "If my program panics, will coverage data be written?
>>
>> Programs built with go build -cover will only write out complete profile 
>> data at the end of execution if the program invokes os.Exit() or returns 
>> normally from main.main. If a program terminates in an unrecovered 
>> panic, or if the program hits a fatal exception (such as a segmentation 
>> violation, divide by zero, etc), profile data from statements executed 
>> during the run will be lost."
>>
>> On Tuesday, 11 July 2023 at 14:17:18 UTC+1 savita juyal wrote:
>>
>>> Hello All,
>>>
>>> I am trying to collect integration test coverage but its not generating 
>>> covcounters file. Please looks steps I am following to generate covearge.
>>>
>>> - *Build go binary* : go build -race -*cover* -o 
>>> $(ROOT)/go/bin/appwithrace -ldflags "-X app/handler.proxyVersion=$(VERSION) 
>>> -X app/handler.gitVersion=$(GITVERSION) -X 
>>> app/handler.buildTime=$(BUILDTIME)" cmd/proxy/proxy.go
>>>
>>> - *Run go binary* : ENABLE_TLS=false ENABLE_TLS_TO_DB=false 
>>> LOAD_BALANCED=false *GOCOVERDIR=./coverage/int *./go/bin/appwithrace 
>>> 2>&1 >/dev/null &
>>>
>>> - *Exit go program* : Kill -9 go_process_id
>>>
>>> Now we only covmetadata file generated under the given path. Please me 
>>> know what I am doing wrong or if I am missing something?
>>>
>>> Regards
>>> Savita Juyal
>>>
>>>
>>>
>>>
>>>
>>>

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
To view this discussion visit 
https://groups.google.com/d/msgid/golang-nuts/beacfca3-2013-4fda-973c-eccb66bc3fd8n%40googlegroups.com.

Reply via email to