Skip to content

armgit / zed

Public Imported from GitHub
0

Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.

icons: Add test to ensure all icon variants exist (#61337)

Finn Eversf3f6a8345484
diff --git a/assets/icons/supermaven.svg b/assets/icons/supermaven.svg
deleted file mode 100644
index af778c70b71..00000000000
--- a/assets/icons/supermaven.svg
+++ /dev/null
@@ -1,8 +0,0 @@
-<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
-<path d="M3.78125 14.9375C4.35078 14.9375 4.8125 14.4758 4.8125 13.9063C4.8125 13.3367 4.35078 12.875 3.78125 12.875C3.21171 12.875 2.75 13.3367 2.75 13.9063C2.75 14.4758 3.21171 14.9375 3.78125 14.9375Z" fill="black"/>
-<path fill-rule="evenodd" clip-rule="evenodd" d="M7.46876 9.18684L4.69485 14.4063L2.875 13.4382L5.64891 8.21875L7.46876 9.18684Z" fill="black"/>
-<path fill-rule="evenodd" clip-rule="evenodd" d="M8.43749 2.99935L5.64475 8.21876L3.8125 7.25066L6.60524 2.03125L8.43749 2.99935Z" fill="black"/>
-<path d="M7.5 3.53124C8.06953 3.53124 8.53124 3.06954 8.53124 2.5C8.53124 1.93045 8.06953 1.46875 7.5 1.46875C6.93046 1.46875 6.46875 1.93045 6.46875 2.5C6.46875 3.06954 6.93046 3.53124 7.5 3.53124Z" fill="black"/>
-<path fill-rule="evenodd" clip-rule="evenodd" d="M12.4366 1.49947C12.8962 1.61399 13.2187 2.02651 13.2187 2.49985V13.9063H11.1552V6.63497L9.29072 10.1392L7.46875 9.1711L11.276 2.01583C11.4984 1.5979 11.977 1.38496 12.4366 1.49947Z" fill="black"/>
-<path d="M12.1875 14.9375C12.757 14.9375 13.2187 14.4758 13.2187 13.9063C13.2187 13.3367 12.757 12.875 12.1875 12.875C11.6179 12.875 11.1562 13.3367 11.1562 13.9063C11.1562 14.4758 11.6179 14.9375 12.1875 14.9375Z" fill="black"/>
-</svg>
diff --git a/crates/icons/src/icons.rs b/crates/icons/src/icons.rs
index 6a94f8c7b46..d1005517d77 100644
--- a/crates/icons/src/icons.rs
+++ b/crates/icons/src/icons.rs
@@ -309,3 +309,45 @@ impl IconName {
format!("icons/{file_stem}.svg").into()
}
}
+
+#[cfg(test)]
+mod tests {
+ use std::path::PathBuf;
+
+ use strum::{IntoEnumIterator as _, ParseError};
+
+ use crate::IconName;
+
+ #[test]
+ fn test_all_icons_exist() {
+ let asset_path = PathBuf::from(env!("CARGO_MANIFEST_DIR")).join("../../assets");
+
+ for icon in IconName::iter() {
+ let icon_path = asset_path.join(&*icon.path());
+ assert!(
+ icon_path.exists(),
+ "Icon {icon:?} does not exist at {icon_path:?}",
+ );
+ }
+ }
+
+ #[test]
+ fn test_no_dangling_icons() -> Result<(), ParseError> {
+ let icons_dir = PathBuf::from(env!("CARGO_MANIFEST_DIR")).join("../../assets/icons");
+
+ for entry in std::fs::read_dir(&icons_dir).expect("failed to read icons directory") {
+ let path = entry.expect("failed to read icons directory entry").path();
+ if path.extension().is_none_or(|extension| extension != "svg") {
+ continue;
+ }
+ let file_stem = path
+ .file_stem()
+ .and_then(|file_stem| file_stem.to_str())
+ .expect("icon file name is not valid UTF-8");
+
+ file_stem.parse::<IconName>()?;
+ }
+
+ Ok(())
+ }
+}