diff options
author | Clement Tsang <34804052+ClementTsang@users.noreply.github.com> | 2023-04-21 00:07:34 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-04-21 00:07:34 -0400 |
commit | 3618449d42f4cc5b667d8a9730b5e6fbe43d7dfb (patch) | |
tree | eed612e863ac4762396e5b4204f358aa40cc5210 /tests | |
parent | 3a0cf1624748ce55efbfe1757ff63ffc6ec9f24f (diff) |
deps: update clap to 4.x (#1107)
* deps: update clap to 4.x
* changelog
* fix test
* add gpu feature/flag test
Diffstat (limited to 'tests')
-rw-r--r-- | tests/arg_tests.rs | 23 | ||||
-rw-r--r-- | tests/util.rs | 4 |
2 files changed, 21 insertions, 6 deletions
diff --git a/tests/arg_tests.rs b/tests/arg_tests.rs index 372955da..95e79994 100644 --- a/tests/arg_tests.rs +++ b/tests/arg_tests.rs @@ -93,9 +93,7 @@ fn test_negative_rate() { .arg("-1000") .assert() .failure() - .stderr(predicate::str::contains( - "wasn't expected, or isn't valid in this context", - )); + .stderr(predicate::str::contains("unexpected argument")); } #[test] @@ -160,11 +158,12 @@ fn test_missing_default_widget_type() { .assert() .failure() .stderr(predicate::str::contains( - "The following required arguments were not provided", + "the following required arguments were not provided", )); } #[test] +#[cfg_attr(feature = "battery", ignore)] fn test_battery_flag() { if !cfg!(feature = "battery") { btm_command() @@ -172,7 +171,21 @@ fn test_battery_flag() { .assert() .failure() .stderr(predicate::str::contains( - "'--battery' which wasn't expected", + "unexpected argument '--battery' found", + )); + } +} + +#[test] +#[cfg_attr(feature = "gpu", ignore)] +fn test_gpu_flag() { + if !cfg!(feature = "gpu") { + btm_command() + .arg("--enable_gpu_memory") + .assert() + .failure() + .stderr(predicate::str::contains( + "unexpected argument '--enable_gpu_memory' found", )); } } diff --git a/tests/util.rs b/tests/util.rs index 40e50305..5a9dbc1a 100644 --- a/tests/util.rs +++ b/tests/util.rs @@ -60,13 +60,15 @@ fn cross_runner() -> Option<String> { } } -/// Returns the [`Command`] of a binary invocation of bottom. +/// Returns the [`Command`] of a binary invocation of bottom, alongside +/// any required env variables. pub fn btm_command() -> Command { let btm_exe = env!("CARGO_BIN_EXE_btm"); match cross_runner() { None => Command::new(btm_exe), Some(runner) => { let mut cmd = Command::new(runner); + cmd.env("NO_COLOR", "1"); cmd.arg(btm_exe); cmd } |