Unnamed repository; edit this file 'description' to name the repository.
Diffstat (limited to 'crates/test-utils/src/fixture.rs')
-rw-r--r--crates/test-utils/src/fixture.rs24
1 files changed, 11 insertions, 13 deletions
diff --git a/crates/test-utils/src/fixture.rs b/crates/test-utils/src/fixture.rs
index 7fe26d53bf..7240069753 100644
--- a/crates/test-utils/src/fixture.rs
+++ b/crates/test-utils/src/fixture.rs
@@ -6,7 +6,8 @@
//! Use this to test functionality local to one file.
//!
//! Simple Example:
-//! ```
+//!
+//! ```ignore
//! r#"
//! fn main() {
//! println!("Hello World")
@@ -19,7 +20,8 @@
//! which is also how to define multiple files in a single test fixture
//!
//! Example using two files in the same crate:
-//! ```
+//!
+//! ```ignore
//! "
//! //- /main.rs
//! mod foo;
@@ -33,7 +35,8 @@
//! ```
//!
//! Example using two crates with one file each, with one crate depending on the other:
-//! ```
+//!
+//! ```ignore
//! r#"
//! //- /main.rs crate:a deps:b
//! fn main() {
@@ -51,7 +54,8 @@
//! for the syntax.
//!
//! Example using some available metadata:
-//! ```
+//!
+//! ```ignore
//! "
//! //- /lib.rs crate:foo deps:bar,baz cfg:foo=a,bar=b env:OUTDIR=path/to,OTHER=foo
//! fn insert_source_code_here() {}
@@ -214,16 +218,11 @@ impl FixtureWithProjectMeta {
);
}
- if line.starts_with("//-") {
+ if let Some(line) = line.strip_prefix("//-") {
let meta = Self::parse_meta_line(line);
res.push(meta);
} else {
- if line.starts_with("// ")
- && line.contains(':')
- && !line.contains("::")
- && !line.contains('.')
- && line.chars().all(|it| !it.is_uppercase())
- {
+ if matches!(line.strip_prefix("// "), Some(l) if l.trim().starts_with('/')) {
panic!("looks like invalid metadata line: {line:?}");
}
@@ -238,8 +237,7 @@ impl FixtureWithProjectMeta {
//- /lib.rs crate:foo deps:bar,baz cfg:foo=a,bar=b env:OUTDIR=path/to,OTHER=foo
fn parse_meta_line(meta: &str) -> Fixture {
- assert!(meta.starts_with("//-"));
- let meta = meta["//-".len()..].trim();
+ let meta = meta.trim();
let mut components = meta.split_ascii_whitespace();
let path = components.next().expect("fixture meta must start with a path").to_owned();