Skip to content

Commit

Permalink
Check all IDE config hashes in ./x test bootstrap, update Helix hash
Browse files Browse the repository at this point in the history
  • Loading branch information
ChaiTRex committed Feb 15, 2025
1 parent d9f125d commit 8417684
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 12 deletions.
17 changes: 14 additions & 3 deletions src/bootstrap/src/core/build_steps/setup.rs
Original file line number Diff line number Diff line change
Expand Up @@ -531,6 +531,16 @@ enum EditorKind {
}

impl EditorKind {
// Used in `./tests.rs`.
#[allow(dead_code)]
pub const ALL: &[EditorKind] = &[
EditorKind::Emacs,
EditorKind::Helix,
EditorKind::Vim,
EditorKind::VsCode,
EditorKind::Zed,
];

fn prompt_user() -> io::Result<Option<EditorKind>> {
let prompt_str = "Available editors:
1. Emacs
Expand Down Expand Up @@ -575,9 +585,10 @@ Select which editor you would like to set up [default: None]: ";
"51068d4747a13732440d1a8b8f432603badb1864fa431d83d0fd4f8fa57039e0",
"d29af4d949bbe2371eac928a3c31cf9496b1701aa1c45f11cd6c759865ad5c45",
],
EditorKind::Helix => {
&["2d3069b8cf1b977e5d4023965eb6199597755e6c96c185ed5f2854f98b83d233"]
}
EditorKind::Helix => &[
"2d3069b8cf1b977e5d4023965eb6199597755e6c96c185ed5f2854f98b83d233",
"6736d61409fbebba0933afd2e4c44ff2f97c1cb36cf0299a7f4a7819b8775040",
],
EditorKind::Vim | EditorKind::VsCode => &[
"ea67e259dedf60d4429b6c349a564ffcd1563cf41c920a856d1f5b16b4701ac8",
"56e7bf011c71c5d81e0bf42e84938111847a810eee69d906bba494ea90b51922",
Expand Down
21 changes: 12 additions & 9 deletions src/bootstrap/src/core/build_steps/setup/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,16 @@ use crate::utils::helpers::hex_encode;

#[test]
fn check_matching_settings_hash() {
let editor = EditorKind::Vscode;
let mut hasher = sha2::Sha256::new();
hasher.update(&editor.settings_template());
let hash = hex_encode(hasher.finalize().as_slice());
assert_eq!(
&hash,
editor.hashes().last().unwrap(),
"Update `EditorKind::hashes()` with the new hash of `src/etc/rust_analyzer_settings.json`"
);
for editor in EditorKind::ALL {
let mut hasher = sha2::Sha256::new();
hasher.update(&editor.settings_template());
let hash = hex_encode(hasher.finalize().as_slice());
assert_eq!(
&hash,
editor.hashes().last().unwrap(),
"Update `EditorKind::hashes()` with the new hash of `{}` for `EditorKind::{:?}`",
editor.settings_template(),
editor,
);
}
}

0 comments on commit 8417684

Please sign in to comment.