@@ -9,6 +9,7 @@ mod platform;
9
9
mod qemu;
10
10
mod util;
11
11
12
+ use crate :: opt:: TestOpt ;
12
13
use anyhow:: Result ;
13
14
use cargo:: { fix_nested_cargo_env, Cargo , CargoAction , Feature , Package , TargetTypes } ;
14
15
use clap:: Parser ;
@@ -47,7 +48,7 @@ fn build(opt: &BuildOpt) -> Result<()> {
47
48
48
49
let cargo = Cargo {
49
50
action : CargoAction :: Build ,
50
- features : Feature :: more_code ( ) ,
51
+ features : Feature :: more_code ( true , true ) ,
51
52
packages : Package :: all_except_xtask ( ) ,
52
53
release : opt. build_mode . release ,
53
54
target : Some ( * opt. target ) ,
@@ -61,7 +62,8 @@ fn clippy(opt: &ClippyOpt) -> Result<()> {
61
62
// Run clippy on all the UEFI packages.
62
63
let cargo = Cargo {
63
64
action : CargoAction :: Clippy ,
64
- features : Feature :: more_code ( ) ,
65
+ // for all possible features
66
+ features : Feature :: more_code ( true , true ) ,
65
67
packages : Package :: all_except_xtask ( ) ,
66
68
release : false ,
67
69
target : Some ( * opt. target ) ,
@@ -90,7 +92,8 @@ fn doc(opt: &DocOpt) -> Result<()> {
90
92
open : opt. open ,
91
93
document_private_items : opt. document_private_items ,
92
94
} ,
93
- features : Feature :: more_code ( ) ,
95
+ // for all possible features
96
+ features : Feature :: more_code ( true , true ) ,
94
97
packages : Package :: published ( ) ,
95
98
release : false ,
96
99
target : None ,
@@ -143,7 +146,7 @@ fn run_vm_tests(opt: &QemuOpt) -> Result<()> {
143
146
/// Run unit tests and doctests on the host. Most of uefi-rs is tested
144
147
/// with VM tests, but a few things like macros and data types can be
145
148
/// tested with regular tests.
146
- fn run_host_tests ( ) -> Result < ( ) > {
149
+ fn run_host_tests ( test_opt : & TestOpt ) -> Result < ( ) > {
147
150
// Run xtask tests.
148
151
let cargo = Cargo {
149
152
action : CargoAction :: Test ,
@@ -159,7 +162,11 @@ fn run_host_tests() -> Result<()> {
159
162
// Run uefi-rs and uefi-macros tests.
160
163
let cargo = Cargo {
161
164
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 ) ,
163
170
// Don't test uefi-services (or the packages that depend on it)
164
171
// as it has lang items that conflict with `std`.
165
172
packages : vec ! [ Package :: Uefi , Package :: UefiMacros ] ,
@@ -222,7 +229,7 @@ fn main() -> Result<()> {
222
229
Action :: GenCode ( gen_opt) => device_path:: gen_code ( gen_opt) ,
223
230
Action :: Miri ( _) => run_miri ( ) ,
224
231
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 ) ,
226
233
Action :: TestLatestRelease ( _) => test_latest_release ( ) ,
227
234
}
228
235
}
0 commit comments