@@ -9,6 +9,7 @@ mod platform;
99mod qemu;
1010mod util;
1111
12+ use crate :: opt:: TestOpt ;
1213use anyhow:: Result ;
1314use cargo:: { fix_nested_cargo_env, Cargo , CargoAction , Feature , Package , TargetTypes } ;
1415use clap:: Parser ;
@@ -47,7 +48,7 @@ fn build(opt: &BuildOpt) -> Result<()> {
4748
4849 let cargo = Cargo {
4950 action : CargoAction :: Build ,
50- features : Feature :: more_code ( ) ,
51+ features : Feature :: more_code ( true , true ) ,
5152 packages : Package :: all_except_xtask ( ) ,
5253 release : opt. build_mode . release ,
5354 target : Some ( * opt. target ) ,
@@ -61,7 +62,8 @@ fn clippy(opt: &ClippyOpt) -> Result<()> {
6162 // Run clippy on all the UEFI packages.
6263 let cargo = Cargo {
6364 action : CargoAction :: Clippy ,
64- features : Feature :: more_code ( ) ,
65+ // for all possible features
66+ features : Feature :: more_code ( true , true ) ,
6567 packages : Package :: all_except_xtask ( ) ,
6668 release : false ,
6769 target : Some ( * opt. target ) ,
@@ -90,7 +92,8 @@ fn doc(opt: &DocOpt) -> Result<()> {
9092 open : opt. open ,
9193 document_private_items : opt. document_private_items ,
9294 } ,
93- features : Feature :: more_code ( ) ,
95+ // for all possible features
96+ features : Feature :: more_code ( true , true ) ,
9497 packages : Package :: published ( ) ,
9598 release : false ,
9699 target : None ,
@@ -143,7 +146,7 @@ fn run_vm_tests(opt: &QemuOpt) -> Result<()> {
143146/// Run unit tests and doctests on the host. Most of uefi-rs is tested
144147/// with VM tests, but a few things like macros and data types can be
145148/// tested with regular tests.
146- fn run_host_tests ( ) -> Result < ( ) > {
149+ fn run_host_tests ( test_opt : & TestOpt ) -> Result < ( ) > {
147150 // Run xtask tests.
148151 let cargo = Cargo {
149152 action : CargoAction :: Test ,
@@ -159,7 +162,11 @@ fn run_host_tests() -> Result<()> {
159162 // Run uefi-rs and uefi-macros tests.
160163 let cargo = Cargo {
161164 action : CargoAction :: Test ,
162- features : vec ! [ Feature :: Alloc ] ,
165+ // At least one unit test, for make_boxed() currently, has different behaviour dependent on
166+ // the unstable feature. Because of this, we need to allow to test both variants. Runtime
167+ // features is set to no as it is not possible as as soon a #[global_allocator] is
168+ // registered, the Rust runtime executing the tests uses it as well.
169+ features : Feature :: more_code ( test_opt. include_unstable , false ) ,
163170 // Don't test uefi-services (or the packages that depend on it)
164171 // as it has lang items that conflict with `std`.
165172 packages : vec ! [ Package :: Uefi , Package :: UefiMacros ] ,
@@ -222,7 +229,7 @@ fn main() -> Result<()> {
222229 Action :: GenCode ( gen_opt) => device_path:: gen_code ( gen_opt) ,
223230 Action :: Miri ( _) => run_miri ( ) ,
224231 Action :: Run ( qemu_opt) => run_vm_tests ( qemu_opt) ,
225- Action :: Test ( _ ) => run_host_tests ( ) ,
232+ Action :: Test ( test_opt ) => run_host_tests ( test_opt ) ,
226233 Action :: TestLatestRelease ( _) => test_latest_release ( ) ,
227234 }
228235}
0 commit comments