aboutsummaryrefslogtreecommitdiff
path: root/crates/tools/src/lib.rs
diff options
context:
space:
mode:
Diffstat (limited to 'crates/tools/src/lib.rs')
-rw-r--r--crates/tools/src/lib.rs10
1 files changed, 8 insertions, 2 deletions
diff --git a/crates/tools/src/lib.rs b/crates/tools/src/lib.rs
index 95d6e08f0..2795afe0b 100644
--- a/crates/tools/src/lib.rs
+++ b/crates/tools/src/lib.rs
@@ -15,12 +15,13 @@ pub type Result<T> = std::result::Result<T, failure::Error>;
15pub const GRAMMAR: &str = "crates/ra_syntax/src/grammar.ron"; 15pub const GRAMMAR: &str = "crates/ra_syntax/src/grammar.ron";
16pub const SYNTAX_KINDS: &str = "crates/ra_syntax/src/syntax_kinds/generated.rs.tera"; 16pub const SYNTAX_KINDS: &str = "crates/ra_syntax/src/syntax_kinds/generated.rs.tera";
17pub const AST: &str = "crates/ra_syntax/src/ast/generated.rs.tera"; 17pub const AST: &str = "crates/ra_syntax/src/ast/generated.rs.tera";
18const TOOLCHAIN: &str = "1.31.0"; 18const TOOLCHAIN: &str = "1.31.1";
19 19
20#[derive(Debug)] 20#[derive(Debug)]
21pub struct Test { 21pub 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
26pub fn collect_tests(s: &str) -> Vec<(usize, Test)> { 27pub 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_err ") => {
49 ok = false;
50 break (idx, line["test_err ".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}