oli-obk / ui_test

A test framework for testing rustc diagnostics output
24 stars 24 forks source link

A test runner that builds tests with rustc or cargo (or any other compiler with some configuration effort) and compares the output of the compiler with a file that you check into git. This allows you to test how your libraries show up to your users when the library is used wrongly and emits errors.

Usage

See examples directory for how to use this in your own crate. To be able to use it with cargo test, you need to put

[[test]]
name = "your_test_file"
harness = false

into your Cargo.toml, otherwise cargo test will only look for #[test]s and not run your fn main() that actually executes ui_test

Implicit (and possibly surprising) behavior

Supported comment annotations

If your test tests for failure, you need to add a //~ annotation where the error is happening to ensure that the test will always keep failing at the annotated line. These comments can take two forms:

In order to change how a single test is tested, you can add various //@ comments to the test. Any other comments will be ignored, and all //@ comments must be formatted precisely as their command specifies, or the test will fail without even being run.

Significant differences to compiletest-rs