Skip to content

Commit 8c51602

Browse files
xtask: Add support for log-debugcon feature
This ensures `cargo xtask build --feature-permutations` tests `log-debugcon` both enabled and disabled.
1 parent eeaba6f commit 8c51602

File tree

1 file changed

+13
-6
lines changed

1 file changed

+13
-6
lines changed

xtask/src/cargo.rs

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ pub enum Feature {
4949
// `uefi` features.
5050
Alloc,
5151
GlobalAllocator,
52+
LogDebugcon,
5253
Logger,
5354
Unstable,
5455
PanicHandler,
@@ -68,6 +69,7 @@ impl Feature {
6869
match self {
6970
Self::Alloc => "alloc",
7071
Self::GlobalAllocator => "global_allocator",
72+
Self::LogDebugcon => "log-debugcon",
7173
Self::Logger => "logger",
7274
Self::Unstable => "unstable",
7375
Self::PanicHandler => "panic_handler",
@@ -88,6 +90,7 @@ impl Feature {
8890
Package::Uefi => vec![
8991
Self::Alloc,
9092
Self::GlobalAllocator,
93+
Self::LogDebugcon,
9194
Self::Logger,
9295
Self::Unstable,
9396
Self::PanicHandler,
@@ -112,7 +115,7 @@ impl Feature {
112115
/// - `include_unstable` - add all functionality behind the `unstable` feature
113116
/// - `runtime_features` - add all functionality that effect the runtime of Rust
114117
pub fn more_code(include_unstable: bool, runtime_features: bool) -> Vec<Self> {
115-
let mut base_features = vec![Self::Alloc, Self::Logger];
118+
let mut base_features = vec![Self::Alloc, Self::LogDebugcon, Self::Logger];
116119
if include_unstable {
117120
base_features.extend([Self::Unstable])
118121
}
@@ -293,6 +296,10 @@ impl Cargo {
293296
cmd.arg(sub_action);
294297
}
295298

299+
// Turn off default features so that `--feature-permutations` can test
300+
// with each feature enabled and disabled.
301+
cmd.arg("--no-default-features");
302+
296303
if self.release {
297304
cmd.arg("--release");
298305
}
@@ -337,19 +344,19 @@ mod tests {
337344
fn test_comma_separated_features() {
338345
assert_eq!(
339346
Feature::comma_separated_string(&Feature::more_code(false, false)),
340-
"alloc,logger"
347+
"alloc,log-debugcon,logger"
341348
);
342349
assert_eq!(
343350
Feature::comma_separated_string(&Feature::more_code(false, true)),
344-
"alloc,logger,global_allocator"
351+
"alloc,log-debugcon,logger,global_allocator"
345352
);
346353
assert_eq!(
347354
Feature::comma_separated_string(&Feature::more_code(true, false)),
348-
"alloc,logger,unstable"
355+
"alloc,log-debugcon,logger,unstable"
349356
);
350357
assert_eq!(
351358
Feature::comma_separated_string(&Feature::more_code(true, true)),
352-
"alloc,logger,unstable,global_allocator"
359+
"alloc,log-debugcon,logger,unstable,global_allocator"
353360
);
354361
}
355362

@@ -380,7 +387,7 @@ mod tests {
380387
};
381388
assert_eq!(
382389
command_to_string(&cargo.command().unwrap()),
383-
"RUSTDOCFLAGS=-Dwarnings cargo doc --package uefi --package xtask --features global_allocator --no-deps --document-private-items --open"
390+
"RUSTDOCFLAGS=-Dwarnings cargo doc --no-default-features --package uefi --package xtask --features global_allocator --no-deps --document-private-items --open"
384391
);
385392
}
386393
}

0 commit comments

Comments
 (0)