# Erratic test failure: difference between \]test and include(./test/runtests.jl)

**URL:** https://discourse.julialang.org/t/erratic-test-failure-difference-between-test-and-include-test-runtests-jl/72342
**Category:** General Usage
**Tags:** package, testing
**Created:** [December 1, 2021, 5:25am UTC](https://discourse.julialang.org/t/erratic-test-failure-difference-between-test-and-include-test-runtests-jl/72342 "2021-12-01T05:25:51Z")
**Posts on this page:** 9
**Page:** 1

<div class="post-metadata">

### Author: ![fipelle](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/fipelle/32/4772_2.png) [@fipelle](https://discourse.julialang.org/u/fipelle)
#### Post date: [December 1, 2021, 5:25am UTC](https://discourse.julialang.org/t/erratic-test-failure-difference-between-test-and-include-test-runtests-jl/72342/1 "2021-12-01T05:25:51Z")

</div>

Hi,

I am having a strange problem with the tests of one of my packages, [MessyTimeSeriesOptim.jl](https://github.com/fipelle/MessyTimeSeriesOptim.jl), which is currently under registration.

I have cloned the `dev` branch on my laptop and added the package via `Pkg.add(path="...")`. All tests pass if I run them via `include("./test/runtests.jl")`. However, if I use the more usual `]test MessyTimeSeriesOptim` they fail at the testset `"DFM simulations: MLE"`.

Why is `]test` behaving differently from `include("./test/runtests.jl")`?

---

<div class="post-metadata">

### Author: ![Tomas\_Pevny](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tomas_pevny/32/25466_2.png) [@Tomas\_Pevny](https://discourse.julialang.org/u/Tomas_Pevny)
#### Post date: [December 1, 2021, 10:47am UTC](https://discourse.julialang.org/t/erratic-test-failure-difference-between-test-and-include-test-runtests-jl/72342/2 "2021-12-01T10:47:30Z")

</div>

I have been once solving problem like this and it was caused by bounds checking. When you run the code with `include`, it inherits bounds checking from julia, if you test by `]test` bounds are always checked, even though there is an `@inbounds`, i.e. it is overrided.

---

<div class="post-metadata">

### Author: ![fipelle](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/fipelle/32/4772_2.png) [@fipelle](https://discourse.julialang.org/u/fipelle)
#### Post date: [December 1, 2021, 3:09pm UTC](https://discourse.julialang.org/t/erratic-test-failure-difference-between-test-and-include-test-runtests-jl/72342/3 "2021-12-01T15:09:35Z")

</div>

I see, thanks. However, I am not getting an error, it simply returns different floats at the end of the run. Is there anything else that gets overwritten with `]test`?

---

<div class="post-metadata">

### Author: ![kristoffer.carlsson](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/kristoffer.carlsson/32/22_2.png) [@kristoffer.carlsson](https://discourse.julialang.org/u/kristoffer.carlsson)
#### Post date: [December 1, 2021, 3:18pm UTC](https://discourse.julialang.org/t/erratic-test-failure-difference-between-test-and-include-test-runtests-jl/72342/4 "2021-12-01T15:18:26Z")

</div>

> [@fipelle](#):
>
> Why is `]test` behaving differently from `include("./test/runtests.jl")` ?

`]test` runs with boundschecking forced to on (`--check-bounds=yes`).

---

<div class="post-metadata">

### Author: ![fipelle](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/fipelle/32/4772_2.png) [@fipelle](https://discourse.julialang.org/u/fipelle)
#### Post date: [December 1, 2021, 3:27pm UTC](https://discourse.julialang.org/t/erratic-test-failure-difference-between-test-and-include-test-runtests-jl/72342/5 "2021-12-01T15:27:54Z")

</div>

@kristoffer.carlsson:

If I include `runtests.jl` with `--check-bounds=yes` I get the same problem. However, if I remove all `@inbounds` and `@turbo` in my code and include `runtests.jl` without `--check-bounds=yes` all tests pass. Is `--check-bounds=yes` doing anything else? Can it affect one of my dependencies rather than my package directly? Also, is it possible to highlight which lines behave differently with `-check-bounds=yes`?

---

<div class="post-metadata">

### Author: ![kristoffer.carlsson](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/kristoffer.carlsson/32/22_2.png) [@kristoffer.carlsson](https://discourse.julialang.org/u/kristoffer.carlsson)
#### Post date: [December 1, 2021, 5:48pm UTC](https://discourse.julialang.org/t/erratic-test-failure-difference-between-test-and-include-test-runtests-jl/72342/6 "2021-12-01T17:48:58Z")

</div>

> [@fipelle](#):
>
> Also, is it possible to highlight which lines behave differently with `-check-bounds=yes` ?

The ones with `@inbounds`. Usually the numeric difference comes from the code being able to use SIMD or not depending on the bounds checking behaviour.

---

<div class="post-metadata">

### Author: ![fipelle](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/fipelle/32/4772_2.png) [@fipelle](https://discourse.julialang.org/u/fipelle)
#### Post date: [December 1, 2021, 9:19pm UTC](https://discourse.julialang.org/t/erratic-test-failure-difference-between-test-and-include-test-runtests-jl/72342/7 "2021-12-01T21:19:41Z")

</div>

Right, but I removed all `@turbo` and `@inbounds` now, and I am not using `@simd` directly. Can it be caused by some dependency?

---

<div class="post-metadata">

### Author: ![kristoffer.carlsson](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/kristoffer.carlsson/32/22_2.png) [@kristoffer.carlsson](https://discourse.julialang.org/u/kristoffer.carlsson)
#### Post date: [December 1, 2021, 10:25pm UTC](https://discourse.julialang.org/t/erratic-test-failure-difference-between-test-and-include-test-runtests-jl/72342/8 "2021-12-01T22:25:09Z")

</div>

It’s actually places that use `@simd` that are interesting. Could be in Base.

---

<div class="post-metadata">

### Author: ![fipelle](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/fipelle/32/4772_2.png) [@fipelle](https://discourse.julialang.org/u/fipelle)
#### Post date: [December 3, 2021, 3:28am UTC](https://discourse.julialang.org/t/erratic-test-failure-difference-between-test-and-include-test-runtests-jl/72342/9 "2021-12-03T03:28:50Z")

</div>

Thanks. I have double checked everything and the differences are minimal with/without check bounds. However, I was using a very small tolerance for the tests that were failing. I suppose that these small numerical differences are coming from somewhere in Base.
