diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index f8dfe73..3cbb45e 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -65,3 +65,4 @@ jobs: - uses: codecov/codecov-action@v7 with: files: lcov.info + token: ${{ secrets.CODECOV_TOKEN }} diff --git a/test/runtests.jl b/test/runtests.jl index a43b16f..d546834 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -95,6 +95,9 @@ end @test pkgfiles("ColorTypes") === nothing @test_throws ErrorException pkgfiles("NotAPkg") + let id = Base.PkgId(CodeTracking) + @test pkgfiles("CodeTracking", id.uuid) === pkgfiles(id) + end # PartialStruct parametric constructors m = @which LikeNamedTuple{(:a,)}((1,)) @@ -120,6 +123,19 @@ end @test whereis(m) == ("REPL[1]", 1) CodeTracking.method_lookup_callback[] = oldlookup + # `MethodInfoKey` iterates as `(method_table, signature)` + let key = MethodInfoKey(nothing, Tuple{typeof(sum), Any}) + mt, sig = key + @test mt === nothing + @test sig === Tuple{typeof(sum), Any} + @test iterate(key, 2) === nothing + end + + # `whereis(lineinfo, method)`: a mismatched basename returns the queried location unchanged + let m = first(methods(f1)) + @test whereis(("elsewhere.jl", 42), m) == (CodeTracking.maybe_fix_path("elsewhere.jl"), 42) + end + # Method definitions ending in semicolon @test code_string(has_semicolon1, (Int, Int)) == "has_semicolon1(x, y) = x + y" @@ -224,6 +240,10 @@ end src, line = definition(String, only(methods(c470))) @test occursin("\$argnames", src) @test line == 137 + # Single-line `eval(:(...))`: definition is recovered from the quoted expression + src, line = definition(String, only(methods(eval_oneline))) + @test occursin("eval_oneline(x)", src) && occursin("2x + 1", src) + @test line == 171 # unnamed arguments m = which(unnamedarg, (Type{String}, Any)) @@ -335,6 +355,8 @@ end (mt, sig) = first(mt_sigs) @test sig == Tuple{typeof(CodeTracking.checkname), Expr, Any} @test pkgfiles(CodeTracking).id == Base.PkgId(CodeTracking) + # A line spanned by no method returns `nothing` + @test signatures_at(CodeTracking, "src/utils.jl", 1) === nothing end # REPL (test copied from Revise). `active_repl` is left `nothing` when no diff --git a/test/script.jl b/test/script.jl index 677ef65..8bde0ab 100644 --- a/test/script.jl +++ b/test/script.jl @@ -166,3 +166,6 @@ struct MyNamedTuple{names, T} end @eval (MyNamedTuple{names, T}(args::T) where {names, T <: Tuple}) = begin $(Expr(:splatnew, :(MyNamedTuple{names, T}), :args)) end + +# Single-line `eval(:(...))`: the method's line points at the `eval` call itself +eval(:(eval_oneline(x) = 2x + 1))