about summary refs log tree commit diff
path: root/library/std/tests/process_spawning.rs
diff options
context:
space:
mode:
authorMoskalykA <100430077+MoskalykA@users.noreply.github.com>2023-07-26 15:07:57 +0200
committerMoskalykA <100430077+MoskalykA@users.noreply.github.com>2023-07-26 15:07:57 +0200
commit48e7f3e313c19d8df1a05f0ccc17ac02e41dda6a (patch)
tree9c60b628d6cbee36502f2e6bef5ef12ce276e391 /library/std/tests/process_spawning.rs
parent4227c0a406f31b7a2b2f4423541234d480a66e70 (diff)
downloadrust-48e7f3e313c19d8df1a05f0ccc17ac02e41dda6a.tar.gz
rust-48e7f3e313c19d8df1a05f0ccc17ac02e41dda6a.zip
Have a better file name than just the issue id
Diffstat (limited to 'library/std/tests/process_spawning.rs')
-rw-r--r--library/std/tests/process_spawning.rs36
1 files changed, 36 insertions, 0 deletions
diff --git a/library/std/tests/process_spawning.rs b/library/std/tests/process_spawning.rs
new file mode 100644
index 00000000000..52e5b55fb9d
--- /dev/null
+++ b/library/std/tests/process_spawning.rs
@@ -0,0 +1,36 @@
+use std::env;
+use std::fs;
+use std::process;
+use std::str;
+
+mod common;
+
+#[test]
+fn issue_15149() {
+    // If we're the parent, copy our own binary to a new directory.
+    let my_path = env::current_exe().unwrap();
+
+    let temp = common::tmpdir();
+    let child_dir = temp.join("issue-15140-child");
+    fs::create_dir_all(&child_dir).unwrap();
+
+    let child_path = child_dir.join(&format!("mytest{}", env::consts::EXE_SUFFIX));
+    fs::copy(&my_path, &child_path).unwrap();
+
+    // Append the new directory to our own PATH.
+    let path = {
+        let mut paths: Vec<_> = env::split_paths(&env::var_os("PATH").unwrap()).collect();
+        paths.push(child_dir.to_path_buf());
+        env::join_paths(paths).unwrap()
+    };
+
+    let child_output =
+        process::Command::new("mytest").env("PATH", &path).arg("child").output().unwrap();
+
+    assert!(
+        child_output.status.success(),
+        "child assertion failed\n child stdout:\n {}\n child stderr:\n {}",
+        str::from_utf8(&child_output.stdout).unwrap(),
+        str::from_utf8(&child_output.stderr).unwrap()
+    );
+}