@@ -272,4 +272,70 @@ pub(crate) fn extract_hot_reload_project_path(process: &sysinfo::Process) -> Opt
272
272
fn process_refresh_kind ( ) -> ProcessRefreshKind {
273
273
// we need nothing, no cpu, no memory, just basics
274
274
ProcessRefreshKind :: nothing ( ) . with_exe ( UpdateKind :: Always ) . with_cmd ( UpdateKind :: Always )
275
+ }
276
+
277
+ #[ cfg( test) ]
278
+ mod tests {
279
+ use super :: * ;
280
+ use sysinfo:: { System , ProcessRefreshKind , UpdateKind } ;
281
+
282
+ #[ test]
283
+ #[ cfg( target_os = "windows" ) ]
284
+ fn test_process_refresh_kind_parent_id_accessible ( ) {
285
+ // Create a system and refresh with our specific ProcessRefreshKind
286
+ let mut system = System :: new ( ) ;
287
+ let refresh_kind = ProcessRefreshKind :: nothing ( ) ;
288
+
289
+ // Refresh processes with our specific refresh kind
290
+ system. refresh_processes_specifics (
291
+ sysinfo:: ProcessesToUpdate :: All ,
292
+ true ,
293
+ refresh_kind
294
+ ) ;
295
+
296
+ // Find any process that has a parent (most processes should have one)
297
+ let mut found_process_with_parent = false ;
298
+
299
+ for ( _pid, process) in system. processes ( ) {
300
+ // Verify parent_id is accessible even though we didn't explicitly request it
301
+ if process. parent ( ) . is_some ( ) {
302
+ found_process_with_parent = true ;
303
+ }
304
+
305
+ // Verify that memory info is not detailed (we didn't request memory refresh)
306
+ assert ! ( process. memory( ) == 0 , "memory should be 0" ) ;
307
+ }
308
+
309
+ // Assert that we found at least one process with a parent
310
+ // This verifies that parent_id is accessible even without explicit request
311
+ assert ! ( found_process_with_parent, "Should find at least one process with a parent ID" ) ;
312
+
313
+ // The test verifies that:
314
+ // 1. parent_id is accessible (found_process_with_parent = true)
315
+ // 2. We only requested exe and cmd info, not CPU or detailed memory
316
+ // 3. The ProcessRefreshKind configuration works as expected
317
+ }
318
+
319
+ #[ test]
320
+ fn test_process_refresh_kind_memory_info ( ) {
321
+ // Create a system and refresh with our specific ProcessRefreshKind
322
+ let mut system = System :: new ( ) ;
323
+ let refresh_kind = ProcessRefreshKind :: nothing ( ) . with_memory ( ) ;
324
+
325
+ // Refresh processes with our specific refresh kind
326
+ system. refresh_processes_specifics (
327
+ sysinfo:: ProcessesToUpdate :: All ,
328
+ true ,
329
+ refresh_kind
330
+ ) ;
331
+
332
+ let mut sum_memory: u64 = 0 ;
333
+
334
+ for ( _pid, process) in system. processes ( ) {
335
+ // Verify that memory info is detailed
336
+ sum_memory += process. memory ( ) ;
337
+ }
338
+
339
+ assert ! ( sum_memory > 1000000000 , "sum memory should be greater than 1000000000" ) ;
340
+ }
275
341
}
0 commit comments