IntelliJ green arrow // build config // cfg(test) on

In IntelliJ, when clicking on the green arrow to build + run, is it possible to have it always have cfg(test) be on?

The context here is: when cfg(test) is off, the build process does NOT provide errors in sections labeled

#[cfg(test)]
{ ... }

but I do want to get the compile errors from those sections.

Thus, is it possible to have IntelliJ green arrows to have cfg(test) on during the build ?

Thanks!

Setting RUSTFLAGS=--cfg test in the run config environment vars might work?

Alternatively you can create a run config for cargo test --no-run and set it as a dependency.

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.