Skip to content
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

Tests are not re-runnable in same session #93

Open
ericphanson opened this issue Jun 11, 2023 · 0 comments
Open

Tests are not re-runnable in same session #93

ericphanson opened this issue Jun 11, 2023 · 0 comments

Comments

@ericphanson
Copy link
Member

My usual workflow is something like:

using TestEnv
TestEnv.activate()
include("test/runtests.jl")
# Change code in tests/package using Revise
include("test/runtests.jl")

However for Legolas that breaks in a few places:

@test_throws SchemaVersionDeclarationError("no prior `@schema` declaration found in current module") @version(TestV1, begin x end)

This test depends on what has already been defined in Main, which seems like a bad practice unto itself. That can be fixed by wrapping it in a module.

Legolas.jl/test/runtests.jl

Lines 552 to 558 in b86444c

_num_calls = Ref{Int}(0)
@version FieldErrorV2 begin
a::Integer = begin
_num_calls[] += 1
a isa Function ? a() : a
end
end

This definition when called a second time says that it is an invalid redefinition. I suppose this too could be wrapped in a module (which gets replaced when the tests are re-included, so there is no struct redefinition).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant