Skip to content

Commit

Permalink
test: make sure do not ignore the UI tests (#494)
Browse files Browse the repository at this point in the history
Found a problem with the test in https://github.com/tokio-rs/console/actions/runs/6988785469/job/19016699616?pr=493.

If the binary does not exist, it will ignore the test cases.

After this change, it will bail out an error.

I moved it to integration tests dir, we don't need to build the binary manually.
  • Loading branch information
Rustin170506 authored Nov 28, 2023
1 parent 8269b5f commit 075ab0c
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 15 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ flags and arguments:
$ tokio-console --help
The Tokio console: a debugger for async Rust.
Usage: tokio-console [OPTIONS] [TARGET_ADDR] [COMMAND]
Usage: tokio-console[EXE] [OPTIONS] [TARGET_ADDR] [COMMAND]
Commands:
gen-config
Expand Down
12 changes: 0 additions & 12 deletions tokio-console/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -778,18 +778,6 @@ mod tests {
Config::command().debug_assert()
}

#[test]
// You can use `TRYCMD=overwrite` to overwrite the expected output.
fn cli_tests() {
// 72 chars seems to fit reasonably in the default width of
// RustDoc's code formatting
// Set the env var COLUMNS to override this.
env::set_var("COLUMNS", "72");
trycmd::TestCases::new()
.case("cli-ui.toml")
.case("../README.md");
}

#[test]
// The example output includes paths, so skip this test on windows. :/
#[cfg_attr(windows, ignore)]
Expand Down
2 changes: 1 addition & 1 deletion tokio-console/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
/// `tokio-console`:
///
/// ```text
#[doc = include_str!("../cli-ui.stdout")]
#[doc = include_str!("../tests/cli-ui.stdout")]
/// ```
///
/// This text can also be displayed by running `tokio-console help`.
Expand Down
23 changes: 23 additions & 0 deletions tokio-console/tests/cli-ui.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
use std::env;

#[test]
// You can use `TRYCMD=overwrite` to overwrite the expected output.
fn cli_tests() {
// 72 chars seems to fit reasonably in the default width of
// RustDoc's code formatting
// Set the env var COLUMNS to override this.
env::set_var("COLUMNS", "72");
// The following might be changed by the test runner, so we
// explicitly set them to known values.
env::set_var("LANG", "en_US.UTF-8");
env::set_var("COLORTERM", "truecolor");

let t = trycmd::TestCases::new();
let console = trycmd::cargo::cargo_bin("tokio-console");
t.register_bin("tokio-console", console);
let readme_path = std::path::Path::new(&std::env::var("CARGO_MANIFEST_DIR").unwrap())
.parent()
.expect("README.md exists in the root of the repo")
.join("README.md");
t.case("tests/cli-ui.toml").case(readme_path);
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
The Tokio console: a debugger for async Rust.

Usage: tokio-console [OPTIONS] [TARGET_ADDR] [COMMAND]
Usage: tokio-console[EXE] [OPTIONS] [TARGET_ADDR] [COMMAND]

Commands:
gen-config
Expand Down
File renamed without changes.

0 comments on commit 075ab0c

Please sign in to comment.