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

Coverage is not being applied #23

Closed
reesmanp opened this issue Dec 29, 2021 · 6 comments · Fixed by #24
Closed

Coverage is not being applied #23

reesmanp opened this issue Dec 29, 2021 · 6 comments · Fixed by #24
Labels
bug Something isn't working

Comments

@reesmanp
Copy link

Using the Github package.gotpl file, and running tests via go test -cover -json -v ./... 2&>1 | gotestfmt -hide empty-packages, coverage is not output. If I change the .gotpl file to this for debugging:

{{- /*gotype: github.com/haveyoudebuggedit/gotestfmt/v2/renderer.Package*/ -}}
{{- /*
This template contains the format for an individual package.
*/ -}}
{{- $settings := .Settings -}}
{{- if and (or (not $settings.HideSuccessfulPackages) (ne .Result "PASS")) (or (not $settings.HideEmptyPackages) (ne .Result "SKIP") (ne (len .TestCases) 0)) -}}
    {{- if eq .Result "PASS" -}}
        {{ "\033" }}[0;32m
    {{- else if eq .Result "SKIP" -}}
        {{ "\033" }}[0;33m
    {{- else -}}
        {{ "\033" }}[0;31m
    {{- end -}}
    📦 {{ .Name }}{{ "\033" }}[0m{{- "\n" -}}
    {{- with .Reason -}}
        {{- "  " -}}🛑 {{ . -}}{{- "\n" -}}
    {{- end -}}
    {{- with .Output -}}
        {{- . -}}{{- "\n" -}}
    {{- end -}}
    {{- with .TestCases -}}
        {{- range . -}}
            {{- if or (not $settings.HideSuccessfulTests) (ne .Result "PASS") -}}
                {{- if eq .Result "PASS" -}}
                    {{ "  \033" }}[0;32m✅
                {{- else if eq .Result "SKIP" -}}
                    {{ "  \033" }}[0;33m🚧
                {{- else -}}
                    {{ "  \033" }}[0;31m❌
                {{- end -}}
                {{ " " }}{{- .Name -}}
                {{- "\033" -}}[0;37m ({{ .Duration -}}
                , coverage: {{ . }}%
                {{- "\033" -}}[0m
                {{- "\n" -}}

                {{- with .Output -}}
                    {{- . -}}
                    {{- "\n" -}}
                {{- end -}}
            {{- end -}}
        {{- end -}}
    {{- end -}}
    {{- "\n" -}}
{{- end -}}

then I see<nil> for the value of coverage. It looks like coverage is not being parsed correctly. I am seeing the event for the coverage as {"Time":"2021-12-29T12:10:04.616381-08:00","Action":"output","Package":"mypackage","Output":"coverage: 40.7% of statements\n"}

@ghost
Copy link

ghost commented Dec 30, 2021

Hey @reesmanp thank you very much. Are you able to provide a full test output? We could integrate it as a full test case.

@ghost
Copy link

ghost commented Dec 30, 2021

Hey @reesmanp I managed to find the issue, it's in the default template. Could you try the templates in #24 if those work for you? Thanks!

@ghost ghost added the bug Something isn't working label Dec 30, 2021
@reesmanp
Copy link
Author

@janosdebugs thanks for finding it and making a fix. Seems to be working at the module level now.

@reesmanp
Copy link
Author

I'd recommend removing the package level config outputs since those still don't show.

@ghost
Copy link

ghost commented Dec 30, 2021

Go doesn't report coverage for individual tests, those will be removed. I'll merge the patch and make a new release.

ghost pushed a commit that referenced this issue Dec 31, 2021
@ghost ghost closed this as completed in #24 Dec 31, 2021
@ghost
Copy link

ghost commented Dec 31, 2021

The fix has now been merged and will be in the next release.

This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Development

Successfully merging a pull request may close this issue.

1 participant