| 1 |
Description: Gate unit tests on std feature for no_std builds |
| 2 |
Author: Simon Quigley <[email protected]> |
| 3 |
Origin: vendor |
| 4 |
Forwarded: not-needed |
| 5 |
Last-Update: 2026-08-18 |
| 6 |
--- |
| 7 |
--- a/src/features/borsh.rs |
| 8 |
+++ b/src/features/borsh.rs |
| 9 |
@@ -65,7 +65,7 @@ fn vec_from_reader<R: Read>(len: usize, |
| 10 |
Ok(vec) |
| 11 |
} |
| 12 |
|
| 13 |
-#[cfg(test)] |
| 14 |
+#[cfg(all(test, feature = "std"))] |
| 15 |
mod tests { |
| 16 |
use alloc::string::String; |
| 17 |
|
| 18 |
--- a/src/features/bytes.rs |
| 19 |
+++ b/src/features/bytes.rs |
| 20 |
@@ -64,7 +64,7 @@ impl CompactString { |
| 21 |
} |
| 22 |
} |
| 23 |
|
| 24 |
-#[cfg(test)] |
| 25 |
+#[cfg(all(test, feature = "std"))] |
| 26 |
mod test { |
| 27 |
use alloc::string::String; |
| 28 |
use alloc::vec::Vec; |
| 29 |
--- a/src/features/markup.rs |
| 30 |
+++ b/src/features/markup.rs |
| 31 |
@@ -13,7 +13,7 @@ impl Render for CompactString { |
| 32 |
} |
| 33 |
} |
| 34 |
|
| 35 |
-#[cfg(test)] |
| 36 |
+#[cfg(all(test, feature = "std"))] |
| 37 |
#[test] |
| 38 |
fn test_markup() { |
| 39 |
const TEXT: &str = "<script>alert('Hello, world!')</script>"; |
| 40 |
--- a/src/features/rkyv.rs |
| 41 |
+++ b/src/features/rkyv.rs |
| 42 |
@@ -51,7 +51,7 @@ impl PartialOrd<CompactString> for Archi |
| 43 |
} |
| 44 |
} |
| 45 |
|
| 46 |
-#[cfg(test)] |
| 47 |
+#[cfg(all(test, feature = "std"))] |
| 48 |
mod tests { |
| 49 |
use alloc::string::String; |
| 50 |
|
| 51 |
--- a/src/features/serde.rs |
| 52 |
+++ b/src/features/serde.rs |
| 53 |
@@ -71,7 +71,7 @@ impl<'de> serde::Deserialize<'de> for Co |
| 54 |
} |
| 55 |
} |
| 56 |
|
| 57 |
-#[cfg(test)] |
| 58 |
+#[cfg(all(test, feature = "std"))] |
| 59 |
mod tests { |
| 60 |
use alloc::string::{String, ToString}; |
| 61 |
use alloc::vec::Vec; |
| 62 |
--- a/src/features/smallvec.rs |
| 63 |
+++ b/src/features/smallvec.rs |
| 64 |
@@ -27,7 +27,7 @@ impl CompactString { |
| 65 |
} |
| 66 |
} |
| 67 |
|
| 68 |
-#[cfg(test)] |
| 69 |
+#[cfg(all(test, feature = "std"))] |
| 70 |
mod tests { |
| 71 |
use alloc::string::String; |
| 72 |
|
| 73 |
--- a/src/features/zeroize.rs |
| 74 |
+++ b/src/features/zeroize.rs |
| 75 |
@@ -10,7 +10,7 @@ impl Zeroize for CompactString { |
| 76 |
} |
| 77 |
} |
| 78 |
|
| 79 |
-#[cfg(test)] |
| 80 |
+#[cfg(all(test, feature = "std"))] |
| 81 |
mod tests { |
| 82 |
use std::string::ToString; |
| 83 |
|
| 84 |
--- a/src/repr/bytes.rs |
| 85 |
+++ b/src/repr/bytes.rs |
| 86 |
@@ -82,7 +82,7 @@ impl Repr { |
| 87 |
} |
| 88 |
} |
| 89 |
|
| 90 |
-#[cfg(test)] |
| 91 |
+#[cfg(all(test, feature = "std"))] |
| 92 |
mod test { |
| 93 |
#[cfg(feature = "std")] |
| 94 |
use std::io::Cursor; |
| 95 |
--- a/src/tests.rs |
| 96 |
+++ b/src/tests.rs |
| 97 |
@@ -1,3 +1,4 @@ |
| 98 |
+#![cfg(feature = "std")] |
| 99 |
use alloc::borrow::Cow; |
| 100 |
use alloc::boxed::Box; |
| 101 |
use alloc::string::{String, ToString}; |
| 102 |
--- a/src/traits.rs |
| 103 |
+++ b/src/traits.rs |
| 104 |
@@ -210,7 +210,7 @@ where |
| 105 |
} |
| 106 |
} |
| 107 |
|
| 108 |
-#[cfg(test)] |
| 109 |
+#[cfg(all(test, feature = "std"))] |
| 110 |
mod tests { |
| 111 |
use alloc::string::{String, ToString}; |
| 112 |
use alloc::vec::Vec; |
| 113 |
--- a/src/features/valuable.rs |
| 114 |
+++ b/src/features/valuable.rs |
| 115 |
@@ -16,7 +16,7 @@ impl Valuable for CompactString { |
| 116 |
} |
| 117 |
} |
| 118 |
|
| 119 |
-#[cfg(test)] |
| 120 |
+#[cfg(all(test, feature = "std"))] |
| 121 |
mod tests { |
| 122 |
use alloc::string::String; |
| 123 |
|