rustdoc: add the ability to run tests with --test.

This adds the `test_harness` directive that runs a code block using the
test runner, to allow for `#[test]` items to be demonstrated and still
tested (currently they are just stripped and not even compiled, let
alone run).
This commit is contained in:
Huon Wilson 2014-06-19 23:11:18 +10:00
parent a17b0421d3
commit 11bdeea767
3 changed files with 43 additions and 19 deletions

View file

@ -171,6 +171,18 @@ You can specify that the code block should be compiled but not run with the
```
~~~
Lastly, you can specify that a code block be compiled as if `--test`
were passed to the compiler using the `test_harness` directive.
~~~md
```test_harness
#[test]
fn foo() {
fail!("oops! (will run & register as failure)")
}
```
~~~
Rustdoc also supplies some extra sugar for helping with some tedious
documentation examples. If a line is prefixed with `# `, then the line
will not show up in the HTML documentation, but it will be used when