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

Coverage isn't generated if tracked path is in a symlink #52458

Open
IanButterworth opened this issue Dec 8, 2023 · 6 comments
Open

Coverage isn't generated if tracked path is in a symlink #52458

IanButterworth opened this issue Dec 8, 2023 · 6 comments
Labels
code coverage regression Regression in behavior compared to a previous version

Comments

@IanButterworth
Copy link
Sponsor Member

IanButterworth commented Dec 8, 2023

testing: Test Failed at /Users/runner/work/Pkg.jl/Pkg.jl/test/pkg.jl:244
  Expression: any(endswith(".cov"), readdir(pkgdir))

https://github.com/JuliaLang/Pkg.jl/actions/runs/7071386764/job/19249051912

Probably related to #52123

@IanButterworth IanButterworth added the regression Regression in behavior compared to a previous version label Dec 8, 2023
@IanButterworth IanButterworth added this to the 1.11 milestone Dec 8, 2023
@IanButterworth
Copy link
Sponsor Member Author

This was introduced by #52140

It seems to be that on macos calling our c function abspath on /var/folders paths converts them to /private/var/folders
So the tracking path gets mutated, but the function location doesn't seem to go through abspath.

% ./julia --code-coverage=@/var/folders
               _
   _       _ _(_)_     |  Documentation: https://docs.julialang.org
  (_)     | (_) (_)    |
   _ _   _| |_  __ _   |  Type "?" for help, "]?" for Pkg help.
  | | | | | | |/ _` |  |
  | | |_| | | | (_| |  |  Version 1.11.0-DEV.1104 (2023-12-15)
 _/ |\__'_|_|_|\__'_|  |  Commit d0efc5cd29 (3 days old master)
|__/                   |

julia> unsafe_string(Base.JLOptions().tracked_path)
"/private/var/folders"

julia> include("/var/folders/test/test.jl")
foo (generic function with 1 method)

julia> @functionloc foo()
("/var/folders/test/test.jl", 1)
julia> include("/private/var/folders/test/test.jl")
foo (generic function with 1 method)

julia> @functionloc foo()
("/private/var/folders/test/test.jl", 1)

@IanButterworth
Copy link
Sponsor Member Author

It's not clear to me why Pkg CI isn't failing in the same way on macos on buildkite here.

@IanButterworth
Copy link
Sponsor Member Author

IanButterworth commented Dec 18, 2023

The julia function abspath doesn't add /private

julia> abspath(mktempdir())
"/var/folders/1z/jf841bdj73bdj3vk7kc7f_3w0000gn/T/jl_bFNXp8"

Perhaps the fix is to stop the c function abspath calling realpath?

char *out = realpath(in + nprefix, NULL);


It also affects the way to specify the current dir with a lone @

ian@Ians-MBP test % pwd
/var/folders/test
ian@Ians-MBP test % /Users/ian/Documents/GitHub/julia/julia --code-coverage=@ -E "unsafe_string((Base.JLOptions()).tracked_path)"
"/private/var/folders/test/"

@IanButterworth IanButterworth changed the title Coverage failure in Pkg tests on MacOS Coverage isn't generated if tracked path is in a symlink Dec 19, 2023
@IanButterworth
Copy link
Sponsor Member Author

The fix for this seems to be

  • rename the init.c func abspath -> absrealpath
  • make a new abspath that doesn't call realpath and use that for tracked_path

In the meantime we can work around it in Pkg by using realpath for tempdirs in the test harnesses JuliaLang/Pkg.jl#3734

vtjnash pushed a commit that referenced this issue Feb 6, 2024
For clarification given its behavior is not the same as julia's
`abspath`

Related #52458
@KristofferC
Copy link
Sponsor Member

@IanButterworth, #52574 is now merged, are we ready for "step 2" in the previous comment?

@IanButterworth
Copy link
Sponsor Member Author

I think it can be dropped off the 1.11 milestone. It's worked around in Pkg and otherwise a bit of an edge case as I can't imagine many people store their packages in symlinked dirs and run code coverage locally

@IanButterworth IanButterworth removed this from the 1.11 milestone May 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
code coverage regression Regression in behavior compared to a previous version
Projects
None yet
Development

No branches or pull requests

3 participants