File: support-specific-target-dir-in-tests.diff

package info (click to toggle)
rust-sysinfo 0.37.2-1
  • links: PTS, VCS
  • area: main
  • in suites: experimental
  • size: 2,264 kB
  • sloc: ansic: 158; makefile: 27
file content (82 lines) | stat: -rw-r--r-- 3,062 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
Index: sysinfo/tests/process.rs
===================================================================
--- sysinfo.orig/tests/process.rs
+++ sysinfo/tests/process.rs
@@ -4,6 +4,7 @@
 
 use bstr::ByteSlice;
 use sysinfo::{Pid, ProcessRefreshKind, ProcessesToUpdate, RefreshKind, System, UpdateKind};
+use std::path::Path;
 
 macro_rules! start_proc {
     ($time:literal, $name:literal) => {
@@ -101,9 +102,11 @@ fn test_environ() {
     if !sysinfo::IS_SUPPORTED_SYSTEM || cfg!(feature = "apple-sandbox") {
         return;
     }
-    let file_name = "target/test_binary";
+    let target_dir = Path::new(option_env!("CARGO_TARGET_DIR").unwrap_or("target"));
+    let file_name = target_dir.join("test_binary");
+    let file_name = file_name.to_str().unwrap();
     build_test_binary(file_name);
-    let mut p = std::process::Command::new(format!("./{file_name}"))
+    let mut p = std::process::Command::new(file_name)
         .env("FOO", "BAR")
         .env("OTHER", "VALUE")
         .spawn()
@@ -138,7 +141,7 @@ fn test_environ() {
     for _ in 0..SIZE {
         big_env.push('a');
     }
-    let mut p = std::process::Command::new("./target/test_binary")
+    let mut p = std::process::Command::new(file_name)
         .env("FOO", &big_env)
         .spawn()
         .unwrap();
@@ -916,9 +919,11 @@ fn test_parent_change() {
         return;
     }
 
-    let file_name = "target/test_binary2";
+    let target_dir = Path::new(option_env!("CARGO_TARGET_DIR").unwrap_or("target"));
+    let file_name = target_dir.join("test_binary2");
+    let file_name = file_name.to_str().unwrap();
     build_test_binary(file_name);
-    let mut p = std::process::Command::new(format!("./{file_name}"))
+    let mut p = std::process::Command::new(file_name)
         .arg("1")
         .spawn()
         .unwrap();
@@ -965,13 +970,15 @@ fn test_multiple_single_process_refresh(
         return;
     }
 
-    let file_name = "target/test_binary3";
+    let target_dir = Path::new(option_env!("CARGO_TARGET_DIR").unwrap_or("target"));
+    let file_name = target_dir.join("test_binary3");
+    let file_name = file_name.to_str().unwrap();
     build_test_binary(file_name);
-    let mut p_a = std::process::Command::new(format!("./{file_name}"))
+    let mut p_a = std::process::Command::new(file_name)
         .arg("1")
         .spawn()
         .unwrap();
-    let mut p_b = std::process::Command::new(format!("./{file_name}"))
+    let mut p_b = std::process::Command::new(file_name)
         .arg("1")
         .spawn()
         .unwrap();
@@ -1068,9 +1075,11 @@ fn test_exists() {
         return;
     }
 
-    let file_name = "target/test_binary4";
+    let target_dir = Path::new(option_env!("CARGO_TARGET_DIR").unwrap_or("target"));
+    let file_name = target_dir.join("test_binary4");
+    let file_name = file_name.to_str().unwrap();
     build_test_binary(file_name);
-    let mut p = std::process::Command::new(format!("./{file_name}"))
+    let mut p = std::process::Command::new(file_name)
         .arg("1")
         .spawn()
         .unwrap();