diff options
Diffstat (limited to 'xtask')
-rw-r--r-- | xtask/src/codegen.rs | 2 | ||||
-rw-r--r-- | xtask/src/codegen/gen_assists_docs.rs | 4 | ||||
-rw-r--r-- | xtask/tests/tidy-tests/cli.rs | 32 | ||||
-rw-r--r-- | xtask/tests/tidy.rs (renamed from xtask/tests/tidy-tests/main.rs) | 39 |
4 files changed, 37 insertions, 40 deletions
diff --git a/xtask/src/codegen.rs b/xtask/src/codegen.rs index 0e4dcb95a..b4907f4b2 100644 --- a/xtask/src/codegen.rs +++ b/xtask/src/codegen.rs | |||
@@ -27,7 +27,7 @@ const AST_NODES: &str = "crates/ra_syntax/src/ast/generated/nodes.rs"; | |||
27 | const AST_TOKENS: &str = "crates/ra_syntax/src/ast/generated/tokens.rs"; | 27 | const AST_TOKENS: &str = "crates/ra_syntax/src/ast/generated/tokens.rs"; |
28 | 28 | ||
29 | const ASSISTS_DIR: &str = "crates/ra_assists/src/handlers"; | 29 | const ASSISTS_DIR: &str = "crates/ra_assists/src/handlers"; |
30 | const ASSISTS_TESTS: &str = "crates/ra_assists/src/doc_tests/generated.rs"; | 30 | const ASSISTS_TESTS: &str = "crates/ra_assists/src/tests/generated.rs"; |
31 | const ASSISTS_DOCS: &str = "docs/user/assists.md"; | 31 | const ASSISTS_DOCS: &str = "docs/user/assists.md"; |
32 | 32 | ||
33 | #[derive(Debug, PartialEq, Eq, Clone, Copy)] | 33 | #[derive(Debug, PartialEq, Eq, Clone, Copy)] |
diff --git a/xtask/src/codegen/gen_assists_docs.rs b/xtask/src/codegen/gen_assists_docs.rs index 31d606535..4bd6b5f0c 100644 --- a/xtask/src/codegen/gen_assists_docs.rs +++ b/xtask/src/codegen/gen_assists_docs.rs | |||
@@ -101,14 +101,14 @@ fn collect_assists() -> Result<Vec<Assist>> { | |||
101 | } | 101 | } |
102 | 102 | ||
103 | fn generate_tests(assists: &[Assist], mode: Mode) -> Result<()> { | 103 | fn generate_tests(assists: &[Assist], mode: Mode) -> Result<()> { |
104 | let mut buf = String::from("use super::check;\n"); | 104 | let mut buf = String::from("use super::check_doc_test;\n"); |
105 | 105 | ||
106 | for assist in assists.iter() { | 106 | for assist in assists.iter() { |
107 | let test = format!( | 107 | let test = format!( |
108 | r######" | 108 | r######" |
109 | #[test] | 109 | #[test] |
110 | fn doctest_{}() {{ | 110 | fn doctest_{}() {{ |
111 | check( | 111 | check_doc_test( |
112 | "{}", | 112 | "{}", |
113 | r#####" | 113 | r#####" |
114 | {}"#####, r#####" | 114 | {}"#####, r#####" |
diff --git a/xtask/tests/tidy-tests/cli.rs b/xtask/tests/tidy-tests/cli.rs deleted file mode 100644 index f5b00a8b8..000000000 --- a/xtask/tests/tidy-tests/cli.rs +++ /dev/null | |||
@@ -1,32 +0,0 @@ | |||
1 | use xtask::{ | ||
2 | codegen::{self, Mode}, | ||
3 | run_rustfmt, | ||
4 | }; | ||
5 | |||
6 | #[test] | ||
7 | fn generated_grammar_is_fresh() { | ||
8 | if let Err(error) = codegen::generate_syntax(Mode::Verify) { | ||
9 | panic!("{}. Please update it by running `cargo xtask codegen`", error); | ||
10 | } | ||
11 | } | ||
12 | |||
13 | #[test] | ||
14 | fn generated_tests_are_fresh() { | ||
15 | if let Err(error) = codegen::generate_parser_tests(Mode::Verify) { | ||
16 | panic!("{}. Please update tests by running `cargo xtask codegen`", error); | ||
17 | } | ||
18 | } | ||
19 | |||
20 | #[test] | ||
21 | fn generated_assists_are_fresh() { | ||
22 | if let Err(error) = codegen::generate_assists_docs(Mode::Verify) { | ||
23 | panic!("{}. Please update assists by running `cargo xtask codegen`", error); | ||
24 | } | ||
25 | } | ||
26 | |||
27 | #[test] | ||
28 | fn check_code_formatting() { | ||
29 | if let Err(error) = run_rustfmt(Mode::Verify) { | ||
30 | panic!("{}. Please format the code by running `cargo format`", error); | ||
31 | } | ||
32 | } | ||
diff --git a/xtask/tests/tidy-tests/main.rs b/xtask/tests/tidy.rs index 3213c4dfa..b8e8860ba 100644 --- a/xtask/tests/tidy-tests/main.rs +++ b/xtask/tests/tidy.rs | |||
@@ -1,11 +1,41 @@ | |||
1 | mod cli; | ||
2 | |||
3 | use std::{ | 1 | use std::{ |
4 | collections::HashMap, | 2 | collections::HashMap, |
5 | path::{Path, PathBuf}, | 3 | path::{Path, PathBuf}, |
6 | }; | 4 | }; |
7 | 5 | ||
8 | use xtask::{not_bash::fs2, project_root, rust_files}; | 6 | use xtask::{ |
7 | codegen::{self, Mode}, | ||
8 | not_bash::fs2, | ||
9 | project_root, run_rustfmt, rust_files, | ||
10 | }; | ||
11 | |||
12 | #[test] | ||
13 | fn generated_grammar_is_fresh() { | ||
14 | if let Err(error) = codegen::generate_syntax(Mode::Verify) { | ||
15 | panic!("{}. Please update it by running `cargo xtask codegen`", error); | ||
16 | } | ||
17 | } | ||
18 | |||
19 | #[test] | ||
20 | fn generated_tests_are_fresh() { | ||
21 | if let Err(error) = codegen::generate_parser_tests(Mode::Verify) { | ||
22 | panic!("{}. Please update tests by running `cargo xtask codegen`", error); | ||
23 | } | ||
24 | } | ||
25 | |||
26 | #[test] | ||
27 | fn generated_assists_are_fresh() { | ||
28 | if let Err(error) = codegen::generate_assists_docs(Mode::Verify) { | ||
29 | panic!("{}. Please update assists by running `cargo xtask codegen`", error); | ||
30 | } | ||
31 | } | ||
32 | |||
33 | #[test] | ||
34 | fn check_code_formatting() { | ||
35 | if let Err(error) = run_rustfmt(Mode::Verify) { | ||
36 | panic!("{}. Please format the code by running `cargo format`", error); | ||
37 | } | ||
38 | } | ||
9 | 39 | ||
10 | #[test] | 40 | #[test] |
11 | fn rust_files_are_tidy() { | 41 | fn rust_files_are_tidy() { |
@@ -24,7 +54,7 @@ fn check_todo(path: &Path, text: &str) { | |||
24 | // This file itself is whitelisted since this test itself contains matches. | 54 | // This file itself is whitelisted since this test itself contains matches. |
25 | "tests/cli.rs", | 55 | "tests/cli.rs", |
26 | // Some of our assists generate `todo!()` so those files are whitelisted. | 56 | // Some of our assists generate `todo!()` so those files are whitelisted. |
27 | "doc_tests/generated.rs", | 57 | "tests/generated.rs", |
28 | "handlers/add_missing_impl_members.rs", | 58 | "handlers/add_missing_impl_members.rs", |
29 | "handlers/add_function.rs", | 59 | "handlers/add_function.rs", |
30 | // To support generating `todo!()` in assists, we have `expr_todo()` in ast::make. | 60 | // To support generating `todo!()` in assists, we have `expr_todo()` in ast::make. |
@@ -106,7 +136,6 @@ impl TidyDocs { | |||
106 | } | 136 | } |
107 | 137 | ||
108 | let whitelist = [ | 138 | let whitelist = [ |
109 | "ra_db", | ||
110 | "ra_hir", | 139 | "ra_hir", |
111 | "ra_hir_expand", | 140 | "ra_hir_expand", |
112 | "ra_ide", | 141 | "ra_ide", |