IntelliJ automatically adds -Z unstable-options when Rust tests are run
Asked Answered
E

2

7

I tried to run a simple Rust test in IntelliJ.

The test command IntelliJ uses is:

cargo test --color=always --package myproject-rust --lib mycode::tests --no-fail-fast -- --format=json -Z unstable-options --show-output

The test failed with the error:

error: the option `Z` is only accepted on the nightly compiler

It seems IntelliJ automatically added the -Z unstable-options in the command.

I triggered the test using the small green play button at the left side of my test function:

enter image description here

My test runs fine from the command line.

There is no way I can remove the -Z unstable-options from the test configuration.

What can I do to remove it?

Extraditable answered 19/8, 2023 at 18:49 Comment(8)
I use pycharm-community-edition (also IntelliJ family) with the Rust plugin and never experienced that. How did you trigger the test?Xenon
So what happens, when you click that play button and then in the context menu it opens select "Modify Run Configuration..."?Xenon
@RichardNeumann The tests ran and generated the error above. It automatically generated a test configuration. In the test configuration, there is no way I can remove the -Z option.Extraditable
Weird, as I have a text field there to configure the command line arguments used.Xenon
@RichardNeumann What is your test run command? PyCharm must have generated a similar one. Does it have the -Z option?Extraditable
Tested in one of my projects: test --package ansi-color-codec --lib codec::test_foo -- --exactXenon
Oh, wait. On Windows I get the same issue as you: The above is the command line configured, but the IDE actually runs: test --color=always --package ansi-color-codec --lib codec::foo --no-fail-fast -- --format=json --exact -Z unstable-options --show-output. Looks like a bug.Xenon
There was a breaking change in Rust 1.70, that broke the test experience. Do you have org.rust.cargo.test.tool.window enabled in Help | Find Action | Experimental Features enabled? If yes, try to disable it and check if it helps. It could also help to upgrade to the latest plugin version.Candlepin
C
2

There was a breaking change in Rust 1.70, that broke the test experience. Do you have org.rust.cargo.test.tool.window enabled in Help | Find Action | Experimental Features enabled? If yes, try to disable it.

Doing this, and a restart of IntelliJ fixed the issue for me.

Condition answered 19/8, 2023 at 18:49 Comment(1)
in my current version of RustRover (2024.1.4) that experimental feature is not listed and I do have the issue in Rust 1.79Rasberry
P
2

It is not possible to use debugger in RustRover 2024.1.4 with Rust 1.79, unless you disable checkbox at "File | Settings | Advanced Settings | Rust | Show test results in the Test tool window". But this action disables helpful testing tool.

Polydactyl answered 14/7 at 22:26 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.