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

Tests when ran outside of repo #15

Open
ThinkChaos opened this issue Jul 11, 2023 · 1 comment
Open

Tests when ran outside of repo #15

ThinkChaos opened this issue Jul 11, 2023 · 1 comment

Comments

@ThinkChaos
Copy link

Hi,

Thanks for the tool, I'm trying to use it to get coverage reports in my GH Actions.
I'm building the binary myself using Nix which builds it fine, and then runs the tests. The way it fetches the sources is not a full clone, but just a "download as zip".
This causes the tests to fail since getCoverallsSourceFileName ends up returning an absolute path:

--- FAIL: TestParseCoverage (0.01s)
    main_test.go:66:
                Error Trace:    main_test.go:66
                Error:          Not equal:
                                expected: "main.go"
                                actual  : "/build/source/main.go"

                                Diff:
                                --- Expected
                                +++ Actual
                                @@ -1 +1 @@
                                -main.go
                                +/build/source/main.go
                Test:           TestParseCoverage
--- FAIL: TestConvertCoverage (0.00s)
    main_test.go:102:
                Error Trace:    main_test.go:102
                Error:          Not equal:
                                expected: "TN:\nSF:main.go\nDA:6,1\nDA:7,1\nDA:8,1\nDA:9,0\nDA:10,2\nDA:11,2\nLF:6\nLH:5\nend_of_record\n"
                                actual  : "TN:\nSF:/build/source/main.go\nDA:6,1\nDA:7,1\nDA:8,1\nDA:9,0\nDA:10,2\nDA:11,2\nLF:6\nLH:5\nend_of_record\n"

                                Diff:
                                --- Expected
                                +++ Actual
                                @@ -1,3 +1,3 @@
                                 TN:
                                -SF:main.go
                                +SF:/build/source/main.go
                                 DA:6,1
                Test:           TestConvertCoverage
--- FAIL: TestPathResolverFunc (0.00s)
    main_test.go:110:
                Error Trace:    main_test.go:110
                Error:          Not equal:
                                expected: "main.go"
                                actual  : "/build/source/main.go"

                                Diff:
                                --- Expected
                                +++ Actual
                                @@ -1 +1 @@
                                -main.go
                                +/build/source/main.go
                Test:           TestPathResolverFunc
FAIL
FAIL    github.com/jandelgado/gcov2lcov 0.018s
FAIL

I can workaround this by skipping the tests run, but thought I'd report it here :)

@jandelgado
Copy link
Owner

jandelgado commented Jul 30, 2023

For now, the easiest way to run the test would be to create an empty directory .git in the projects root dir, before the tests are run (i.e. mkdir .git). I'll check if we can get rid off the code checking for a vcs root dir....

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