66# Summary
77[ summary ] : #summary
88
9- Allow giving documentation tests names for identification in test runner
10- output by including ` name=NAME ` in doctest code block info strings.
9+ Allow giving documentation tests names for identification in test runner output
10+ by including ` name=IDENT ` in doctest code block info strings.
1111
1212# Motivation
1313[ motivation ] : #motivation
@@ -24,8 +24,8 @@ specific tests using `cargo test --doc -- $TEST_NAME`.
2424# Guide-level explanation
2525[ guide-level-explanation ] : #guide-level-explanation
2626
27- Doctests are written as fenced markdown code blocks that start and end
28- with lines containing three backticks.
27+ Doctests are written as fenced markdown code blocks that start and end with
28+ lines containing three backticks.
2929
3030The first set of backticks may be followed by an info string. For example, to
3131tell the Rust compiler to ignore the doctest:
@@ -52,8 +52,9 @@ test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out
5252```
5353
5454If you'd like to have the test runner print a more informative name, perhaps
55- because there are many doctests in a single file, you can put ` name=NAME ` ,
56- where ` NAME ` is the name the test should have, in the doctest's info string.
55+ because there are many doctests in a single file, you can put ` name=IDENT ` ,
56+ where ` IDENT ` is the name the test should have, which must be an identifier, in
57+ the doctest's info string.
5758
5859
5960```` rust
@@ -77,18 +78,18 @@ test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out
7778[ reference-level-explanation ] : #reference-level-explanation
7879
7980The set of valid words that may appear in code block info strings is extended
80- to include patterns of the form ` name=NAME ` .
81+ to include patterns of the form ` name=IDENT ` .
8182
82- This ` NAME ` will be the name of the documentation test generated by the code
83- block.
83+ This ` IDENT ` will be the name of the documentation test generated by the code
84+ block, and must be a valid Rust identifier .
8485
8586When the test runner runs the documentation test, the test will be identified
8687by this name, in addition to the test binary, module, and line number.
8788
88- Multiple ` name=NAME ` words may not appear in a single code block's info
89+ Multiple ` name=IDENT ` words may not appear in a single code block's info
8990string.
9091
91- ` name=NAME ` may be combined with existing annotations like ` rust ` or
92+ ` name=IDENT ` may be combined with existing annotations like ` rust ` or
9293` should_panic ` by separating the annotations with commas:
9394
9495````
@@ -116,13 +117,6 @@ feature.
116117This design seems like the simplest design possible, although viable
117118alternatives may have been overlooked.
118119
119- A previous version of this RFC included the additional restrictions that labels
120- must be valid rust identifiers, and that labels must be unique within the same
121- module. These restrictions were intended to allow the machinery that generates
122- doctest tests to use the labels as the generated doctest function names. If
123- this simplifies or improves the generated doctest functions, these restrictions
124- might be desirable.
125-
126120The impact of adopting this RFC is minimal. Doctests test output will remain a
127121little hard to make sense of.
128122
0 commit comments