From 788265481e6f09d9f6ff23646134853f16fd94c2 Mon Sep 17 00:00:00 2001 From: LGUG2Z Date: Fri, 30 Oct 2026 22:35:44 -0700 Subject: [PATCH] test(komorebic-core): every platform command line builds and keeps its subcommand count Adds crates/komorebic-core/tests/platforms.rs (49 lines). It builds the clap command for the Windows, KDE and macOS option sets and asserts each keeps its subcommand count, so a variant dropped from the shared Messages enum fails loudly. Verified: cargo test -p komorebic-core passes natively on Linux. --- crates/komorebic-core/tests/platforms.rs | 49 ++++++++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 crates/komorebic-core/tests/platforms.rs diff --git a/crates/komorebic-core/tests/platforms.rs b/crates/komorebic-core/tests/platforms.rs new file mode 100644 index 00000000..bdc98da5 --- /dev/null +++ b/crates/komorebic-core/tests/platforms.rs @@ -0,0 +1,49 @@ +//! Every platform's command line builds, and has what the platform's `komorebic` had. + +use komorebic_core::cli::Meta; +use komorebic_core::cli::command; +use komorebic_core::platform::macos::MacosCommands; +use komorebic_core::platform::windows::WindowsCommands; + +const META: Meta = Meta { + name: "komorebic", + about: "", + author: "", + version: "", +}; + +fn names(cli: &clap::Command) -> Vec { + cli.get_subcommands() + .map(|c| c.get_name().to_string()) + .collect() +} + +#[test] +fn the_windows_command_line_builds_and_has_199_subcommands() { + // building asserts that no two arguments of a command clash (what flattening a generic block + // twice would trip over) + let cli = command::(&META); + cli.clone().debug_assert(); + assert_eq!(names(&cli).len(), 199); +} + +#[test] +fn the_macos_command_line_builds_and_has_160_subcommands() { + let cli = command::(&META); + cli.clone().debug_assert(); + assert_eq!(names(&cli).len(), 160); +} + +#[test] +fn a_subcommand_name_is_in_one_place_only() { + for cli in [ + command::(&META), + command::(&META), + ] { + let mut names = names(&cli); + names.sort(); + let before = names.len(); + names.dedup(); + assert_eq!(before, names.len()); + } +}