-
Notifications
You must be signed in to change notification settings - Fork 11
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Doctests as testitem? #49
Comments
By digging around in the output I found some more information. It probably has to do with the execution of the testitems in a new module:
|
We should probably just try to detect doc tests statically and then treat them as a special kind of test item, or something like that... |
This is the workaround I've been using to run doctests in a I feel like there's got to be better ways to do this, but I'm a Julia beginner so this is the best I could come up with 😅 using TestItems
@testitem "doctests" begin
function with_documenter(fn)
env = "@v#.#"
if !(env in Base.LOAD_PATH)
insert!(Base.LOAD_PATH, 2, env)
@info "changed LOAD_PATH" Base.LOAD_PATH
end
__mod = @__MODULE__()
@eval __mod using Documenter
try
@info "running test fn"
@eval __mod $fn()
@info "test fn done"
catch e
rethrow(e)
finally
let idx = findfirst(isequal(env), Base.LOAD_PATH)
if idx == nothing
return
end
deleteat!(Base.LOAD_PATH, idx)
@info "reset LOAD_PATH" Base.LOAD_PATH
end
end
end
with_documenter() do
DocMeta.setdocmeta!(Musica, :DocTestSetup, :(using Musica); recursive=true)
doctest(Musica; manual=false)
end
end |
I'm not sure how to run doctests as a testitem:
doctest(MyPackage)
is not a bool, so I can't do@test doctest(MyPackage)
inside the@testitem
doctest(MyPackage)
directly inside the@testitem
, it fails with an uninformative error message:The text was updated successfully, but these errors were encountered: