mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-10-01 06:11:35 +00:00
Generalize file ensuring infrastructure
This commit is contained in:
parent
0f6f458cc1
commit
b6ba0dec0c
2 changed files with 38 additions and 6 deletions
|
@ -859,12 +859,12 @@ fn manual(fields: &[(&'static str, &'static str, &[&str], &str)]) -> String {
|
|||
mod tests {
|
||||
use std::fs;
|
||||
|
||||
use test_utils::project_dir;
|
||||
use test_utils::{ensure_file_contents, project_dir};
|
||||
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn schema_in_sync_with_package_json() {
|
||||
fn ensure_schema_in_package_json() {
|
||||
let s = Config::json_schema();
|
||||
let schema = format!("{:#}", s);
|
||||
let mut schema = schema
|
||||
|
@ -885,13 +885,12 @@ mod tests {
|
|||
|
||||
let start = package_json.find(start_marker).unwrap() + start_marker.len();
|
||||
let end = package_json.find(end_marker).unwrap();
|
||||
|
||||
let p = remove_ws(&package_json[start..end]);
|
||||
let s = remove_ws(&schema);
|
||||
|
||||
if !p.contains(&s) {
|
||||
package_json.replace_range(start..end, &schema);
|
||||
fs::write(&package_json_path, &mut package_json).unwrap();
|
||||
panic!("new config, updating package.json")
|
||||
ensure_file_contents(&package_json_path, &package_json)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue