mirror of
https://github.com/rust-lang/rust-analyzer
synced 2025-01-27 12:25:05 +00:00
xtask: fold gen-tests and gen-ast into codegen
This commit is contained in:
parent
b5f13d8d51
commit
a669049ef3
4 changed files with 4 additions and 11 deletions
|
@ -78,7 +78,7 @@ Rust syntax tree structure and parser. See
|
||||||
Tests for ra_syntax are mostly data-driven: `test_data/parser` contains subdirectories with a bunch of `.rs`
|
Tests for ra_syntax are mostly data-driven: `test_data/parser` contains subdirectories with a bunch of `.rs`
|
||||||
(test vectors) and `.txt` files with corresponding syntax trees. During testing, we check
|
(test vectors) and `.txt` files with corresponding syntax trees. During testing, we check
|
||||||
`.rs` against `.txt`. If the `.txt` file is missing, it is created (this is how you update
|
`.rs` against `.txt`. If the `.txt` file is missing, it is created (this is how you update
|
||||||
tests). Additionally, running `cargo gen-tests` will walk the grammar module and collect
|
tests). Additionally, running `cargo xtask codegen` will walk the grammar module and collect
|
||||||
all `// test test_name` comments into files inside `test_data/parser/inline` directory.
|
all `// test test_name` comments into files inside `test_data/parser/inline` directory.
|
||||||
|
|
||||||
See [#93](https://github.com/rust-analyzer/rust-analyzer/pull/93) for an example PR which
|
See [#93](https://github.com/rust-analyzer/rust-analyzer/pull/93) for an example PR which
|
||||||
|
|
|
@ -13,7 +13,6 @@ SUBCOMMANDS:
|
||||||
format-hook
|
format-hook
|
||||||
fuzz-tests
|
fuzz-tests
|
||||||
codegen
|
codegen
|
||||||
gen-tests
|
|
||||||
install
|
install
|
||||||
lint";
|
lint";
|
||||||
|
|
||||||
|
|
|
@ -57,19 +57,13 @@ fn main() -> Result<()> {
|
||||||
};
|
};
|
||||||
install(opts)?
|
install(opts)?
|
||||||
}
|
}
|
||||||
"gen-tests" => {
|
|
||||||
if matches.contains(["-h", "--help"]) {
|
|
||||||
help::print_no_param_subcommand_help(&subcommand);
|
|
||||||
return Ok(());
|
|
||||||
}
|
|
||||||
codegen::generate_parser_tests(Mode::Overwrite)?
|
|
||||||
}
|
|
||||||
"codegen" => {
|
"codegen" => {
|
||||||
if matches.contains(["-h", "--help"]) {
|
if matches.contains(["-h", "--help"]) {
|
||||||
help::print_no_param_subcommand_help(&subcommand);
|
help::print_no_param_subcommand_help(&subcommand);
|
||||||
return Ok(());
|
return Ok(());
|
||||||
}
|
}
|
||||||
codegen::generate_syntax(Mode::Overwrite)?
|
codegen::generate_syntax(Mode::Overwrite)?;
|
||||||
|
codegen::generate_parser_tests(Mode::Overwrite)?;
|
||||||
}
|
}
|
||||||
"format" => {
|
"format" => {
|
||||||
if matches.contains(["-h", "--help"]) {
|
if matches.contains(["-h", "--help"]) {
|
||||||
|
|
|
@ -14,7 +14,7 @@ fn generated_grammar_is_fresh() {
|
||||||
#[test]
|
#[test]
|
||||||
fn generated_tests_are_fresh() {
|
fn generated_tests_are_fresh() {
|
||||||
if let Err(error) = codegen::generate_parser_tests(Mode::Verify) {
|
if let Err(error) = codegen::generate_parser_tests(Mode::Verify) {
|
||||||
panic!("{}. Please update tests by running `cargo xtask gen-tests`", error);
|
panic!("{}. Please update tests by running `cargo xtask codegen`", error);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue