Skip to content

Commit 4a0ec50

Browse files
committed
Update issue-15149.rs
1 parent 7200afa commit 4a0ec50

File tree

1 file changed

+14
-13
lines changed

1 file changed

+14
-13
lines changed

src/test/ui-fulldeps/issue-15149.rs

+14-13
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,11 @@
55
// ignore-cross-compile
66

77
use std::env;
8+
use std::ffi::OsStr;
89
use std::fs;
10+
use std::path::PathBuf;
911
use std::process;
1012
use std::str;
11-
use std::path::PathBuf;
1213

1314
fn main() {
1415
// If we're the child, make sure we were invoked correctly
@@ -18,8 +19,8 @@ fn main() {
1819
// checking that it ends_with the executable name. This
1920
// is needed because of Windows, which has a different behavior.
2021
// See #15149 for more info.
21-
return assert!(args[0].ends_with(&format!("mytest{}",
22-
env::consts::EXE_SUFFIX)));
22+
let my_path = env::current_exe().unwrap();
23+
return assert_eq!(my_path.file_stem(), Some(OsStr::new("mytest")));
2324
}
2425

2526
test();
@@ -28,14 +29,13 @@ fn main() {
2829
fn test() {
2930
// If we're the parent, copy our own binary to a new directory.
3031
let my_path = env::current_exe().unwrap();
31-
let my_dir = my_path.parent().unwrap();
32+
let my_dir = my_path.parent().unwrap();
3233

3334
let child_dir = PathBuf::from(env::var_os("RUST_TEST_TMPDIR").unwrap());
3435
let child_dir = child_dir.join("issue-15140-child");
3536
fs::create_dir_all(&child_dir).unwrap();
3637

37-
let child_path = child_dir.join(&format!("mytest{}",
38-
env::consts::EXE_SUFFIX));
38+
let child_path = child_dir.join(&format!("mytest{}", env::consts::EXE_SUFFIX));
3939
fs::copy(&my_path, &child_path).unwrap();
4040

4141
// Append the new directory to our own PATH.
@@ -45,12 +45,13 @@ fn test() {
4545
env::join_paths(paths).unwrap()
4646
};
4747

48-
let child_output = process::Command::new("mytest").env("PATH", &path)
49-
.arg("child")
50-
.output().unwrap();
48+
let child_output =
49+
process::Command::new("mytest").env("PATH", &path).arg("child").output().unwrap();
5150

52-
assert!(child_output.status.success(),
53-
"child assertion failed\n child stdout:\n {}\n child stderr:\n {}",
54-
str::from_utf8(&child_output.stdout).unwrap(),
55-
str::from_utf8(&child_output.stderr).unwrap());
51+
assert!(
52+
child_output.status.success(),
53+
"child assertion failed\n child stdout:\n {}\n child stderr:\n {}",
54+
str::from_utf8(&child_output.stdout).unwrap(),
55+
str::from_utf8(&child_output.stderr).unwrap()
56+
);
5657
}

0 commit comments

Comments
 (0)