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

Adding methods to existing functions in test setups is not isolated to the users of the setup #184

Open
Drvi opened this issue Sep 16, 2024 · 0 comments
Labels
speculative a feature idea that we are undecided about

Comments

@Drvi
Copy link
Collaborator

Drvi commented Sep 16, 2024

This led to at least one confusing situation where removing a test setup from a test item didn't cause a failure because the required methods leaked the test setup and were available to the test item regardless, MRE:

@testsetup module B
    import ReTestItems
    ReTestItems.runtests(::Int) = 1
end

@testitem "t1" begin @test ReTestItems.runtests(1) == 1 end
@testitem "t2" begin @test ReTestItems.runtests(1) == 1 end
@testitem "t3" begin @test ReTestItems.runtests(1) == 1 end
@testitem "t4" begin @test ReTestItems.runtests(1) == 1 end
@testitem "t5" begin @test ReTestItems.runtests(1) == 1 end
@testitem "t50" setup=[B] begin @test B.ReTestItems.runtests(1) == 1 end
@testitem "t96" begin @test ReTestItems.runtests(1) == 1 end
@testitem "t97" begin @test ReTestItems.runtests(1) == 1 end
@testitem "t98" begin @test ReTestItems.runtests(1) == 1 end
@testitem "t99" begin @test ReTestItems.runtests(1) == 1 end
@testitem "t100" begin @test ReTestItems.runtests(1) == 1 end
Test Summary:    | Pass  Error  Total  Time
ReTestItems      |    6      5     11  3.4s
  .              |    6      5     11      
    the-tests.jl |    6      5     11      
      t1         |           1      1  0.9s
      t2         |           1      1  0.0s
      t3         |           1      1  0.0s
      t4         |           1      1  0.0s
      t5         |           1      1  0.0s
      t50        |    1             1  0.1s
      t96        |    1             1  0.0s
      t97        |    1             1  0.0s
      t98        |    1             1  0.0s
      t99        |    1             1  0.0s
      t100       |    1             1  0.0s

There isn't probably much to do about this, but maybe we should investigate whether Base.Experimental.@MethodTable could be used to make test setups more isolated.

@nickrobinson251 nickrobinson251 added the speculative a feature idea that we are undecided about label Sep 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
speculative a feature idea that we are undecided about
Projects
None yet
Development

No branches or pull requests

2 participants