diff options
Diffstat (limited to 'crates/tools/src/lib.rs')
-rw-r--r-- | crates/tools/src/lib.rs | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/crates/tools/src/lib.rs b/crates/tools/src/lib.rs index 95d6e08f0..66fca5bef 100644 --- a/crates/tools/src/lib.rs +++ b/crates/tools/src/lib.rs | |||
@@ -21,6 +21,7 @@ const TOOLCHAIN: &str = "1.31.0"; | |||
21 | pub struct Test { | 21 | pub struct Test { |
22 | pub name: String, | 22 | pub name: String, |
23 | pub text: String, | 23 | pub text: String, |
24 | pub ok: bool, | ||
24 | } | 25 | } |
25 | 26 | ||
26 | pub fn collect_tests(s: &str) -> Vec<(usize, Test)> { | 27 | pub fn collect_tests(s: &str) -> Vec<(usize, Test)> { |
@@ -38,11 +39,16 @@ pub fn collect_tests(s: &str) -> Vec<(usize, Test)> { | |||
38 | } | 39 | } |
39 | let mut block = block.map(|(idx, line)| (idx, &line[prefix.len()..])); | 40 | let mut block = block.map(|(idx, line)| (idx, &line[prefix.len()..])); |
40 | 41 | ||
42 | let mut ok = true; | ||
41 | let (start_line, name) = loop { | 43 | let (start_line, name) = loop { |
42 | match block.next() { | 44 | match block.next() { |
43 | Some((idx, line)) if line.starts_with("test ") => { | 45 | Some((idx, line)) if line.starts_with("test ") => { |
44 | break (idx, line["test ".len()..].to_string()); | 46 | break (idx, line["test ".len()..].to_string()); |
45 | } | 47 | } |
48 | Some((idx, line)) if line.starts_with("test_fail ") => { | ||
49 | ok = false; | ||
50 | break (idx, line["test_fail ".len()..].to_string()); | ||
51 | } | ||
46 | Some(_) => (), | 52 | Some(_) => (), |
47 | None => continue 'outer, | 53 | None => continue 'outer, |
48 | } | 54 | } |
@@ -52,7 +58,7 @@ pub fn collect_tests(s: &str) -> Vec<(usize, Test)> { | |||
52 | "\n", | 58 | "\n", |
53 | ); | 59 | ); |
54 | assert!(!text.trim().is_empty() && text.ends_with('\n')); | 60 | assert!(!text.trim().is_empty() && text.ends_with('\n')); |
55 | res.push((start_line, Test { name, text })) | 61 | res.push((start_line, Test { name, text, ok })) |
56 | } | 62 | } |
57 | res | 63 | res |
58 | } | 64 | } |