[pve-devel] [RFC proxmox 1/7] sys: fs: move tests to a sub-module

Lukas Wagner l.wagner at proxmox.com
Mon Aug 21 15:44:38 CEST 2023


This ensures that test code is not compiled in regular builds

Signed-off-by: Lukas Wagner <l.wagner at proxmox.com>
---
 proxmox-sys/src/fs/dir.rs | 29 +++++++++++++++++------------
 1 file changed, 17 insertions(+), 12 deletions(-)

diff --git a/proxmox-sys/src/fs/dir.rs b/proxmox-sys/src/fs/dir.rs
index bdef85e..6aee316 100644
--- a/proxmox-sys/src/fs/dir.rs
+++ b/proxmox-sys/src/fs/dir.rs
@@ -152,16 +152,21 @@ fn create_path_at_do(
     }
 }
 
-#[test]
-fn test_create_path() {
-    create_path(
-        "testdir/testsub/testsub2/testfinal",
-        Some(CreateOptions::new().perm(stat::Mode::from_bits_truncate(0o755))),
-        Some(
-            CreateOptions::new()
-                .owner(nix::unistd::Uid::effective())
-                .group(nix::unistd::Gid::effective()),
-        ),
-    )
-    .expect("expected create_path to work");
+#[cfg(test)]
+mod tests {
+    use super::*;
+
+    #[test]
+    fn test_create_path() {
+        create_path(
+            "testdir/testsub/testsub2/testfinal",
+            Some(CreateOptions::new().perm(stat::Mode::from_bits_truncate(0o755))),
+            Some(
+                CreateOptions::new()
+                    .owner(nix::unistd::Uid::effective())
+                    .group(nix::unistd::Gid::effective()),
+            ),
+        )
+        .expect("expected create_path to work");
+    }
 }
-- 
2.39.2






More information about the pve-devel mailing list