Documenter.jl
Documenter.jl copied to clipboard
Make doctest runnable inside @testitem
I am unable to make doctset runnable inside @testitem
@testitem "Doctests (Documenter.jl)" begin
using MyPackage
using Documenter
DocMeta.setdocmeta!(MyPackage, :DocTestSetup, :(using MyPackage); recursive=true)
doctest(MyPackage)
end
fails with
┌ Error: Failed to evaluate `CurrentModule = MyPackage` in `@meta` block.
│ exception =
│ UndefVarError: `MyPackage` not defined in `Main`
│ Suggestion: check for spelling errors or missing imports.
│ Hint: MyPackage is loaded but not imported in the active module Main.
└ @ Documenter ~/.julia/packages/Documenter/HdXI4/src/utilities/utilities.jl:47
Hmm this is an interesting point. All meta blocks are eval'ed into Main by default, so if Main doesn't have the modules you need, it's not going to work.
A monkeypatch would be to add an @eval Main import MyPackage into your test item, which should get it to work, but a 'cleaner' solution will need some more thought.