Skip to content

Commit 59da97d

Browse files
committed
rustfmt the test
1 parent 6c67a76 commit 59da97d

File tree

1 file changed

+62
-30
lines changed

1 file changed

+62
-30
lines changed

src/test/run-pass/command-pre-exec.rs

Lines changed: 62 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
// ignore-windows - this is a unix-specific test
33
// ignore-cloudabi no processes
44
// ignore-emscripten no processes
5-
65
#![feature(process_exec, rustc_private)]
76

87
extern crate libc;
@@ -11,71 +10,104 @@ use std::env;
1110
use std::io::Error;
1211
use std::os::unix::process::CommandExt;
1312
use std::process::Command;
14-
use std::sync::Arc;
1513
use std::sync::atomic::{AtomicUsize, Ordering};
14+
use std::sync::Arc;
1615

1716
fn main() {
1817
if let Some(arg) = env::args().nth(1) {
1918
match &arg[..] {
2019
"test1" => println!("hello2"),
2120
"test2" => assert_eq!(env::var("FOO").unwrap(), "BAR"),
22-
"test3" => assert_eq!(env::current_dir().unwrap()
23-
.to_str().unwrap(), "/"),
21+
"test3" => assert_eq!(env::current_dir().unwrap().to_str().unwrap(), "/"),
2422
"empty" => {}
2523
_ => panic!("unknown argument: {}", arg),
2624
}
27-
return
25+
return;
2826
}
2927

3028
let me = env::current_exe().unwrap();
3129

32-
let output = unsafe { Command::new(&me).arg("test1").pre_exec(|| {
33-
println!("hello");
34-
Ok(())
35-
}).output().unwrap() };
30+
let output = unsafe {
31+
Command::new(&me)
32+
.arg("test1")
33+
.pre_exec(|| {
34+
println!("hello");
35+
Ok(())
36+
})
37+
.output()
38+
.unwrap()
39+
};
3640
assert!(output.status.success());
3741
assert!(output.stderr.is_empty());
3842
assert_eq!(output.stdout, b"hello\nhello2\n");
3943

40-
let output = unsafe { Command::new(&me).arg("test2").pre_exec(|| {
41-
env::set_var("FOO", "BAR");
42-
Ok(())
43-
}).output().unwrap() };
44+
let output = unsafe {
45+
Command::new(&me)
46+
.arg("test2")
47+
.pre_exec(|| {
48+
env::set_var("FOO", "BAR");
49+
Ok(())
50+
})
51+
.output()
52+
.unwrap()
53+
};
4454
assert!(output.status.success());
4555
assert!(output.stderr.is_empty());
4656
assert!(output.stdout.is_empty());
4757

48-
let output = unsafe { Command::new(&me).arg("test3").pre_exec(|| {
49-
env::set_current_dir("/").unwrap();
50-
Ok(())
51-
}).output().unwrap() };
58+
let output = unsafe {
59+
Command::new(&me)
60+
.arg("test3")
61+
.pre_exec(|| {
62+
env::set_current_dir("/").unwrap();
63+
Ok(())
64+
})
65+
.output()
66+
.unwrap()
67+
};
5268
assert!(output.status.success());
5369
assert!(output.stderr.is_empty());
5470
assert!(output.stdout.is_empty());
5571

56-
let output = unsafe { Command::new(&me).arg("bad").pre_exec(|| {
57-
Err(Error::from_raw_os_error(102))
58-
}).output().unwrap_err() };
72+
let output = unsafe {
73+
Command::new(&me)
74+
.arg("bad")
75+
.pre_exec(|| Err(Error::from_raw_os_error(102)))
76+
.output()
77+
.unwrap_err()
78+
};
5979
assert_eq!(output.raw_os_error(), Some(102));
6080

6181
let pid = unsafe { libc::getpid() };
6282
assert!(pid >= 0);
63-
let output = unsafe { Command::new(&me).arg("empty").pre_exec(move || {
64-
let child = libc::getpid();
65-
assert!(child >= 0);
66-
assert!(pid != child);
67-
Ok(())
68-
}).output().unwrap() };
83+
let output = unsafe {
84+
Command::new(&me)
85+
.arg("empty")
86+
.pre_exec(move || {
87+
let child = libc::getpid();
88+
assert!(child >= 0);
89+
assert!(pid != child);
90+
Ok(())
91+
})
92+
.output()
93+
.unwrap()
94+
};
6995
assert!(output.status.success());
7096
assert!(output.stderr.is_empty());
7197
assert!(output.stdout.is_empty());
7298

7399
let mem = Arc::new(AtomicUsize::new(0));
74100
let mem2 = mem.clone();
75-
let output = unsafe { Command::new(&me).arg("empty").pre_exec(move || {
76-
assert_eq!(mem2.fetch_add(1, Ordering::SeqCst), 0);
77-
Ok(())
78-
}).output().unwrap() };
101+
let output = unsafe {
102+
Command::new(&me)
103+
.arg("empty")
104+
.pre_exec(move || {
105+
assert_eq!(mem2.fetch_add(1, Ordering::SeqCst), 0);
106+
Ok(())
107+
})
108+
.output()
109+
.unwrap()
110+
};
79111
assert!(output.status.success());
80112
assert!(output.stderr.is_empty());
81113
assert!(output.stdout.is_empty());

0 commit comments

Comments
 (0)