Stream: helpdesk (published)

Topic: Testing issues


view this post on Zulip Nils (Mar 02 2021 at 10:26):

I have a weird issue with my tests: when I do

(@v1.6) pkg> gc --all # to avoid any saved copies of the local package

(...)

(@v1.6) pkg> activate --temp
  Activating new environment at `C:\Users\ngudat\AppData\Local\Temp\jl_rApJIG\Project.toml`

(jl_rApJIG) pkg> add "C:/Users/ngudat/.julia/dev/MyPackage"

(...)

(jl_rApJIG) pkg> test MyPackage

I get

     Testing Running tests...
Test Summary: | Pass  Total
Constructors  |    1      1
MyPackage: Error During Test at C:\Users\ngudat\.julia\packages\MyPackage\mJoC0\test\runtests.jl:10
  Got exception outside of a @test
  BoundsError: attempt to access 2-element Vector{Float64} at index [3]

But when I do

julia> include("C:\\Users\\ngudat\\.julia\\dev\\MyPackage\\test\\runtests.jl")
Test Summary: | Pass  Total
Constructors  |    1      1
Test Summary: | Pass  Total
Functions     |    2      2

So I don't really know how to debug this, as running the tests "manually" works. What is test MyPackage doing differently? I get the same error in GitHub CI.

view this post on Zulip Andrey Oskin (Mar 02 2021 at 10:31):

Probably function names/variables get mixed up? Are you putting all your tests in separate modules?

view this post on Zulip Fredrik Ekre (Mar 02 2021 at 10:42):

You probably want to use dev instead of add on your local path. add uses the content of the last commit in the repo at that path while dev just points to the content in that folder on the fs.

view this post on Zulip Nils (Mar 02 2021 at 10:55):

Ah, dev is definitely a good shout, that also allows me to change runtests.jl and have those changes reflected when I re-run test MyPackage

view this post on Zulip Nils (Mar 02 2021 at 10:56):

I have also figured out what the error was (I initialized an array with t where it should have been t+1), but I'm still at a loss as to how this error didn't occur when doing include(".../runtests.jl")

view this post on Zulip Fredrik Ekre (Mar 02 2021 at 10:59):

Probably because you ran tests in different environments? Or maybe I misunderstood your MWE.

view this post on Zulip Nils (Mar 02 2021 at 12:59):

Hm, not sure I follow - what actually happens when I do test MyPackage? I thought it was equivalent to running runtests.jl?

view this post on Zulip Fredrik Ekre (Mar 02 2021 at 13:17):

Kinda, but Pkg resolves a set of packages and sets up a new temporary environment


Last updated: Oct 02 2023 at 04:34 UTC