Skip to content

Commit f625528

Browse files
committed
std: unix process_unsupported: Provide a wait status emulation (tidy)
Move tests into a module as demanded by tidy.
1 parent 281b050 commit f625528

File tree

2 files changed

+39
-36
lines changed

2 files changed

+39
-36
lines changed

library/std/src/sys/unix/process/process_unsupported/wait_status.rs

+3-36
Original file line numberDiff line numberDiff line change
@@ -63,39 +63,6 @@ impl ExitStatus {
6363
}
6464
}
6565

66-
// Test that our emulation exactly matches Linux
67-
//
68-
// This test runs *on Linux* but it tests
69-
// the implementation used on non-Unix `#[cfg(unix)]` platforms.
70-
//
71-
// I.e. we're using Linux as a proxy for "trad unix".
72-
#[cfg(all(test, target_os = "linux"))]
73-
mod compare_with_linux {
74-
use super::ExitStatus as Emulated;
75-
use crate::os::unix::process::ExitStatusExt as _;
76-
use crate::process::ExitStatus as Real;
77-
78-
#[test]
79-
fn compare() {
80-
// Check that we handle out-of-range values similarly, too.
81-
for wstatus in -0xf_ffff..0xf_ffff {
82-
let emulated = Emulated::from(wstatus);
83-
let real = Real::from_raw(wstatus);
84-
85-
macro_rules! compare { { $method:ident } => {
86-
assert_eq!(
87-
emulated.$method(),
88-
real.$method(),
89-
"{wstatus:#x}.{}()",
90-
stringify!($method),
91-
);
92-
} }
93-
compare!(code);
94-
compare!(signal);
95-
compare!(core_dumped);
96-
compare!(stopped_signal);
97-
compare!(continued);
98-
compare!(into_raw);
99-
}
100-
}
101-
}
66+
#[cfg(test)]
67+
#[path = "wait_status/tests.rs"] // needed because of strange layout of process_unsupported
68+
mod tests;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
// Note that tests in this file are run on Linux as well as on platforms using process_unsupported
2+
3+
// Test that our emulation exactly matches Linux
4+
//
5+
// This test runs *on Linux* but it tests
6+
// the implementation used on non-Unix `#[cfg(unix)]` platforms.
7+
//
8+
// I.e. we're using Linux as a proxy for "trad unix".
9+
#[cfg(target_os = "linux")]
10+
#[test]
11+
fn compare_with_linux() {
12+
use super::ExitStatus as Emulated;
13+
use crate::os::unix::process::ExitStatusExt as _;
14+
use crate::process::ExitStatus as Real;
15+
16+
// Check that we handle out-of-range values similarly, too.
17+
for wstatus in -0xf_ffff..0xf_ffff {
18+
let emulated = Emulated::from(wstatus);
19+
let real = Real::from_raw(wstatus);
20+
21+
macro_rules! compare { { $method:ident } => {
22+
assert_eq!(
23+
emulated.$method(),
24+
real.$method(),
25+
"{wstatus:#x}.{}()",
26+
stringify!($method),
27+
);
28+
} }
29+
compare!(code);
30+
compare!(signal);
31+
compare!(core_dumped);
32+
compare!(stopped_signal);
33+
compare!(continued);
34+
compare!(into_raw);
35+
}
36+
}

0 commit comments

Comments
 (0)