Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

DocTestTeardown for cleaning-up the DocTestSetup state (or similar feature) #2566

Open
maleadt opened this issue Aug 30, 2024 · 1 comment · May be fixed by #2577
Open

DocTestTeardown for cleaning-up the DocTestSetup state (or similar feature) #2566

maleadt opened this issue Aug 30, 2024 · 1 comment · May be fixed by #2577

Comments

@maleadt
Copy link
Contributor

maleadt commented Aug 30, 2024

I'm using DocTestSetup in LLVM.jl to set-up the resource context needed to execute doctests in:

```@meta
DocTestSetup = quote
    using LLVM
    ctx = Context()
end
```

However, that context is supposed to get cleaned up (not only to avoid memory leaks, but also to detect situations where accidentally using resources from a different context). It would be nice if there were a DocTestTeardown where I could put the clean-up:

```@meta
DocTestTeardown = quote
    dispose(ctx)
end
```

Right now, I'm using the following workaround:

```@meta
DocTestSetup = quote
    using LLVM

    # XXX; clean-up previous contexts
    while context(; throw_error=false) !== nothing
        dispose(context())
    end

    ctx = Context()
end
```

Also requested on Discourse, https://discourse.julialang.org/t/is-it-possible-to-run-a-cleanup-code-after-a-jldoctest-block-has-been-evaluated/44999, by @jishnub

@lgoettgens
Copy link

I am working on this and #2058. I'll open a draft PR once there is something to show

@lgoettgens lgoettgens linked a pull request Sep 15, 2024 that will close this issue
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants