Skip to content

Commit 52ccbf9

Browse files
committed
Adjust for base paths possibly being non-normalized
Fixes test failures with JuliaLang/julia#60251. Also fixes an unrelated test where Revise was using the wrong PkgId for Core.Compiler (failure not seen on CI, because it's explicitly disabled there).
1 parent e4e167f commit 52ccbf9

File tree

3 files changed

+13
-10
lines changed

3 files changed

+13
-10
lines changed

src/pkgs.jl

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -362,7 +362,7 @@ function has_writable_paths(pkgdata::PkgData)
362362
end
363363

364364
function watch_includes(mod::Module, fn::AbstractString)
365-
@lock included_files_lock push!(included_files, (mod, normpath(abspath(fn))))
365+
@lock included_files_lock push!(included_files, (mod, realpath(fn)))
366366
end
367367

368368
## Working with Pkg and code-loading
@@ -390,6 +390,7 @@ function manifest_paths!(pkgpaths::Dict, manifest_file::String)
390390
for entry in entries
391391
id = PkgId(UUID(entry["uuid"]::String), name)
392392
path = Base.explicit_manifest_entry_path(manifest_file, id, entry)
393+
ispath(path) && (path = realpath(path))
393394
if path isa String
394395
if isfile(path)
395396
# Workaround for #802
@@ -423,7 +424,7 @@ function watch_manifest(mfile::String)
423424
for (id, pkgdir) in pkgdirs
424425
if haskey(pkgdatas, id)
425426
pkgdata = pkgdatas[id]
426-
if pkgdir != basedir(pkgdata)
427+
if !samefile(pkgdir, basedir(pkgdata))
427428
## The package directory has changed
428429
@debug "Pkg" _group="pathswitch" oldpath=basedir(pkgdata) newpath=pkgdir
429430
push!(pathreplacements, basedir(pkgdata)=>pkgdir)
@@ -434,7 +435,7 @@ function watch_manifest(mfile::String)
434435
# Update the paths in the watchlist
435436
for (oldpath, newpath) in pathreplacements
436437
for (_, pkgdata) in pkgdatas
437-
if basedir(pkgdata) == oldpath
438+
if samefile(basedir(pkgdata), oldpath)
438439
switch_basepath(pkgdata, newpath)
439440
end
440441
end

src/recipes.jl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,15 @@ detected during tracking are applied immediately. Optionally, if `revise_throw`
99
`true`, `revise()` will throw if any exceptions are encountered while revising.
1010
"""
1111
function track(mod::Module; modified_files=revision_queue, revise_throw::Bool=!isinteractive())
12-
id = Base.moduleroot(mod) == Core.Compiler ?
13-
PkgId(mod, "Core.Compiler") :
14-
PkgId(mod)
12+
id = pkgidid_for_mod(mod)
1513
modname = nameof(mod)
1614
ret = _track(id, modname; modified_files=modified_files)
1715
revise(; throw=revise_throw) # force revision so following calls in the same block work
1816
return ret
1917
end
2018

19+
pkgidid_for_mod(mod) = id = Base.moduleroot(mod) == Core.Compiler ? PkgId(mod, "Core.Compiler") : PkgId(mod)
20+
2121
const vstring = "v$(VERSION.major).$(VERSION.minor)"
2222

2323
function inpath(path::AbstractString, dirs::Vector{String})
@@ -140,7 +140,7 @@ function track_subdir_from_git!(pkgdata::PkgData, subdir::AbstractString; commit
140140
if repo == nothing
141141
throw(GitRepoException(subdir))
142142
end
143-
prefix = string(relpath(subdir, repo_path), "/") # git-relative path of this subdir
143+
prefix = string(relpath(realpath(subdir), realpath(repo_path)), "/") # git-relative path of this subdir
144144
tree = git_tree(repo, commit)
145145
files = Iterators.filter(file->startswith(file, prefix) && endswith(file, ".jl"), keys(tree))
146146
ccall((:giterr_clear, :libgit2), Cvoid, ()) # necessary to avoid errors like "the global/xdg file 'attributes' doesn't exist: No such file or directory"

test/runtests.jl

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -499,8 +499,10 @@ const issue639report = []
499499
@test Revise.RelocatableExpr(definition(m)) != rex
500500
# CodeTracking methods
501501
m3 = first(methods(eval(fn3)))
502-
m3file = joinpath(dn, "subdir", "file3.jl")
503-
@test whereis(m3) == (m3file, 1)
502+
m3file = realpath(joinpath(dn, "subdir", "file3.jl"))
503+
w = whereis(m3)
504+
@test samefile(w[1], m3file)
505+
@test w[2] == 1
504506
@test signatures_at(m3file, 1) == [Revise.SigInfo(nothing, m3.sig)]
505507
@test signatures_at(eval(Symbol(modname)), joinpath("src", "subdir", "file3.jl"), 1) == [Revise.SigInfo(nothing, m3.sig)]
506508

@@ -2990,7 +2992,7 @@ const issue639report = []
29902992
if repo != nothing && isfile(joinpath(path, "VERSION")) && isdir(joinpath(path, "base"))
29912993
# Tracking Core.Compiler
29922994
Revise.track(Core.Compiler)
2993-
id = Base.PkgId(Core.Compiler)
2995+
id = Revise.pkgidid_for_mod(Core.Compiler)
29942996
pkgdata = Revise.pkgdatas[id]
29952997
@test any(k->endswith(k, "optimize.jl"), Revise.srcfiles(pkgdata))
29962998
m = first(methods(Core.Compiler.typeinf_code))

0 commit comments

Comments
 (0)