mirror of
https://github.com/rust-lang/rust-analyzer
synced 2024-12-25 20:43:21 +00:00
Document inline tests infra
This commit is contained in:
parent
9b3d806b0d
commit
2fd3228525
1 changed files with 15 additions and 1 deletions
|
@ -19,12 +19,26 @@ files to have the same name except for the leading number. In general,
|
||||||
test suite should be append-only: old tests should not be modified,
|
test suite should be append-only: old tests should not be modified,
|
||||||
new tests should be created instead.
|
new tests should be created instead.
|
||||||
|
|
||||||
|
|
||||||
Note that only `ok` tests are normative: `err` tests test error
|
Note that only `ok` tests are normative: `err` tests test error
|
||||||
recovery and it is totally ok for a parser to not implement any error
|
recovery and it is totally ok for a parser to not implement any error
|
||||||
recovery at all. However, for libsyntax2.0 we do care about error
|
recovery at all. However, for libsyntax2.0 we do care about error
|
||||||
recovery, and we do care about precise and useful error messages.
|
recovery, and we do care about precise and useful error messages.
|
||||||
|
|
||||||
|
There are also so-called "inline tests". They appear as the comments
|
||||||
|
with a `test` header in the source code, like this:
|
||||||
|
|
||||||
|
```rust
|
||||||
|
// test fn_basic
|
||||||
|
// fn foo() {}
|
||||||
|
fn fn_item(p: &mut Parser) {
|
||||||
|
// ...
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
You can run `cargo collect-tests` command to collect all inline tests
|
||||||
|
into `tests/data/inline` directory. The main advantage of inline tests
|
||||||
|
is that they help to illustrate what the relevant code is doing.
|
||||||
|
|
||||||
|
|
||||||
Contribution opportunity: design and implement testing infrastructure
|
Contribution opportunity: design and implement testing infrastructure
|
||||||
for validators.
|
for validators.
|
||||||
|
|
Loading…
Reference in a new issue