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

Bug: full file paths in coverage output (windows) #24

Closed
phanirithvij opened this issue Feb 27, 2022 · 4 comments · Fixed by #25
Closed

Bug: full file paths in coverage output (windows) #24

phanirithvij opened this issue Feb 27, 2022 · 4 comments · Fixed by #25

Comments

@phanirithvij
Copy link
Contributor

Describe the bug
It doesn't work on windows

To Reproduce
Steps to reproduce the behavior:

  1. go install github.com/orlangure/gocovsh@latest
  2. cd Some/Directory
  3. git clone https://github.com/tsoding/snitch
  4. cd snitch
  5. go test -v -cover -coverprofile coverage.out
  6. gocovsh --profile coverage.out
  7. Enter on a selected file.

Expected behavior
File paths are relative in the cover.out file eg. github.com/tsoding/snitch/logcmd.go:26.33,28.4 1 0.
I don't think this issue is package-specific (snitch).

Screenshots
Files
After Opening a file

Desktop (please complete the following information):

  • OS: Windows 10
  • Info:
      Edition	Windows 10 Home Single Language
      Version	21H1
      Installed on8/7/2020
      OS build	19043.1566
      Experience	Windows Feature Experience Pack 120.2212.4170.0
  • Terminal emulator: cmd.exe, clink, alacritty

Additional context
Not sure if this is windows specific but I'm on windows.

@orlangure
Copy link
Owner

Hi @phanirithvij and thanks for the report.

It appears that the issue is indeed exists on Windows (which I honestly never tested, so thanks for that), because on my mac everything works as expected:
image

I'll look into it when I have access to a Windows instance, or if you'd like to help you could try figuring out the reason, and maybe even submitting a fix😼

@orlangure
Copy link
Owner

@phanirithvij, hi again!

I just tried running gocovsh on a windows instance on ec2 (AWS cloud), and it worked for both powershell and cmd.exe terminal:
image

File names in the list are relative to the current folder (the same folder that contains the go.mod file and the coverage.out report). Opening the file also works as expected:
image

For some reason, this piece of code doesn't remove package name prefix from the coverage reports on your system:

for i, p := range profiles {
p.FileName = strings.TrimPrefix(p.FileName, pkg+"/")
profiles[i] = p
}

I need your help in figuring out the root cause, because I can't reproduce the issue.

@phanirithvij
Copy link
Contributor Author

I was a bit busy so I didn't respond I apologise.
I'll spend some time on debugging this on my system today.
Maybe you can add windows-latest and macos too to the test workflow in the meantime?

@phanirithvij
Copy link
Contributor Author

Enabled them on my fork, windows fails with the same errors.
workflow run

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 a pull request may close this issue.

2 participants