Expand description
A test harness for checking and comparing compiler errors with a focus on error spans.
This crate is useful mainly for procedural macros, but can also be used in other contexts where compiler errors need to be verified.
It provides a way to verify that your macro underlines the correct part of the code with its errors, using in-file error annotations.
§Usage
- Add
err_span_checkto yourdev-dependencies. - Create a
tests/faildirectory in your project. - Add
.rsfiles with test cases intests/fail. - Create a test file (e.g.
tests/test.rs) with the following content:
#[test]
fn compile_error_tests() {
err_span_check::run_on_fail_dir();
}- Run
cargo test.
§Workflow
When running tests, err_span_check will automatically update your test files in tests/fail with the actual
compiler errors. You inspect these changes using git diff and commit them if they are correct.
Note: All test cases in tests/fail must be at least staged in git.
See the README for more details.
Functions§
- run_
on_ fail_ dir - The entry point for this crate. Call this once inside of a test function.