Skip to content

Commit 06d4019

Browse files
committed
For issue 15149 test, don't execute from tmpfs, and wait to see if the child panics before passing.
1 parent 451e134 commit 06d4019

File tree

1 file changed

+17
-13
lines changed

1 file changed

+17
-13
lines changed

src/test/run-pass/issue-15149.rs

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11-
use std::io::{TempDir, Command, fs};
11+
use std::io::{Command, fs, USER_RWX};
1212
use std::os;
1313

1414
fn main() {
@@ -22,19 +22,23 @@ fn main() {
2222
}
2323

2424
fn test() {
25-
// If we're the parent, copy our own binary to a tempr directory, and then
26-
// make it executable.
27-
let dir = TempDir::new("mytest").unwrap();
28-
let me = os::self_exe_name().unwrap();
29-
let dest = dir.path().join(format!("mytest{}", os::consts::EXE_SUFFIX));
30-
fs::copy(&me, &dest).unwrap();
31-
32-
// Append the temp directory to our own PATH.
25+
// If we're the parent, copy our own binary to a new directory.
26+
let my_path = os::self_exe_name().unwrap();
27+
let my_dir = my_path.dir_path();
28+
29+
let child_dir = Path::new(my_dir.join("issue-15149-child"));
30+
drop(fs::mkdir(&child_dir, USER_RWX));
31+
32+
let child_path = child_dir.join(format!("mytest{}",
33+
os::consts::EXE_SUFFIX));
34+
fs::copy(&my_path, &child_path).unwrap();
35+
36+
// Append the new directory to our own PATH.
3337
let mut path = os::split_paths(os::getenv("PATH").unwrap_or(String::new()));
34-
path.push(dir.path().clone());
38+
path.push(child_dir.clone());
3539
let path = os::join_paths(path.as_slice()).unwrap();
3640

37-
Command::new("mytest").env("PATH", path.as_slice())
38-
.arg("child")
39-
.spawn().unwrap();
41+
assert!(Command::new("mytest").env("PATH", path.as_slice())
42+
.arg("child")
43+
.status().unwrap().success());
4044
}

0 commit comments

Comments
 (0)