Skip to content

Conversation

@pballok
Copy link

@pballok pballok commented Nov 16, 2024

What:
Removed Path Normalization from regexp patterns
Fixes #115

Why:

  • Even on Windows, the file paths are reported with the standard / separator by go test, so to match those paths, the path separator in the regexp needs also to be / on all platforms

Tested on:

  • Windows Git-Bash shell
  • Windows standard Command Prompt shell
  • macOS zsh

Note:
As there were no more calls to the Path Normalization, I removed the file entirely, but some of the tests refer to this file being part of the test profiles. I clean up those profiles too, but I see some test logic still depends on path.go being part of the coverage stats. It is a bit difficult to see clearly what tests fail because of these changes, and what test fail for unrelated reasons, because there are many tests failing for me on the main branch as well.

@vladopajic
Copy link
Owner

@pballok awesome, thanks for PR!

i will take a look at those tests related to path.go file.

@vladopajic
Copy link
Owner

@pballok please rebase from main branch. i have just pushed change that has refactored tests not to use path.go file.

@pballok pballok force-pushed the fix-path-normalisation-on-windows branch from 3e3b1c6 to cf68457 Compare November 17, 2024 03:47
@pballok
Copy link
Author

pballok commented Nov 17, 2024

I did the rebase, but the tests still fail on my end. The also fail on the new main, so I'm not sure my changes are the cause. It's possible my local setup is causing it, I need to investigate, but won't have access to my computer for a couple of days. Here is the error log:

$ go test ./... -covermode=atomic -coverpkg=./... -coverprofile=cover.out
        github.com/vladopajic/go-test-coverage/v2               coverage: 0.0% of statements
        github.com/vladopajic/go-test-coverage/v2/pkg/testcoverage/path         coverage: 0.0% of statements
--- FAIL: TestCheck (0.00s)
    --- FAIL: TestCheck/valid_profile_-_pass_after_override (29.93s)
        check_test.go:112:
                Error Trace:    C:/Users/Peti/git/go-test-coverage/pkg/testcoverage/check_test.go:112
                Error:          Should be true
                Test:           TestCheck/valid_profile_-_pass_after_override
        check_test.go:114:
                Error Trace:    C:/Users/Peti/git/go-test-coverage/pkg/testcoverage/helpers_test.go:95
                                                        C:/Users/Peti/git/go-test-coverage/pkg/testcoverage/check_test.go:114
                Error:          Not equal:
                                expected: 1
                                actual  : 0
                Test:           TestCheck/valid_profile_-_pass_after_override
        check_test.go:114:
                Error Trace:    C:/Users/Peti/git/go-test-coverage/pkg/testcoverage/helpers_test.go:96
                                                        C:/Users/Peti/git/go-test-coverage/pkg/testcoverage/check_test.go:114
                Error:          Not equal:
                                expected: 0
                                actual  : 1
                Test:           TestCheck/valid_profile_-_pass_after_override
    --- FAIL: TestCheck/valid_profile_-_fail_after_override (30.06s)
        check_test.go:128:
                Error Trace:    C:/Users/Peti/git/go-test-coverage/pkg/testcoverage/check_test.go:128
                Error:          Should be false
                Test:           TestCheck/valid_profile_-_fail_after_override
        check_test.go:130:
                Error Trace:    C:/Users/Peti/git/go-test-coverage/pkg/testcoverage/helpers_test.go:95
                                                        C:/Users/Peti/git/go-test-coverage/pkg/testcoverage/check_test.go:130
                Error:          Not equal:
                                expected: 0
                                actual  : 1
                Test:           TestCheck/valid_profile_-_fail_after_override
        check_test.go:130:
                Error Trace:    C:/Users/Peti/git/go-test-coverage/pkg/testcoverage/helpers_test.go:96
                                                        C:/Users/Peti/git/go-test-coverage/pkg/testcoverage/check_test.go:130
                Error:          Not equal:
                                expected: 1
                                actual  : 0
                Test:           TestCheck/valid_profile_-_fail_after_override
FAIL
coverage: 72.1% of statements in ./...
FAIL    github.com/vladopajic/go-test-coverage/v2/pkg/testcoverage      62.798s
ok      github.com/vladopajic/go-test-coverage/v2/pkg/testcoverage/badge        0.450s  coverage: 1.7% of statements in ./...
ok      github.com/vladopajic/go-test-coverage/v2/pkg/testcoverage/badgestorer  0.374s  coverage: 6.0% of statements in ./...
--- FAIL: Test_findFile (2.70s)
    cover_test.go:99:
                Error Trace:    C:/Users/Peti/git/go-test-coverage/pkg/testcoverage/coverage/cover_test.go:99
                Error:          Not equal:
                                expected: "pkg/testcoverage/coverage/cover.go"
                                actual  : "C:\\Users\\Peti\\git\\go-test-coverage\\pkg\\testcoverage\\coverage\\cover.go"

                                Diff:
                                --- Expected
                                +++ Actual
                                @@ -1 +1 @@
                                -pkg/testcoverage/coverage/cover.go
                                +C:\Users\Peti\git\go-test-coverage\pkg\testcoverage\coverage\cover.go
                Test:           Test_findFile
    cover_test.go:100:
                Error Trace:    C:/Users/Peti/git/go-test-coverage/pkg/testcoverage/coverage/cover_test.go:100
                Error:          Should be true
                Test:           Test_findFile
    cover_test.go:104:
                Error Trace:    C:/Users/Peti/git/go-test-coverage/pkg/testcoverage/coverage/cover_test.go:104
                Error:          Not equal:
                                expected: "pkg/testcoverage/coverage/cover.go"
                                actual  : "C:\\Users\\Peti\\git\\go-test-coverage\\pkg\\testcoverage\\coverage\\cover.go"

                                Diff:
                                --- Expected
                                +++ Actual
                                @@ -1 +1 @@
                                -pkg/testcoverage/coverage/cover.go
                                +C:\Users\Peti\git\go-test-coverage\pkg\testcoverage\coverage\cover.go
                Test:           Test_findFile
    cover_test.go:105:
                Error Trace:    C:/Users/Peti/git/go-test-coverage/pkg/testcoverage/coverage/cover_test.go:105
                Error:          Should be true
                Test:           Test_findFile
FAIL
coverage: 32.1% of statements in ./...
FAIL    github.com/vladopajic/go-test-coverage/v2/pkg/testcoverage/coverage     64.129s
FAIL

@vladopajic
Copy link
Owner

@pballok thanks for reporting issue and providing solution. i have fixed testes in #121 and merged to main.

new release is coming really soon.

happy coding 🌞

@vladopajic vladopajic closed this Nov 17, 2024
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 this pull request may close these issues.

override regex parsing failure on Windows

2 participants