gotestsum icon indicating copy to clipboard operation
gotestsum copied to clipboard

Implemented combine coverprofile in the case of rerun failed

Open yihuaf opened this issue 1 year ago • 6 comments

Fix #274

As discussed in #274, when gotestsum rerun failed test cases, the coverprofile gets overridden by the each calls to the underlying go test, causing coverprofile to per in correct.

I tested the code with the repros provided in #274: https://github.com/neiser/gotestsum-rerun-dependent-subtests/tree/master

The code is just a proof of concept. If the general approach is acceptable, then I will go ahead and clean up the PR with necessary unit tests and comments.

The general approach taken in this PR:

  • if coverprofile flag is discovered, we parse the flag to get the file path.
  • in normal case, we pass the coverprofile directly to go test unmodified.
  • in the case that we need to rerun the failed test cases, we modify the coverprofile flag with a new file name.
  • after the run, we combine the new coverprofile output with the original file path passed in.

yihuaf avatar Feb 15 '24 21:02 yihuaf

Looks like test-windows is broken unrelated to my change. I tried tip of the tree and the test still fails.

=== Failed
=== FAIL: cmd TestE2E_RerunFails/first_run_has_errors,_abort_rerun (0.39s)
    main_e2e_test.go:69: assertion failed: 
        --- expected
        +++ actual
        @@ -1,6 +1,11 @@
        +FAIL testjson/internal/broken
        +
        +=== Failed
        +=== FAIL: testjson/internal/broken 
        +FAIL   gotest.tools/gotestsum/testjson/internal/broken [build failed]
         
         === Errors
         ../testjson/internal/broken/broken.go:5:21: undefined: somepackage
         
        -DONE 0 tests, 1 error
        +DONE 0 tests, 1 failure, 1 error

yihuaf avatar Feb 16 '24 00:02 yihuaf

@dnephin I was trying to do a PR to update your dependencies but tests are failing locally with the same error posted by @yihuaf

gaby avatar Mar 10 '24 03:03 gaby

@dnephin Please let me know if there is anything you would like me to follow up :)

yihuaf avatar Mar 19 '24 00:03 yihuaf

@dnephin Let me know if there is anything else you would like me to fix :)

yihuaf avatar Apr 18 '24 06:04 yihuaf