# How to execute additional code before runtests.jl?

**URL:** <https://discourse.julialang.org/t/how-to-execute-additional-code-before-runtests-jl/113854>\
**Category:** General Usage\
**Tags:** question, testing, ci\
**Created:** [May 5, 2024, 5:47am UTC](https://discourse.julialang.org/t/how-to-execute-additional-code-before-runtests-jl/113854 "2024-05-05T05:47:42Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![nsajko](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/nsajko/32/221187_2.png) [@nsajko](https://discourse.julialang.org/u/nsajko)\
**Post date:** [May 5, 2024, 5:47am UTC](https://discourse.julialang.org/t/how-to-execute-additional-code-before-runtests-jl/113854/1 "2024-05-05T05:47:42Z")

</div>

I’m trying to solve [How to detect whether the build (compiler options) is a production build](https://discourse.julialang.org/t/how-to-detect-whether-the-build-compiler-options-is-a-production-build/113827/). I think the right solution is to introduce a global boolean constant whose value would be determined by the user (most often CI) so that it would be available within `test/runtests.jl`. This could be solved with Preferences.jl, however that seems unnecessarily complicated as it involves TOML files on disk.

Is there a way to define a statement like `const flag = true` that would execute before `test/runtests.jl`. It should be easy to use from CI.

---

<div class="post-metadata">

**Author:** ![cjdoris](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/cjdoris/32/213133_2.png) [@cjdoris](https://discourse.julialang.org/u/cjdoris)\
**Post date:** [May 5, 2024, 6:11am UTC](https://discourse.julialang.org/t/how-to-execute-additional-code-before-runtests-jl/113854/2 "2024-05-05T06:11:40Z")

</div>

Use an environment variable? Most CI platforms already set the `CI` env variable for you.

---

<div class="post-metadata">

**Author:** ![abraemer](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/abraemer/32/51403_2.png) [@abraemer](https://discourse.julialang.org/u/abraemer)\
**Post date:** [May 5, 2024, 6:11am UTC](https://discourse.julialang.org/t/how-to-execute-additional-code-before-runtests-jl/113854/3 "2024-05-05T06:11:42Z")

</div>

Could you just use a command line argument for that?

Edit: I think @cjdoris suggestion makes more sense.
