| 1 | //! Exit codes that need no Bluetooth (CLAUDE.md, "Exit codes"). |
| 2 | |
| 3 | // Test-only file: helpers may panic (clippy.toml exempts only #[test] functions themselves). |
| 4 | #![allow(clippy::unwrap_used, clippy::expect_used, clippy::indexing_slicing)] |
| 5 | |
| 6 | use std::process::Command; |
| 7 | |
| 8 | fn budctl(args: &[&str]) -> std::process::Output { |
| 9 | Command::new(env!("CARGO_BIN_EXE_budctl")).args(args).output().unwrap() |
| 10 | } |
| 11 | |
| 12 | #[test] |
| 13 | fn help_and_version_exit_0() { |
| 14 | for flag in ["--help", "--version"] { |
| 15 | let out = budctl(&[flag]); |
| 16 | assert_eq!(out.status.code(), Some(0), "{flag}"); |
| 17 | assert!(!out.stdout.is_empty(), "{flag}"); |
| 18 | } |
| 19 | } |
| 20 | |
| 21 | #[test] |
| 22 | fn usage_errors_exit_1() { |
| 23 | for args in [&["frobnicate"][..], &[], &["--device", "not-a-mac", "status"]] { |
| 24 | let out = budctl(args); |
| 25 | assert_eq!(out.status.code(), Some(1), "{args:?}"); |
| 26 | } |
| 27 | } |