From eb8aa805bce14c1bf6379afaa1e95a4fe61e0b6e Mon Sep 17 00:00:00 2001 From: Tim Holy Date: Mon, 18 Mar 2019 14:53:04 -0500 Subject: [PATCH 1/2] Use abspath on filenames (fixes #23) --- src/CodeTracking.jl | 1 + test/runtests.jl | 5 ++++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/CodeTracking.jl b/src/CodeTracking.jl index 9e8e5f5..50f5703 100644 --- a/src/CodeTracking.jl +++ b/src/CodeTracking.jl @@ -114,6 +114,7 @@ Return the signatures of all methods whose definition spans the specified locati Returns `nothing` if there are no methods at that location. """ function signatures_at(filename::AbstractString, line::Integer) + filename = abspath(filename) if occursin(juliabase, filename) rpath = postpath(filename, juliabase) id = PkgId(Base) diff --git a/test/runtests.jl b/test/runtests.jl index 84eea2d..db725ac 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -4,7 +4,7 @@ using CodeTracking using Test, InteractiveUtils # Note: ColorTypes needs to be installed, but note the intentional absence of `using ColorTypes` -include("script.jl") +isdefined(Main, :Revise) ? includet("script.jl") : include("script.jl") @testset "CodeTracking.jl" begin m = first(methods(f1)) @@ -87,5 +87,8 @@ end @test !isempty(sigs) sigs = signatures_at(Base.find_source_file(String(m.file)), m.line) @test !isempty(sigs) + + # issue #23 + @test !isempty(signatures_at("script.jl", 9)) end end From c8e0e5944db62034a486f6498eb93691608070f1 Mon Sep 17 00:00:00 2001 From: Tim Holy Date: Mon, 18 Mar 2019 14:53:16 -0500 Subject: [PATCH 2/2] Clarify an error message --- src/CodeTracking.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/CodeTracking.jl b/src/CodeTracking.jl index 50f5703..7355da5 100644 --- a/src/CodeTracking.jl +++ b/src/CodeTracking.jl @@ -140,7 +140,7 @@ function signatures_at(filename::AbstractString, line::Integer) end end end - error("$filename not found, perhaps the package is not loaded") + error("$filename not found in internal data, perhaps the package is not loaded (or not loaded with `includet`)") end """