diff options
author | Hannes De Valkeneer <[email protected]> | 2020-04-22 21:52:12 +0100 |
---|---|---|
committer | Hannes De Valkeneer <[email protected]> | 2020-04-22 22:54:09 +0100 |
commit | 380a2870c73be5c03512b5711988d760cd21cca6 (patch) | |
tree | 44a770af38fca7488a35756487dce9025c9fdf8e /crates/ra_ide/src | |
parent | 3f1f3a835a07983344f6f3becf7a0c32b96d68bc (diff) |
feat: run ignored tests
Diffstat (limited to 'crates/ra_ide/src')
-rw-r--r-- | crates/ra_ide/src/runnables.rs | 35 |
1 files changed, 33 insertions, 2 deletions
diff --git a/crates/ra_ide/src/runnables.rs b/crates/ra_ide/src/runnables.rs index 9433f3a24..05a66e03c 100644 --- a/crates/ra_ide/src/runnables.rs +++ b/crates/ra_ide/src/runnables.rs | |||
@@ -34,7 +34,7 @@ impl Display for TestId { | |||
34 | 34 | ||
35 | #[derive(Debug)] | 35 | #[derive(Debug)] |
36 | pub enum RunnableKind { | 36 | pub enum RunnableKind { |
37 | Test { test_id: TestId }, | 37 | Test { test_id: TestId, attr: TestAttr }, |
38 | TestMod { path: String }, | 38 | TestMod { path: String }, |
39 | Bench { test_id: TestId }, | 39 | Bench { test_id: TestId }, |
40 | Bin, | 40 | Bin, |
@@ -77,7 +77,8 @@ fn runnable_fn(sema: &Semantics<RootDatabase>, fn_def: ast::FnDef) -> Option<Run | |||
77 | }; | 77 | }; |
78 | 78 | ||
79 | if has_test_related_attribute(&fn_def) { | 79 | if has_test_related_attribute(&fn_def) { |
80 | RunnableKind::Test { test_id } | 80 | let attr = TestAttr::from_fn(&fn_def); |
81 | RunnableKind::Test { test_id, attr } | ||
81 | } else if fn_def.has_atom_attr("bench") { | 82 | } else if fn_def.has_atom_attr("bench") { |
82 | RunnableKind::Bench { test_id } | 83 | RunnableKind::Bench { test_id } |
83 | } else { | 84 | } else { |
@@ -87,6 +88,21 @@ fn runnable_fn(sema: &Semantics<RootDatabase>, fn_def: ast::FnDef) -> Option<Run | |||
87 | Some(Runnable { range: fn_def.syntax().text_range(), kind }) | 88 | Some(Runnable { range: fn_def.syntax().text_range(), kind }) |
88 | } | 89 | } |
89 | 90 | ||
91 | #[derive(Debug)] | ||
92 | pub struct TestAttr { | ||
93 | pub ignore: bool, | ||
94 | } | ||
95 | |||
96 | impl TestAttr { | ||
97 | fn from_fn(fn_def: &ast::FnDef) -> TestAttr { | ||
98 | let ignore = fn_def | ||
99 | .attrs() | ||
100 | .filter_map(|attr| attr.simple_name()) | ||
101 | .any(|attribute_text| attribute_text == "ignore"); | ||
102 | TestAttr { ignore } | ||
103 | } | ||
104 | } | ||
105 | |||
90 | /// This is a method with a heuristics to support test methods annotated with custom test annotations, such as | 106 | /// This is a method with a heuristics to support test methods annotated with custom test annotations, such as |
91 | /// `#[test_case(...)]`, `#[tokio::test]` and similar. | 107 | /// `#[test_case(...)]`, `#[tokio::test]` and similar. |
92 | /// Also a regular `#[test]` annotation is supported. | 108 | /// Also a regular `#[test]` annotation is supported. |
@@ -157,6 +173,9 @@ mod tests { | |||
157 | test_id: Path( | 173 | test_id: Path( |
158 | "test_foo", | 174 | "test_foo", |
159 | ), | 175 | ), |
176 | attr: TestAttr { | ||
177 | ignore: false, | ||
178 | }, | ||
160 | }, | 179 | }, |
161 | }, | 180 | }, |
162 | Runnable { | 181 | Runnable { |
@@ -165,6 +184,9 @@ mod tests { | |||
165 | test_id: Path( | 184 | test_id: Path( |
166 | "test_foo", | 185 | "test_foo", |
167 | ), | 186 | ), |
187 | attr: TestAttr { | ||
188 | ignore: true, | ||
189 | }, | ||
168 | }, | 190 | }, |
169 | }, | 191 | }, |
170 | ] | 192 | ] |
@@ -200,6 +222,9 @@ mod tests { | |||
200 | test_id: Path( | 222 | test_id: Path( |
201 | "test_mod::test_foo1", | 223 | "test_mod::test_foo1", |
202 | ), | 224 | ), |
225 | attr: TestAttr { | ||
226 | ignore: false, | ||
227 | }, | ||
203 | }, | 228 | }, |
204 | }, | 229 | }, |
205 | ] | 230 | ] |
@@ -237,6 +262,9 @@ mod tests { | |||
237 | test_id: Path( | 262 | test_id: Path( |
238 | "foo::test_mod::test_foo1", | 263 | "foo::test_mod::test_foo1", |
239 | ), | 264 | ), |
265 | attr: TestAttr { | ||
266 | ignore: false, | ||
267 | }, | ||
240 | }, | 268 | }, |
241 | }, | 269 | }, |
242 | ] | 270 | ] |
@@ -276,6 +304,9 @@ mod tests { | |||
276 | test_id: Path( | 304 | test_id: Path( |
277 | "foo::bar::test_mod::test_foo1", | 305 | "foo::bar::test_mod::test_foo1", |
278 | ), | 306 | ), |
307 | attr: TestAttr { | ||
308 | ignore: false, | ||
309 | }, | ||
279 | }, | 310 | }, |
280 | }, | 311 | }, |
281 | ] | 312 | ] |