about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--library/std/src/sys/unix/process/process_unsupported/wait_status.rs39
-rw-r--r--library/std/src/sys/unix/process/process_unsupported/wait_status/tests.rs36
2 files changed, 39 insertions, 36 deletions
diff --git a/library/std/src/sys/unix/process/process_unsupported/wait_status.rs b/library/std/src/sys/unix/process/process_unsupported/wait_status.rs
index f465946a528..3c649db1a35 100644
--- a/library/std/src/sys/unix/process/process_unsupported/wait_status.rs
+++ b/library/std/src/sys/unix/process/process_unsupported/wait_status.rs
@@ -63,39 +63,6 @@ impl ExitStatus {
     }
 }
 
-// Test that our emulation exactly matches Linux
-//
-// This test runs *on Linux* but it tests
-// the implementation used on non-Unix `#[cfg(unix)]` platforms.
-//
-// I.e. we're using Linux as a proxy for "trad unix".
-#[cfg(all(test, target_os = "linux"))]
-mod compare_with_linux {
-    use super::ExitStatus as Emulated;
-    use crate::os::unix::process::ExitStatusExt as _;
-    use crate::process::ExitStatus as Real;
-
-    #[test]
-    fn compare() {
-        // Check that we handle out-of-range values similarly, too.
-        for wstatus in -0xf_ffff..0xf_ffff {
-            let emulated = Emulated::from(wstatus);
-            let real = Real::from_raw(wstatus);
-
-            macro_rules! compare { { $method:ident } => {
-                assert_eq!(
-                    emulated.$method(),
-                    real.$method(),
-                    "{wstatus:#x}.{}()",
-                    stringify!($method),
-                );
-            } }
-            compare!(code);
-            compare!(signal);
-            compare!(core_dumped);
-            compare!(stopped_signal);
-            compare!(continued);
-            compare!(into_raw);
-        }
-    }
-}
+#[cfg(test)]
+#[path = "wait_status/tests.rs"] // needed because of strange layout of process_unsupported
+mod tests;
diff --git a/library/std/src/sys/unix/process/process_unsupported/wait_status/tests.rs b/library/std/src/sys/unix/process/process_unsupported/wait_status/tests.rs
new file mode 100644
index 00000000000..5132eab10a1
--- /dev/null
+++ b/library/std/src/sys/unix/process/process_unsupported/wait_status/tests.rs
@@ -0,0 +1,36 @@
+// Note that tests in this file are run on Linux as well as on platforms using process_unsupported
+
+// Test that our emulation exactly matches Linux
+//
+// This test runs *on Linux* but it tests
+// the implementation used on non-Unix `#[cfg(unix)]` platforms.
+//
+// I.e. we're using Linux as a proxy for "trad unix".
+#[cfg(target_os = "linux")]
+#[test]
+fn compare_with_linux() {
+    use super::ExitStatus as Emulated;
+    use crate::os::unix::process::ExitStatusExt as _;
+    use crate::process::ExitStatus as Real;
+
+    // Check that we handle out-of-range values similarly, too.
+    for wstatus in -0xf_ffff..0xf_ffff {
+        let emulated = Emulated::from(wstatus);
+        let real = Real::from_raw(wstatus);
+
+        macro_rules! compare { { $method:ident } => {
+            assert_eq!(
+                emulated.$method(),
+                real.$method(),
+                "{wstatus:#x}.{}()",
+                stringify!($method),
+            );
+        } }
+        compare!(code);
+        compare!(signal);
+        compare!(core_dumped);
+        compare!(stopped_signal);
+        compare!(continued);
+        compare!(into_raw);
+    }
+}