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.

ci: Speed it up (#56440)

Piotr Osiewicz6d2b391a3be7
diff --git a/crates/client/src/telemetry.rs b/crates/client/src/telemetry.rs
index 58681d2e14b..b68de9442ee 100644
--- a/crates/client/src/telemetry.rs
+++ b/crates/client/src/telemetry.rs
@@ -99,10 +99,6 @@ static DOTNET_PROJECT_FILES_REGEX: LazyLock<Regex> = LazyLock::new(|| {
Regex::new(r"^(global\.json|Directory\.Build\.props|.*\.(csproj|fsproj|vbproj|sln))$").unwrap()
});
-#[cfg(target_os = "macos")]
-static MACOS_VERSION_REGEX: LazyLock<Regex> =
- LazyLock::new(|| Regex::new(r"(\s*\(Build [^)]*[0-9]\))").unwrap());
-
pub fn os_name() -> String {
#[cfg(target_os = "macos")]
{
@@ -125,63 +121,72 @@ pub fn os_name() -> String {
/// Note: This might do blocking IO! Only call from background threads
pub fn os_version() -> String {
- #[cfg(target_os = "macos")]
- {
- use objc2_foundation::NSProcessInfo;
- let process_info = NSProcessInfo::processInfo();
- let version_nsstring = process_info.operatingSystemVersionString();
- // "Version 15.6.1 (Build 24G90)" -> "15.6.1 (Build 24G90)"
- let version_string = version_nsstring.to_string().replace("Version ", "");
- // "15.6.1 (Build 24G90)" -> "15.6.1"
- // "26.0.0 (Build 25A5349a)" -> unchanged (Beta or Rapid Security Response; ends with letter)
- MACOS_VERSION_REGEX
- .replace_all(&version_string, "")
- .to_string()
- }
- #[cfg(any(target_os = "linux", target_os = "freebsd"))]
- {
- use std::path::Path;
-
- let content = if let Ok(file) = std::fs::read_to_string(&Path::new("/etc/os-release")) {
- file
- } else if let Ok(file) = std::fs::read_to_string(&Path::new("/usr/lib/os-release")) {
- file
- } else if let Ok(file) = std::fs::read_to_string(&Path::new("/var/run/os-release")) {
- file
- } else {
- log::error!(
- "Failed to load /etc/os-release, /usr/lib/os-release, or /var/run/os-release"
- );
- "".to_string()
- };
- let mut name = "unknown";
- let mut version = "unknown";
-
- for line in content.lines() {
- match line.split_once('=') {
- Some(("ID", val)) => name = val.trim_matches('"'),
- Some(("VERSION_ID", val)) => version = val.trim_matches('"'),
- _ => {}
- }
- }
-
- format!("{} {}", name, version)
- }
-
- #[cfg(target_os = "windows")]
- {
- let mut info = unsafe { std::mem::zeroed() };
- let status = unsafe { windows::Wdk::System::SystemServices::RtlGetVersion(&mut info) };
- if status.is_ok() {
- semver::Version::new(
- info.dwMajorVersion as _,
- info.dwMinorVersion as _,
- info.dwBuildNumber as _,
- )
- .to_string()
- } else {
- "unknown".to_string()
- }
+ cfg_select! {
+ feature = "test-support" => {
+ // MacOS branch in particular is quite slow, hence we ought to "avoid" it in tests.
+ "test binary".to_owned()
+ }
+ target_os = "macos" => {
+ #[cfg(target_os = "macos")]
+ static MACOS_VERSION_REGEX: LazyLock<Regex> = LazyLock::new(|| {
+ let regex_compilation = std::time::Instant::now();
+ let r = Regex::new(r"(\s*\(Build [^)]*[0-9]\))").unwrap();
+ dbg!(regex_compilation.elapsed());
+ r
+ });
+ use objc2_foundation::NSProcessInfo;
+ let process_info = NSProcessInfo::processInfo();
+ let version_nsstring = process_info.operatingSystemVersionString();
+ // "Version 15.6.1 (Build 24G90)" -> "15.6.1 (Build 24G90)"
+ let version_string = version_nsstring.to_string().replace("Version ", "");
+ // "15.6.1 (Build 24G90)" -> "15.6.1"
+ // "26.0.0 (Build 25A5349a)" -> unchanged (Beta or Rapid Security Response; ends with letter)
+ MACOS_VERSION_REGEX
+ .replace_all(&version_string, "")
+ .to_string()
+ }
+ any(target_os = "linux", target_os = "freebsd") => {
+ use std::path::Path;
+
+ let content = if let Ok(file) = std::fs::read_to_string(&Path::new("/etc/os-release")) {
+ file
+ } else if let Ok(file) = std::fs::read_to_string(&Path::new("/usr/lib/os-release")) {
+ file
+ } else if let Ok(file) = std::fs::read_to_string(&Path::new("/var/run/os-release")) {
+ file
+ } else {
+ log::error!(
+ "Failed to load /etc/os-release, /usr/lib/os-release, or /var/run/os-release"
+ );
+ "".to_string()
+ };
+ let mut name = "unknown";
+ let mut version = "unknown";
+
+ for line in content.lines() {
+ match line.split_once('=') {
+ Some(("ID", val)) => name = val.trim_matches('"'),
+ Some(("VERSION_ID", val)) => version = val.trim_matches('"'),
+ _ => {}
+ }
+ }
+
+ format!("{} {}", name, version)
+ }
+ target_os = "windows" => {
+ let mut info = unsafe { std::mem::zeroed() };
+ let status = unsafe { windows::Wdk::System::SystemServices::RtlGetVersion(&mut info) };
+ if status.is_ok() {
+ semver::Version::new(
+ info.dwMajorVersion as _,
+ info.dwMinorVersion as _,
+ info.dwBuildNumber as _,
+ )
+ .to_string()
+ } else {
+ "unknown".to_string()
+ }
+ }
}
}
diff --git a/crates/zed/src/zed/visual_tests.rs b/crates/zed/src/zed/visual_tests.rs
index 610621f480f..80e37a37989 100644
--- a/crates/zed/src/zed/visual_tests.rs
+++ b/crates/zed/src/zed/visual_tests.rs
@@ -82,7 +82,6 @@ pub async fn open_test_workspace(
cx: &mut VisualTestAppContext,
) -> Result<WindowHandle<workspace::Workspace>> {
let window_size = size(px(1280.0), px(800.0));
-
let project = cx.update(|cx| {
project::Project::local(
app_state.client.clone(),