|
1 | 1 | @testset "goto symbols" begin |
2 | | - using Atom: modulegotoitems, realpath′, toplevelgotoitems, SYMBOLSCACHE, |
| 2 | + using Atom: modulegotoitems, toplevelgotoitems, SYMBOLSCACHE, |
3 | 3 | regeneratesymbols, methodgotoitems, globalgotoitems |
4 | 4 | using CSTParser |
5 | 5 |
|
|
51 | 51 |
|
52 | 52 | @testset "module goto" begin |
53 | 53 | let item = modulegotoitems("Atom", Main)[1] |
54 | | - @test item.file == realpath′(joinpath(@__DIR__, "..", "src", "Atom.jl")) |
| 54 | + @test item.file == joinpath′(atomjldir, "Atom.jl") |
55 | 55 | @test item.line == 3 |
56 | 56 | end |
57 | 57 | let item = modulegotoitems("Junk2", Main.Junk)[1] |
58 | | - @test item.file == joinpath(@__DIR__, "fixtures", "Junk.jl") |
| 58 | + @test item.file == joinpath′(junkpath) |
59 | 59 | @test item.line == 14 |
60 | 60 | end |
61 | 61 | end |
62 | 62 |
|
63 | 63 | @testset "goto toplevel symbols" begin |
64 | 64 | ## where Revise approach works, i.e.: precompiled modules |
65 | | - let dir = realpath′(joinpath(@__DIR__, "..", "src")) |
66 | | - path = joinpath(dir, "comm.jl") |
| 65 | + let path = joinpath′(atomjldir, "comm.jl") |
67 | 66 | text = read(path, String) |
68 | 67 | mod = Atom |
69 | 68 | key = "Atom" |
|
79 | 78 | # check caching works |
80 | 79 | @test haskey(SYMBOLSCACHE, key) |
81 | 80 |
|
82 | | - # check the Revise-like approach finds all the included files |
83 | | - let numfiles = 0 |
84 | | - debuggerpath = realpath′(joinpath(@__DIR__, "..", "src", "debugger")) |
85 | | - profilerpath = realpath′(joinpath(@__DIR__, "..", "src", "profiler")) |
86 | | - for (d, ds, fs) ∈ walkdir(dir) |
87 | | - if d ∈ (debuggerpath, profilerpath) |
88 | | - numfiles += 1 # debugger.jl / traceur.jl (in Atom module) |
89 | | - continue |
90 | | - end |
91 | | - for f ∈ fs |
92 | | - if endswith(f, ".jl") # .jl check is needed for travis, who creates hoge.cov files |
93 | | - numfiles += 1 |
94 | | - end |
95 | | - end |
96 | | - end |
97 | | - @test length(SYMBOLSCACHE[key]) == numfiles |
98 | | - end |
| 81 | + # check the Revise-like approach finds all files in Atom module |
| 82 | + @test length(SYMBOLSCACHE[key]) == length(atommodfiles) |
99 | 83 |
|
100 | 84 | # when `path` isn't given, i.e. via docpane / workspace |
101 | 85 | let items = toplevelgotoitems(word, mod, "", nothing) .|> Dict |
|
106 | 90 |
|
107 | 91 | # same as above, but without any previous cache -- falls back to CSTPraser-based module-walk |
108 | 92 | delete!(SYMBOLSCACHE, key) |
| 93 | + |
109 | 94 | let items = toplevelgotoitems(word, mod, "", nothing) .|> Dict |
110 | 95 | @test !isempty(items) |
111 | 96 | @test items[1][:file] == path |
112 | 97 | @test items[1][:text] == word |
113 | 98 | end |
| 99 | + |
| 100 | + # check CSTPraser-based module-walk finds all the included files |
| 101 | + # currently broken: |
| 102 | + # - files in submodules are included |
| 103 | + # - webio.jl is excluded since `include("webio.jl")` is a toplevel call |
| 104 | + @test_broken length(SYMBOLSCACHE[key]) == length(atommoddir) |
114 | 105 | end |
115 | 106 |
|
116 | 107 | ## where the Revise-like approach doesn't work, e.g. non-precompiled modules |
|
143 | 134 | # handle dot accessors gracefully |
144 | 135 | let |
145 | 136 | # can access the non-exported (non-method) bindings in the other module |
146 | | - path = realpath′(joinpath(@__DIR__, "..", "src", "goto.jl")) |
| 137 | + path = joinpath′(@__DIR__, "..", "src", "goto.jl") |
147 | 138 | text = read(@__FILE__, String) |
148 | 139 | items = Dict.(toplevelgotoitems("Atom.SYMBOLSCACHE", Main, text, @__FILE__)) |
149 | 140 | @test !isempty(items) |
150 | 141 | @test items[1][:file] == path |
151 | 142 | @test items[1][:text] == "SYMBOLSCACHE" |
152 | 143 |
|
153 | 144 | # handle if a module is duplicated |
154 | | - path = realpath′(joinpath(@__DIR__, "..", "src", "comm.jl")) |
| 145 | + path = joinpath′(@__DIR__, "..", "src", "comm.jl") |
155 | 146 | text = read(path, String) |
156 | 147 | items = Dict.(toplevelgotoitems("Atom.handlers", Atom, text, path)) |
157 | 148 | @test !isempty(items) |
|
0 commit comments