Repository: GuillaumeGomez/sysinfo (language: rust)

Issue:
Should `exe` be included in default process retrieval (and removed from `ProcessRefreshKind`)?
It seems to be a basic information that everyone might want all the time.


Discussion / hints:
Another solution would be to just remove `refresh_process[es]`.

Fix patch:
diff --git a/src/common.rs b/src/common.rs
index 003dc972d..d7e6ffd6d 100644
--- a/src/common.rs
+++ b/src/common.rs
@@ -221,13 +221,14 @@ impl System {
     /// It does the same as:
     ///
     /// ```no_run
-    /// # use sysinfo::{ProcessRefreshKind, System};
+    /// # use sysinfo::{ProcessRefreshKind, System, UpdateKind};
     /// # let mut system = System::new();
     /// system.refresh_processes_specifics(
     ///     ProcessRefreshKind::new()
     ///         .with_memory()
     ///         .with_cpu()
-    ///         .with_disk_usage(),
+    ///         .with_disk_usage()
+    ///         .with_exe(UpdateKind::OnlyIfNotSet),
     /// );
     /// ```
     ///
@@ -247,7 +248,8 @@ impl System {
             ProcessRefreshKind::new()
                 .with_memory()
                 .with_cpu()
-                .with_disk_usage(),
+                .with_disk_usage()
+                .with_exe(UpdateKind::OnlyIfNotSet),
         );
     }
 
@@ -273,7 +275,7 @@ impl System {
     /// It is the same as calling:
     ///
     /// ```no_run
-    /// # use sysinfo::{Pid, ProcessRefreshKind, System};
+    /// # use sysinfo::{Pid, ProcessRefreshKind, System, UpdateKind};
     /// # let mut system = System::new();
     /// # let pid = Pid::from(0);
     /// system.refresh_process_specifics(
@@ -281,7 +283,8 @@ impl System {
     ///     ProcessRefreshKind::new()
     ///         .with_memory()
     ///         .with_cpu()
-    ///         .with_disk_usage(),
+    ///         .with_disk_usage()
+    ///         .with_exe(UpdateKind::OnlyIfNotSet),
     /// );
     /// ```
     ///
@@ -302,7 +305,8 @@ impl System {
             ProcessRefreshKind::new()
                 .with_memory()
                 .with_cpu()
-                .with_disk_usage(),
+                .with_disk_usage()
+                .with_exe(UpdateKind::OnlyIfNotSet),
         )
     }
 


Test patch:
diff --git a/tests/process.rs b/tests/process.rs
index 6cb5ac2eb..9fd414ea0 100644
--- a/tests/process.rs
+++ b/tests/process.rs
@@ -2,28 +2,6 @@
 
 use sysinfo::{Pid, ProcessRefreshKind, System, UpdateKind};
 
-#[test]
-fn test_process() {
-    let mut s = System::new();
-    assert_eq!(s.processes().len(), 0);
-    s.refresh_processes();
-    if !sysinfo::IS_SUPPORTED || cfg!(feature = "apple-sandbox") {
-        return;
-    }
-    assert!(!s.processes().is_empty());
-    assert!(s
-        .processes()
-        .values()
-        .all(|p| p.exe().as_os_str().is_empty()));
-
-    let mut s = System::new();
-    s.refresh_processes_specifics(ProcessRefreshKind::new().with_exe(UpdateKind::Always));
-    assert!(s
-        .processes()
-        .values()
-        .any(|p| !p.exe().as_os_str().is_empty()));
-}
-
 #[test]
 fn test_cwd() {
     if !sysinfo::IS_SUPPORTED || cfg!(feature = "apple-sandbox") {
@@ -188,17 +166,13 @@ fn test_process_refresh() {
         .process(sysinfo::get_current_pid().expect("failed to get current pid"))
         .is_some());
 
+    assert!(s.processes().iter().all(|(_, p)| p.environ().is_empty()
+        && p.cwd().as_os_str().is_empty()
+        && p.cmd().is_empty()));
     assert!(s
         .processes()
         .iter()
-        .all(|(_, p)| p.exe().as_os_str().is_empty()
-            && p.environ().is_empty()
-            && p.cwd().as_os_str().is_empty()
-            && p.cmd().is_empty()));
-    assert!(s
-        .processes()
-        .iter()
-        .any(|(_, p)| !p.name().is_empty() && p.memory() != 0));
+        .any(|(_, p)| !p.exe().as_os_str().is_empty() && !p.name().is_empty() && p.memory() != 0));
 }
 
 #[test]