Hi,
Is there a way to test a package with check-bounds=no?
It seems that it isnalways yes by default.
I was thinking about something like:
pkg> test --check-bounds=no
Thank you
Hi,
Is there a way to test a package with check-bounds=no?
It seems that it isnalways yes by default.
I was thinking about something like:
pkg> test --check-bounds=no
Thank you
import Pkg
Pkg.test("MyPkg"; julia_args=`--check-bounds=auto`)
This was my first time seeing backticks used like that.
`--check-bounds=auto`
I was surprised to see that it wasn’t wrapped in double quotes, but I later discovered that julia_args
wants a value of the type Union{Cmd, AbstractVector{<:AbstractString}}
.
I didn’t know a Cmd could be non-executable.
Thank you all for your feedbacks.
I did not know that someone else could choose what the solution to my question is. (Just interesting to know)
1/ May I ask what is the rationale behind --check-bounds=auto
instead of --check-bounds=no
. It is not intuitive to me.
2/ Also what is the rationale behind having the REPL run with --check-bounds=no
by default and package tests --check-bounds=yes
by default? It would make more sense if they both run with the same options in the same session, no?
3/ Would it be nice to be able to do pkg> test --check-bounds=no
or auto?
Thanks again.
If --check-bounds
is no
, that disables all boundschecking in the entire Julia process. That is considered way too unsafe, and so this option is not recommended.
By default, the REPL runs with --check-bounds=auto
. The auto
option is nether yes nor no. When it’s auto
, then Julia will bounds check by default, except in @inbounds
blocks. This allows the user to selectively disable boundschecking in small sections of code that the user has manually reviewed.
I think most people would want to run tests with bounds checking always enabled. This is because, if I make a mistake in some block that I have annotated @inbounds
such that it reads out of bounds, I would want Julia to throw an exception in my test suite, instead of segfaulting or exhibiting undefined behaviour, which could lead to hard-to-diagnose bugs. Generally, I don’t care that my test suite runs a little bit slower. But I really do care that my test suite is able to pick up bugs in my code - after all, that’s what it’s there for.
Thank you @jakobnissen.
I think your points 2/ and 3/ answer and correct my assumptions of my question 2/.
My question 3/ was about a feature request in the REPL/package manager command.