]> git.proxmox.com Git - pxar.git/commitdiff
add test-harness feature for separate unit tests
authorWolfgang Bumiller <w.bumiller@proxmox.com>
Thu, 25 Jun 2020 11:50:53 +0000 (13:50 +0200)
committerWolfgang Bumiller <w.bumiller@proxmox.com>
Thu, 25 Jun 2020 11:51:22 +0000 (13:51 +0200)
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
Cargo.toml
src/format/acl.rs
src/format/mod.rs
src/lib.rs

index a2eb3df0ad2e5228799a4a06603efe8b91f825f3..1890e7da0dd0ff35954c0ad13111a2b4f522f8db 100644 (file)
@@ -23,6 +23,12 @@ test = false
 bench = false
 doc = false
 
+[[test]]
+name = "simple"
+path = "tests/simple/main.rs"
+test = true
+required-features = [ "anyhow", "test-harness" ]
+
 [dependencies]
 bitflags = "1.2.1"
 endian_trait = { version = "0.6", features = ["arrays"] }
@@ -50,6 +56,8 @@ async-example = [
     "tokio/macros",
 ]
 
+test-harness = []
+
 [dev-dependencies]
 libc = "0.2"
 anyhow = "1.0"
index 3885a5f46c8a6291b501e7e8b55e493a53229c81..39eb7f9bf66bd2ae1be0cc986950eca1c0847481 100644 (file)
@@ -20,7 +20,7 @@ impl Permissions {
     pub const NO_MASK: Permissions = Permissions(NO_MASK);
 }
 
-#[derive(Clone, Debug, Endian, Eq)]
+#[derive(Clone, Debug, Endian, Eq, PartialEq)]
 #[repr(C)]
 pub struct User {
     pub uid: u64,
@@ -46,13 +46,7 @@ impl PartialOrd for User {
     }
 }
 
-impl PartialEq for User {
-    fn eq(&self, other: &User) -> bool {
-        self.uid == other.uid && self.permissions == other.permissions
-    }
-}
-
-#[derive(Clone, Debug, Endian, Eq)]
+#[derive(Clone, Debug, Endian, Eq, PartialEq)]
 #[repr(C)]
 pub struct Group {
     pub gid: u64,
@@ -78,19 +72,14 @@ impl PartialOrd for Group {
     }
 }
 
-impl PartialEq for Group {
-    fn eq(&self, other: &Group) -> bool {
-        self.gid == other.gid && self.permissions == other.permissions
-    }
-}
-
-#[derive(Clone, Debug, Endian)]
+#[derive(Clone, Debug, Endian, Eq, PartialEq)]
 #[repr(C)]
 pub struct GroupObject {
     pub permissions: Permissions,
 }
 
 #[derive(Clone, Debug, Endian)]
+#[cfg_attr(feature = "test-harness", derive(Eq, PartialEq))]
 #[repr(C)]
 pub struct Default {
     pub user_obj_permissions: Permissions,
index e3db8f52e00b17f36323fba47326794fb4877d40..07470b4ac371c823e02a5fff003a346790a5c076 100644 (file)
@@ -165,6 +165,7 @@ impl Display for Header {
 }
 
 #[derive(Clone, Debug, Default, Endian)]
+#[cfg_attr(feature = "test-harness", derive(Eq, PartialEq))]
 #[repr(C)]
 pub struct Entry {
     pub mode: u64,
@@ -438,7 +439,7 @@ impl PartialEq for XAttr {
     }
 }
 
-#[derive(Clone, Debug, Endian)]
+#[derive(Clone, Debug, Endian, Eq, PartialEq)]
 #[repr(C)]
 pub struct Device {
     pub major: u64,
@@ -479,12 +480,13 @@ fn test_linux_devices() {
 }
 
 #[derive(Clone, Debug)]
+#[cfg_attr(feature = "test-harness", derive(Eq, PartialEq))]
 #[repr(C)]
 pub struct FCaps {
     pub data: Vec<u8>,
 }
 
-#[derive(Clone, Copy, Debug, Endian)]
+#[derive(Clone, Copy, Debug, Endian, Eq, PartialEq)]
 #[repr(C)]
 pub struct QuotaProjectId {
     pub projid: u64,
index 4a40d193bfe1c0b7b7fd9431c102b5d7b13627de..1e887480b7aa4914e5a9892c220ec50c1bde7b45 100644 (file)
@@ -35,6 +35,7 @@ pub use format::mode;
 /// This includes the usual data you'd get from `stat()` as well as ACLs, extended attributes, file
 /// capabilities and more.
 #[derive(Clone, Debug, Default)]
+#[cfg_attr(feature = "test-harness", derive(Eq, PartialEq))]
 pub struct Metadata {
     /// Data typically found in a `stat()` call.
     pub stat: Stat,
@@ -283,6 +284,7 @@ impl MetadataBuilder {
 ///
 /// This contains all the various ACL entry types supported by the pxar archive format.
 #[derive(Clone, Debug, Default)]
+#[cfg_attr(feature = "test-harness", derive(Eq, PartialEq))]
 pub struct Acl {
     /// User ACL list.
     pub users: Vec<format::acl::User>,