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

fix: handle empty/windows paths correctly in base-path-aware path fixer #984

Merged
merged 1 commit into from
Dec 30, 2024

Conversation

matt-codecov
Copy link
Contributor

@matt-codecov matt-codecov commented Dec 30, 2024

there are a couple issues in the base-path-aware path fixer:

empty paths are not skipped

  • the regular path fixer early-exits if the passed-in path is ""
  • if the regular path fixer doesn't succeed, the base-aware path fixer retries with some prefixes (one of them being ./ for windows paths due to the other bug fixed in this PR)
  • the regular path fixer is retried with the passed-in path of "", so it does not early-exit
  • however, the next line strips ./ so the path is turned into ""
  • os.path.relpath() gets mad

incorrect usage of PurePath

the base-path-aware path fixer uses the parent directory of the coverage file as its base. we use PurePath to figure out that parent directory, as it does not perform any actual disk operations, it's just path manipulations.

the issue is, PurePath on our Linux prod servers will instantiate a PurePosixPath, even if the path we are using is clearly a windows path like C:\Users\matt. this is wrong:

>>> pure_path = PurePosixPath("C:\\Users\\matt")
>>> pure_path
PurePosixPath("C:\\Users\\matt")

>>> # parent should be C:\Users
>>> pure_path.parent
PurePosixPath(".")

the fix is to use PureWindowsPath for windows paths and PurePosixPath otherwise

Legal Boilerplate

Look, I get it. The entity doing business as "Sentry" was incorporated in the State of Delaware in 2015 as Functional Software, Inc. In 2022 this entity acquired Codecov and as result Sentry is going to need some rights from me in order to utilize my contributions in this PR. So here's the deal: I retain all rights, title and interest in and to my contributions, and by keeping this boilerplate intact I confirm that Sentry can use, modify, copy, and redistribute my contributions, under Sentry's choice of terms.

@matt-codecov matt-codecov requested a review from a team December 30, 2024 18:42
@codecov-notifications
Copy link

codecov-notifications bot commented Dec 30, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

✅ All tests successful. No failed tests found.

📢 Thoughts on this report? Let us know!

Copy link

codecov bot commented Dec 30, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 97.97%. Comparing base (0026a62) to head (038ae62).
Report is 1 commits behind head on main.

✅ All tests successful. No failed tests found.

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #984   +/-   ##
=======================================
  Coverage   97.97%   97.97%           
=======================================
  Files         444      444           
  Lines       35850    35873   +23     
=======================================
+ Hits        35124    35147   +23     
  Misses        726      726           
Flag Coverage Δ
integration 42.16% <44.00%> (-0.01%) ⬇️
unit 90.61% <100.00%> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

⚠️ Impact Analysis from Codecov is deprecated and will be sunset on Jan 31 2025. See more

Copy link

✅ All tests successful. No failed tests were found.

📣 Thoughts on this report? Let Codecov know! | Powered by Codecov

- the regular path fixer early-exits if the passed-in path is `""`
- if the regular path fixer doesn't succeed, the base-aware path fixer retries with some prefixes (one of them being `./`)
- the regular path fixer is retried with the passed-in path of `""`, so it does not early-exit
- however, the next line strips `./` so the path is _turned into_ `""`
- `os.path.relpath()` gets mad
@matt-codecov matt-codecov force-pushed the matt/fix-base-aware-pathfixer branch from 38aeb0c to 038ae62 Compare December 30, 2024 19:26
@matt-codecov matt-codecov changed the title fix: make base-aware path fixer ignore empty paths fix: handle empty/windows paths correctly in base-path-aware path fixer Dec 30, 2024
@matt-codecov matt-codecov added this pull request to the merge queue Dec 30, 2024
Merged via the queue into main with commit 82c4f5c Dec 30, 2024
26 of 27 checks passed
@matt-codecov matt-codecov deleted the matt/fix-base-aware-pathfixer branch December 30, 2024 19:46
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.

2 participants