rust-osdev / bootimage

Tool to create bootable disk images from a Rust OS kernel.
Apache License 2.0
765 stars 67 forks source link

Cannot run tests on CLion #71

Open gerritsangel opened 3 years ago

gerritsangel commented 3 years ago

I think bootimage has some problems with the custom test runner on CLion/Rust plugin.

CLion can create a Cargo run configuration for tests. This creates the following cargo command:

C:/Programming/Rust/cargo/bin/cargo.exe test --color=always --no-fail-fast -- -Z unstable-options --format=json --show-output

Unfortunately, the arguments after -- are passed to qemu as is

Running: `qemu-system-x86_64 -drive format=raw,file=C:\dev\Workspace\gerrix\target\x86_64-blog_os\debug\deps\bootimage-gerrix-d6bdb98945edd169.bin -no-reboot -device isa-debug-exit,iobase=0xf4,iosize=0x04 -Z unstable-options --format=json --show-output`
qemu-system-x86_64: -Z: invalid option

Running the test via cargo test works, though.

phil-opp commented 3 years ago

It looks like CLion only supports Rust's built-in test runner. I don't think that it would make sense to filter out the --format=json etc arguments in bootimage because the output format would still be incompatible if CLion expects some specific JSON output.

It's probably also worth mentioning that I'm planning to release a new bootloader version that does no longer require bootimage at all and instead lets user define their own small "runner" crates. This should allow you to adjust your runner exactly as you need, including the QEMU arguments.

avrong commented 3 years ago

Rust plugin uses its test tool window to perform tests. It needs cargo test JSON output to show it there, and adds this flag implicitly on test.

As a workaround, you can make an alias to test command in .cargo/config.toml and avoid Rust plugin to add --format=json to the command. Then, use cargo t in cargo run configuration.

[alias]
t = "test"