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.
Probably function names/variables get mixed up? Are you putting all your tests in separate modules?
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.
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
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")
Probably because you ran tests in different environments? Or maybe I misunderstood your MWE.
Hm, not sure I follow - what actually happens when I do test MyPackage
? I thought it was equivalent to running runtests.jl
?
Kinda, but Pkg resolves a set of packages and sets up a new temporary environment
Last updated: Nov 22 2024 at 04:41 UTC