From 1eb61203b725684fd2c7e25ac7e2d53eef10c64c Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Mon, 8 Mar 2021 21:13:15 +0300 Subject: Make `code generation` just work Contributors don't need to learn about `cargo xtask codegen` if `cargo test` just does the right thing. --- crates/rust-analyzer/src/config.rs | 4 ++-- crates/test_utils/src/lib.rs | 5 ++++- 2 files changed, 6 insertions(+), 3 deletions(-) (limited to 'crates') diff --git a/crates/rust-analyzer/src/config.rs b/crates/rust-analyzer/src/config.rs index bceca2b0f..078c83f75 100644 --- a/crates/rust-analyzer/src/config.rs +++ b/crates/rust-analyzer/src/config.rs @@ -864,7 +864,7 @@ mod tests { use super::*; #[test] - fn ensure_schema_in_package_json() { + fn generate_package_json_config() { let s = Config::json_schema(); let schema = format!("{:#}", s); let mut schema = schema @@ -895,7 +895,7 @@ mod tests { } #[test] - fn schema_in_sync_with_docs() { + fn generate_config_documentation() { let docs_path = project_root().join("docs/user/generated_config.adoc"); let current = fs::read_to_string(&docs_path).unwrap(); let expected = ConfigData::manual(); diff --git a/crates/test_utils/src/lib.rs b/crates/test_utils/src/lib.rs index 097a54139..dd582c77c 100644 --- a/crates/test_utils/src/lib.rs +++ b/crates/test_utils/src/lib.rs @@ -18,7 +18,7 @@ use std::{ }; use profile::StopWatch; -use stdx::lines_with_ends; +use stdx::{is_ci, lines_with_ends}; use text_size::{TextRange, TextSize}; pub use dissimilar::diff as __diff; @@ -376,6 +376,9 @@ pub fn try_ensure_file_contents(file: &Path, contents: &str) -> Result<(), ()> { "\n\x1b[31;1merror\x1b[0m: {} was not up-to-date, updating\n", display_path.display() ); + if is_ci() { + eprintln!("\n NOTE: run `cargo test` locally and commit the updated files\n"); + } if let Some(parent) = file.parent() { let _ = std::fs::create_dir_all(parent); } -- cgit v1.2.3