diff options
author | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2020-05-06 17:18:17 +0100 |
---|---|---|
committer | GitHub <[email protected]> | 2020-05-06 17:18:17 +0100 |
commit | b832dfc917313633e4d5484deca47b1b117140b5 (patch) | |
tree | 168b4bf3ecc2eafc1967fd94605e6821541ea359 /crates/ra_db | |
parent | fbc8bd3fdbbeed199901d6f387ab57d82aac6e04 (diff) | |
parent | 86fa80e5b3860ee2446dcf29355c314d6dc4365a (diff) |
Merge #4331
4331: Fixture improvements r=TimoFreiberg a=TimoFreiberg
As mentioned in [Zulip](https://rust-lang.zulipchat.com/#narrow/stream/185405-t-compiler.2Fwg-rls-2.2E0/topic/resolve_path.20between.20fixture.20files) :)
I think always allowing unindented first lines is friendlier than making the user fix it and I don't see any drawbacks.
Co-authored-by: Timo Freiberg <[email protected]>
Diffstat (limited to 'crates/ra_db')
-rw-r--r-- | crates/ra_db/src/fixture.rs | 46 |
1 files changed, 45 insertions, 1 deletions
diff --git a/crates/ra_db/src/fixture.rs b/crates/ra_db/src/fixture.rs index 8248684ee..51d4c493e 100644 --- a/crates/ra_db/src/fixture.rs +++ b/crates/ra_db/src/fixture.rs | |||
@@ -1,4 +1,48 @@ | |||
1 | //! FIXME: write short doc here | 1 | //! Fixtures are strings containing rust source code with optional metadata. |
2 | //! A fixture without metadata is parsed into a single source file. | ||
3 | //! Use this to test functionality local to one file. | ||
4 | //! | ||
5 | //! Example: | ||
6 | //! ``` | ||
7 | //! r#" | ||
8 | //! fn main() { | ||
9 | //! println!("Hello World") | ||
10 | //! } | ||
11 | //! "# | ||
12 | //! ``` | ||
13 | //! | ||
14 | //! Metadata can be added to a fixture after a `//-` comment. | ||
15 | //! The basic form is specifying filenames, | ||
16 | //! which is also how to define multiple files in a single test fixture | ||
17 | //! | ||
18 | //! Example: | ||
19 | //! ``` | ||
20 | //! " | ||
21 | //! //- /main.rs | ||
22 | //! mod foo; | ||
23 | //! fn main() { | ||
24 | //! foo::bar(); | ||
25 | //! } | ||
26 | //! | ||
27 | //! //- /foo.rs | ||
28 | //! pub fn bar() {} | ||
29 | //! " | ||
30 | //! ``` | ||
31 | //! | ||
32 | //! Metadata allows specifying all settings and variables | ||
33 | //! that are available in a real rust project: | ||
34 | //! - crate names via `crate:cratename` | ||
35 | //! - dependencies via `deps:dep1,dep2` | ||
36 | //! - configuration settings via `cfg:dbg=false,opt_level=2` | ||
37 | //! - environment variables via `env:PATH=/bin,RUST_LOG=debug` | ||
38 | //! | ||
39 | //! Example: | ||
40 | //! ``` | ||
41 | //! " | ||
42 | //! //- /lib.rs crate:foo deps:bar,baz cfg:foo=a,bar=b env:OUTDIR=path/to,OTHER=foo | ||
43 | //! fn insert_source_code_here() {} | ||
44 | //! " | ||
45 | //! ``` | ||
2 | 46 | ||
3 | use std::str::FromStr; | 47 | use std::str::FromStr; |
4 | use std::sync::Arc; | 48 | use std::sync::Arc; |