Skip to content

Commit

Permalink
Merge pull request #473 from JuliaDebug/kc/fix
Browse files Browse the repository at this point in the history
update test based on the removal of Base.replaceuserpath
  • Loading branch information
KristofferC authored Apr 15, 2021
2 parents b2702ba + 5bbf213 commit cf3f29a
Show file tree
Hide file tree
Showing 6 changed files with 119 additions and 59 deletions.
5 changes: 1 addition & 4 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,8 @@ jobs:
matrix:
version:
- '1.0'
- '1.1'
- '1.2'
- '1.3'
- '1.4'
- '1.5'
- '1'
- 'nightly'
os:
- ubuntu-latest
Expand Down
96 changes: 75 additions & 21 deletions docs/Manifest.toml
Original file line number Diff line number Diff line change
@@ -1,54 +1,78 @@
# This file is machine-generated - editing it directly is not advised

[[ArgTools]]
uuid = "0dad84c5-d112-42e6-8d28-ef12dabb789f"

[[Artifacts]]
uuid = "56f22d72-fd6d-98f1-02f0-08ddc0907c33"

[[Base64]]
uuid = "2a0f44e3-6c83-55bd-87e4-b1978d98bd5f"

[[CodeTracking]]
deps = ["InteractiveUtils", "UUIDs"]
git-tree-sha1 = "9c173f62af93cce8af2bd3527d160b6ddd6eaf81"
git-tree-sha1 = "8ad457cfeb0bca98732c97958ef81000a543e73e"
uuid = "da1fd8a2-8d9e-5ec2-8556-3022fb5608a2"
version = "1.0.0"
version = "1.0.5"

[[Dates]]
deps = ["Printf"]
uuid = "ade2ca70-3891-5945-98fb-dc099432e06a"

[[Distributed]]
deps = ["Random", "Serialization", "Sockets"]
uuid = "8ba89e20-285c-5b6f-9357-94700520ee1b"

[[DocStringExtensions]]
deps = ["LibGit2", "Markdown", "Pkg", "Test"]
git-tree-sha1 = "50ddf44c53698f5e784bbebb3f4b21c5807401b1"
git-tree-sha1 = "9d4f64f79012636741cf01133158a54b24924c32"
uuid = "ffbed154-4ef7-542d-bbb7-c09d3a79fcae"
version = "0.8.3"
version = "0.8.4"

[[Documenter]]
deps = ["Base64", "Dates", "DocStringExtensions", "InteractiveUtils", "JSON", "LibGit2", "Logging", "Markdown", "REPL", "Test", "Unicode"]
git-tree-sha1 = "395fa1554c69735802bba37d9e7d9586fd44326c"
deps = ["Base64", "Dates", "DocStringExtensions", "IOCapture", "InteractiveUtils", "JSON", "LibGit2", "Logging", "Markdown", "REPL", "Test", "Unicode"]
git-tree-sha1 = "3ebb967819b284dc1e3c0422229b58a40a255649"
uuid = "e30172f5-a6a5-5a46-863b-614d45cd2de4"
version = "0.24.11"
version = "0.26.3"

[[Downloads]]
deps = ["ArgTools", "LibCURL", "NetworkOptions"]
uuid = "f43a241f-c20a-4ad4-852c-f6b1247861c6"

[[IOCapture]]
deps = ["Logging"]
git-tree-sha1 = "377252859f740c217b936cebcd918a44f9b53b59"
uuid = "b5f81e59-6552-4d32-b1f0-c071b021bf89"
version = "0.1.1"

[[InteractiveUtils]]
deps = ["Markdown"]
uuid = "b77e0a4c-d291-57a0-90e8-8db25a27a240"

[[JSON]]
deps = ["Dates", "Mmap", "Parsers", "Unicode"]
git-tree-sha1 = "b34d7cef7b337321e97d22242c3c2b91f476748e"
git-tree-sha1 = "81690084b6198a2e1da36fcfda16eeca9f9f24e4"
uuid = "682c06a0-de6a-54ab-a142-c8b1cf79cde6"
version = "0.21.0"
version = "0.21.1"

[[JuliaInterpreter]]
deps = ["CodeTracking", "InteractiveUtils", "Random", "UUIDs"]
path = ".."
uuid = "aa1ae85d-cabe-5617-a682-6adf51b2e16a"
version = "0.8.0"
version = "0.8.11"

[[LibCURL]]
deps = ["LibCURL_jll", "MozillaCACerts_jll"]
uuid = "b27032c2-a3e7-50c8-80cd-2d36dbcbfd21"

[[LibCURL_jll]]
deps = ["Artifacts", "LibSSH2_jll", "Libdl", "MbedTLS_jll", "Zlib_jll", "nghttp2_jll"]
uuid = "deac9b47-8bc7-5906-a0fe-35ac56dc84c0"

[[LibGit2]]
deps = ["Printf"]
deps = ["Base64", "NetworkOptions", "Printf", "SHA"]
uuid = "76f85450-5226-5b5a-8eaa-529ad045b433"

[[LibSSH2_jll]]
deps = ["Artifacts", "Libdl", "MbedTLS_jll"]
uuid = "29816b5a-b9ab-546f-933c-edad1886dfa8"

[[Libdl]]
uuid = "8f399da3-3557-5675-b5ff-fb832c97cbdb"

Expand All @@ -59,25 +83,35 @@ uuid = "56ddb016-857b-54e1-b83d-db4d58db5568"
deps = ["Base64"]
uuid = "d6f4376e-aef5-505a-96c1-9c027394607a"

[[MbedTLS_jll]]
deps = ["Artifacts", "Libdl"]
uuid = "c8ffd9c3-330d-5841-b78e-0817d7145fa1"

[[Mmap]]
uuid = "a63ad114-7e13-5084-954f-fe012c677804"

[[MozillaCACerts_jll]]
uuid = "14a3606d-f60d-562e-9121-12d972cd8159"

[[NetworkOptions]]
uuid = "ca575930-c2e3-43a9-ace4-1e988b2c1908"

[[Parsers]]
deps = ["Dates", "Test"]
git-tree-sha1 = "8077624b3c450b15c087944363606a6ba12f925e"
deps = ["Dates"]
git-tree-sha1 = "c8abc88faa3f7a3950832ac5d6e690881590d6dc"
uuid = "69de0a69-1ddd-5017-9359-2bf0b02dc9f0"
version = "1.0.10"
version = "1.1.0"

[[Pkg]]
deps = ["Dates", "LibGit2", "Libdl", "Logging", "Markdown", "Printf", "REPL", "Random", "SHA", "UUIDs"]
deps = ["Artifacts", "Dates", "Downloads", "LibGit2", "Libdl", "Logging", "Markdown", "Printf", "REPL", "Random", "SHA", "Serialization", "TOML", "Tar", "UUIDs", "p7zip_jll"]
uuid = "44cfe95a-1eb2-52ea-b672-e2afdf69b78f"

[[Printf]]
deps = ["Unicode"]
uuid = "de0858da-6303-5e67-8744-51eddeeeb8d7"

[[REPL]]
deps = ["InteractiveUtils", "Markdown", "Sockets"]
deps = ["InteractiveUtils", "Markdown", "Sockets", "Unicode"]
uuid = "3fa0cd96-eef1-5676-8a61-b3b8758bbffb"

[[Random]]
Expand All @@ -93,8 +127,16 @@ uuid = "9e88b42a-f829-5b0c-bbe9-9e923198166b"
[[Sockets]]
uuid = "6462fe0b-24de-5631-8697-dd941f90decc"

[[TOML]]
deps = ["Dates"]
uuid = "fa267f1f-6049-4f14-aa54-33bafae1ed76"

[[Tar]]
deps = ["ArgTools", "SHA"]
uuid = "a4e569a6-e804-4fa4-b0f3-eef7a1d5b13e"

[[Test]]
deps = ["Distributed", "InteractiveUtils", "Logging", "Random"]
deps = ["InteractiveUtils", "Logging", "Random", "Serialization"]
uuid = "8dfed614-e22c-5e08-85e1-65c5234f0b40"

[[UUIDs]]
Expand All @@ -103,3 +145,15 @@ uuid = "cf7118a7-6976-5b1a-9a39-7adc72f591a4"

[[Unicode]]
uuid = "4ec0a83e-493e-50e2-b9ac-8f72acf5a8f5"

[[Zlib_jll]]
deps = ["Libdl"]
uuid = "83775a58-1f1d-513f-b197-d71354ab007a"

[[nghttp2_jll]]
deps = ["Artifacts", "Libdl"]
uuid = "8e850ede-7688-5339-a07c-302acd2aaf8d"

[[p7zip_jll]]
deps = ["Artifacts", "Libdl"]
uuid = "3f19e933-33d8-53b3-aaab-bd5110c3b7a0"
46 changes: 24 additions & 22 deletions docs/src/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ Using this package as an interpreter is straightforward:
julia> using JuliaInterpreter
julia> list = [1, 2, 5]
3-element Array{Int64,1}:
3-element Vector{Int64}:
1
2
5
Expand Down Expand Up @@ -53,11 +53,12 @@ julia> @interpret sum([1,2,3]) # no element bigger than 4, breakpoint should no
6
julia> frame, bpref = @interpret sum([1,2,5]) # should trigger breakpoint
(Frame for sum(a::AbstractArray; dims) in Base at reducedim.jl:652
c 1* 652 1 ─ nothing
2 652 │ %2 = (Base.#sum#583)(Colon(), #self#, a)
3 652 └── return %2
a = [1, 2, 5], breakpoint(sum(a::AbstractArray; dims) in Base at reducedim.jl:652, line 652))
(Frame for sum(a::AbstractArray; dims, kw...) in Base at reducedim.jl:873
c 1* 873 1 ─ nothing
2 873 │ %2 = ($(QuoteNode(NamedTuple)))()
3 873 │ %3 = Base.pairs(%2)
a = [1, 2, 5], breakpoint(sum(a::AbstractArray; dims, kw...) in Base at reducedim.jl:873, line 873))
```

`frame` is described in more detail on the next page; for now, suffice it to say
Expand All @@ -74,11 +75,12 @@ julia> @interpret sum([1,2,5])
julia> enable(bp)
julia> @interpret sum([1,2,5])
(Frame for sum(a::AbstractArray; dims) in Base at reducedim.jl:652
c 1* 652 1 ─ nothing
2 652 │ %2 = (Base.#sum#583)(Colon(), #self#, a)
3 652 └── return %2
a = [1, 2, 5], breakpoint(sum(a::AbstractArray; dims) in Base at reducedim.jl:652, line 652))
(Frame for sum(a::AbstractArray; dims, kw...) in Base at reducedim.jl:873
c 1* 873 1 ─ nothing
2 873 │ %2 = ($(QuoteNode(NamedTuple)))()
3 873 │ %3 = Base.pairs(%2)
a = [1, 2, 5], breakpoint(sum(a::AbstractArray; dims, kw...) in Base at reducedim.jl:873, line 873))
```

[`disable`](@ref) and [`enable`](@ref) allow you to turn breakpoints off and on without losing any
Expand Down Expand Up @@ -107,17 +109,17 @@ julia> break_on(:error)
julia> fr, pc = @interpret f_outer()
before error
(Frame for f_outer() in Main at none:2
1 2 1 ─ (println)("before error")
2* 3 │ (f_inner)()
3 4 │ %3 = (println)("after error")
(Frame for f_outer() in Main at none:1
1 2 1 ─ Base.println("before error")
2* 3 │ f_inner()
3 4 │ %3 = Base.println("after error")
4 4 └── return %3
callee: f_inner() in Main at none:1, breakpoint(error(s::AbstractString) in Base at error.jl:33, line 33, ErrorException("inner error")))
julia> leaf(fr)
Frame for error(s::AbstractString) in Base at error.jl:33
1 33 1 ─ %1 = (ErrorException)(s)
2* 33 │ %2 = (throw)(%1)
1 33 1 ─ %1 = ($(QuoteNode(ErrorException)))(_2)
2* 33 │ %2 = Core.throw(%1)
3 33 └── return %2
s = "inner error"
caller: f_inner() in Main at none:1
Expand Down Expand Up @@ -152,18 +154,18 @@ julia> @interpret myfunction(1, 2)
6
julia> @interpret myfunction(5, 6)
(Frame for myfunction(x, y) in Main at none:2
(Frame for myfunction(x, y) in Main at none:1
3 4 │ %3 = (>)(x, 3)
3 4 │ %3 = _2 > 3
4 4 └── goto #3 if not %3
b 5* 4 2 ─ nothing
6 4 └── goto #3
7 5 3 ┄ %7 = (+)(a, b, x, y)
7 5 3 ┄ %7 = _5 + _4 + _2 + _3
x = 5
y = 6
a = 1
b = 2, breakpoint(myfunction(x, y) in Main at none:2, line 4))
b = 2
a = 1, breakpoint(myfunction(x, y) in Main at none:1, line 4))
```

Here the breakpoint is marked with a `b` indicating that it is an unconditional breakpoint.
Expand Down
16 changes: 8 additions & 8 deletions src/construct.jl
Original file line number Diff line number Diff line change
Expand Up @@ -240,15 +240,15 @@ julia> framecode
1 1 1 ─ return 1
julia> frameargs
2-element Array{Any,1}:
2-element Vector{Any}:
mymethod (generic function with 1 method)
[1.0, 2.0]
julia> lenv
svec(Float64)
julia> argtypes
Tuple{typeof(mymethod),Array{Float64,1}}
Tuple{typeof(mymethod), Vector{Float64}}
```
"""
function prepare_call(@nospecialize(f), allargs; enter_generated = false)
Expand Down Expand Up @@ -616,20 +616,20 @@ mymethod (generic function with 1 method)
julia> JuliaInterpreter.enter_call_expr(:(\$mymethod(1)))
Frame for mymethod(x) in Main at none:1
1* 1 1 ─ %1 = (+)(x, 1)
1* 1 1 ─ %1 = _2 + 1
2 1 └── return %1
x = 1
julia> mymethod(x::Vector{T}) where T = 1
mymethod (generic function with 2 methods)
julia> a = [1.0, 2.0]
2-element Array{Float64,1}:
2-element Vector{Float64}:
1.0
2.0
julia> JuliaInterpreter.enter_call_expr(:(\$mymethod(\$a)))
Frame for mymethod(x::Array{T,1}) where T in Main at none:1
Frame for mymethod(x::Vector{T}) where T in Main at none:1
1* 1 1 ─ return 1
x = [1.0, 2.0]
T = Float64
Expand Down Expand Up @@ -659,15 +659,15 @@ mymethod (generic function with 1 method)
julia> JuliaInterpreter.enter_call(mymethod, 1)
Frame for mymethod(x) in Main at none:1
1* 1 1 ─ %1 = (+)(x, 1)
1* 1 1 ─ %1 = _2 + 1
2 1 └── return %1
x = 1
julia> mymethod(x::Vector{T}) where T = 1
mymethod (generic function with 2 methods)
julia> JuliaInterpreter.enter_call(mymethod, [1.0, 2.0])
Frame for mymethod(x::Array{T,1}) where T in Main at none:1
Frame for mymethod(x::Vector{T}) where T in Main at none:1
1* 1 1 ─ return 1
x = [1.0, 2.0]
T = Float64
Expand Down Expand Up @@ -753,7 +753,7 @@ Evaluate `f` on the specified arguments using the interpreter.
```jldoctest
julia> a = [1, 7]
2-element Array{Int64,1}:
2-element Vector{Int64}:
1
7
Expand Down
4 changes: 2 additions & 2 deletions src/utils.jl
Original file line number Diff line number Diff line change
Expand Up @@ -596,7 +596,7 @@ julia> JuliaInterpreter.step_expr!(frame);
julia> JuliaInterpreter.step_expr!(frame);
julia> JuliaInterpreter.locals(frame)
2-element Array{JuliaInterpreter.Variable,1}:
2-element Vector{JuliaInterpreter.Variable}:
#self# = capture
x = Core.Box(1)
Expand All @@ -607,7 +607,7 @@ julia> JuliaInterpreter.eval_code(frame, "x = 2")
2
julia> JuliaInterpreter.locals(frame)
2-element Array{JuliaInterpreter.Variable,1}:
2-element Vector{JuliaInterpreter.Variable}:
#self# = capture
x = Core.Box(2)
```
Expand Down
11 changes: 9 additions & 2 deletions test/interpret.jl
Original file line number Diff line number Diff line change
Expand Up @@ -495,6 +495,13 @@ g_1(x) = g_2(x)
g_2(x) = g_3(x)
g_3(x) = error("foo")
line_g = @__LINE__

if isdefined(Base, :replaceuserpath)
_contractuser = Base.replaceuserpath
else
_contractuser = Base.contractuser
end

try
break_on(:error)
local frame, bp = @interpret g_1(2.0)
Expand All @@ -503,7 +510,7 @@ try
if isdefined(Base, :print_stackframe)
@test occursin("[1] error(s::String)", stacktrace_lines[3])
@test occursin("[2] g_3(x::Float64)", stacktrace_lines[5])
thefile = Base.replaceuserpath(@__FILE__)
thefile = _contractuser(@__FILE__)
@test occursin("$thefile:$(line_g - 1)", stacktrace_lines[6])
@test occursin("[3] g_2(x::Float64)", stacktrace_lines[7])
@test occursin("$thefile:$(line_g - 2)", stacktrace_lines[8])
Expand Down Expand Up @@ -531,7 +538,7 @@ try
@test occursin(string("ERROR: ", sprint(showerror, ErrorException("foo"))), stacktrace_lines[1])
if isdefined(Base, :print_stackframe)
@test occursin("[1] error(s::String)", stacktrace_lines[3])
thefile = Base.replaceuserpath(@__FILE__)
thefile = _contractuser(@__FILE__)
@test occursin("[2] g_3(x::Float64)", stacktrace_lines[5])
@test occursin("$thefile:$(line_g - 1)", stacktrace_lines[6])
@test occursin("[3] g_2(x::Float64)", stacktrace_lines[7])
Expand Down

0 comments on commit cf3f29a

Please sign in to comment.