Clarify that we can remove the test_runner stub from basic_boot.rs

Fixes #945
This commit is contained in:
Philipp Oppermann
2021-03-19 11:12:28 +01:00
parent e2ea67a826
commit 42c550fcde

View File

@@ -836,7 +836,7 @@ At this point, `cargo run` and `cargo test` should work again. Of course, `cargo
### Completing the Integration Test
Like our `src/main.rs`, our `tests/basic_boot.rs` executable can import types from our new library. This allows us to import the missing components to complete our test.
Like our `src/main.rs`, our `tests/basic_boot.rs` executable can import types from our new library. This allows us to import the missing components to complete our test:
```rust
// in tests/basic_boot.rs
@@ -849,7 +849,7 @@ fn panic(info: &PanicInfo) -> ! {
}
```
Instead of reimplementing the test runner, we use the `test_runner` function from our library. For our `panic` handler, we call the `blog_os::test_panic_handler` function like we did in our `main.rs`.
Instead of reimplementing the test runner, we use the `test_runner` function from our library by changing the `#![test_runner(crate::test_runner)]` attribute to `#![test_runner(blog_os::test_runner)]`. We then don't need the `test_runner` stub function in `basic_boot.rs` anymore, so we can remove it. For our `panic` handler, we call the `blog_os::test_panic_handler` function like we did in our `main.rs`.
Now `cargo test` exits normally again. When you run it, you see that it builds and runs the tests for our `lib.rs`, `main.rs`, and `basic_boot.rs` separately after each other. For the `main.rs` and the `basic_boot` integration test, it reports "Running 0 tests" since these files don't have any functions annotated with `#[test_case]`.