Testing #1009
Replies: 161 comments 68 replies
-
I'm not sure if I did something wrong, but by following along with this guide exactly I was receiving an error about fmt being undeclared after setting up the CompareMessage implementation. I fixed it by adding |
Beta Was this translation helpful? Give feedback.
-
@leggettc18 You did nothing wrong, I forgot to mention these imports. Fixed in 1f97103. Thanks for reporting! |
Beta Was this translation helpful? Give feedback.
-
I'm unable to run
|
Beta Was this translation helpful? Give feedback.
-
Try I have the same problem but couldn't figure out why the file isn't automatically found. |
Beta Was this translation helpful? Give feedback.
-
@AntoineSebert Do you have a @Beidah Sounds like forgot a |
Beta Was this translation helpful? Give feedback.
-
@phil-opp Yes it's there. The problem seems to have disappread today, and anyway it's not a big deal. |
Beta Was this translation helpful? Give feedback.
-
The recent improvements in the test framework now produce text outputs that are not colored in green, thus making the test result less visible within the terminal. |
Beta Was this translation helpful? Give feedback.
-
Yes, there is! You can use ANSI escape codes for coloring. For example, you can create a type to print something in green: use core::fmt;
struct Green(&'static str);
impl fmt::Display for Green {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "\x1B[32m")?; // prefix code
write!(f, "{}", self.0)?;
write!(f, "\x1B[0m")?; // postfix code
Ok(())
}
} Now you can do I opened #603 for adding this to the post. |
Beta Was this translation helpful? Give feedback.
-
In the process of adding tests, I encountered some strange errors. In this test, I simply created a writer, but failed, and judging from the error message, it seems that it did not execute any tests at all, because I did not see the information printed by test_runner or panic_handler on the console. lws@lsw:/document/project/flandre-os/FlandreOS$ cargo xtest test_default_writer
Compiling flandre_os v0.0.1 (/document/project/flandre-os/FlandreOS)
Finished dev [unoptimized + debuginfo] target(s) in 0.33s
Running target/x86_64-flandre_os/debug/deps/flandre_os-d120248f92b70111
Building bootloader
Compiling bootloader v0.6.0 (/work/tool/rust/cargo/registry/src/mirrors.ustc.edu.cn-61ef6e0cd06fb9b8/bootloader-0.6.0)
Finished release [optimized + debuginfo] target(s) in 0.72s
Running: `qemu-system-x86_64 -drive format=raw,file=/document/project/flandre-os/FlandreOS/target/x86_64-flandre_os/debug/deps/bootimage-flandre_os-d120248f92b70111.bin -device isa-debug-exit,iobase=0xf4,iosize=0x04 -serial stdio -display none test_default_writer`
qemu-system-x86_64: -display none: drive with bus=0, unit=0 (index=0) exists
error: test failed, to rerun pass '--lib'
|
Beta Was this translation helpful? Give feedback.
-
I did all kinds of printing tests and the printing function seemed to work normally, but when I tried to add some tests to ensure that these functions would not be damaged in future modifications, I got the above errors. |
Beta Was this translation helpful? Give feedback.
-
I think passing a test name to |
Beta Was this translation helpful? Give feedback.
-
Yes, as you see from the "Running: What you can do is to run the tests of the library component through |
Beta Was this translation helpful? Give feedback.
-
I tried adding the "x" as you indicated in the above paragraph. The test did not fail. WIth some more fooling about i see that the I have submitted a pull request #610 |
Beta Was this translation helpful? Give feedback.
-
@xj42 Thanks a lot for reporting! I created #611 to fix this. |
Beta Was this translation helpful? Give feedback.
-
Hi, thank you for taking your time and effort into making this brilliant blog! I've learnt so much about operating systems and the Rust language in general! Can't wait to see how this blog unfolds and what new things you'll bring. I just wanted to ask if it is the expected behaviour for It seems to me that perhaps this was the desired behaviour? If so, is there a way for me to send data to the serial port while the QEMU instance is running as normal? |
Beta Was this translation helpful? Give feedback.
-
Its extremely hard to find a tutor for Rust that does OS Development lol |
Beta Was this translation helpful? Give feedback.
-
Hi! First of all appreciate for your absolutely awesome tutorial! I met a problem at very beginning of this section. After replacing the default test framework by inserting below announcement and #![feature(custom_test_frameworks)]
#![test_runner(crate::test_runner)]
#![reexport_test_harness_main = "test_main"] Then I met the problem of “duplicate lang item” errors. So I remove all Thank you so much! |
Beta Was this translation helpful? Give feedback.
-
On macOS, running error: could not compile `spin` (lib) due to 118 previous errors``` |
Beta Was this translation helpful? Give feedback.
-
Hello, when i run the cargo test command i got this error :
my config.toml file :
my json file :
and yes i have :
Thanks you. |
Beta Was this translation helpful? Give feedback.
-
I'm getting a segfault on the first step of adding the test_runner function and running the cargo test. Is there anything that could explain this behavior?? |
Beta Was this translation helpful? Give feedback.
-
hi!
My rust.yml looks like this:
anyone know why this is happening? |
Beta Was this translation helpful? Give feedback.
-
Hi, when I try to pass arguments "-display none" to QUME, and then run the cargo test, it will below error message.
|
Beta Was this translation helpful? Give feedback.
-
The section where we try to print the names of the test functions is not functioning correctly for me. Whenever I use core::any::type_name::(), it only prints the actual type, which is &dyn core::ops::function::Fn() instead of the function's name. |
Beta Was this translation helpful? Give feedback.
-
main.rs:
|
Beta Was this translation helpful? Give feedback.
-
Is it possible to move the testing module such as test_panic_handler, exit_qemu, Testable trait from lib.rs into its own dedicated file? It would make the code more structured and but I've had a problem with test_main(), where I've tried importing it via use crate::test_main() and also included these attributes in the dedicated testing module file: #![feature(custom_test_frameworks)] Anyone have any thoughts? |
Beta Was this translation helpful? Give feedback.
-
Is there a solution so that if the the test panics, can we continue? |
Beta Was this translation helpful? Give feedback.
-
The step after testing is to get coverage data.
|
Beta Was this translation helpful? Give feedback.
-
cargo test gives this: (signal: 11, SIGSEGV: invalid memory reference) |
Beta Was this translation helpful? Give feedback.
-
If anyone else is experience the same issue that I was with Insert into your Make sure you're using the latest nightly compiler. |
Beta Was this translation helpful? Give feedback.
-
both lib.rs and basic_boot.rs contain a entry point function "_start", but cargo test still compile. Why is that? |
Beta Was this translation helpful? Give feedback.
-
This is a general purpose comment thread for the Testing post.
Beta Was this translation helpful? Give feedback.
All reactions