Skip to content

Commit

Permalink
test(cli): Verify terminal styling
Browse files Browse the repository at this point in the history
This uses a new feature from snapbox that let's us render terminal
styling in SVG files.  This let's us see / visualize ANSI escape codes,
including in github's UI (will render images, including side-by-side
images for diffs).
  • Loading branch information
epage committed Feb 19, 2024
1 parent e7ff7a6 commit 174e03b
Show file tree
Hide file tree
Showing 1,306 changed files with 16,306 additions and 2,682 deletions.
43 changes: 41 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ sha1 = "0.10.6"
sha2 = "0.10.8"
shell-escape = "0.1.5"
supports-hyperlinks = "2.1.0"
snapbox = { version = "0.5.0", features = ["diff", "path"] }
snapbox = { version = "0.5.2", features = ["diff", "path", "term-svg"] }
tar = { version = "0.4.40", default-features = false }
tempfile = "3.9.0"
thiserror = "1.0.56"
Expand Down
1 change: 1 addition & 0 deletions crates/cargo-test-support/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1320,6 +1320,7 @@ impl CargoCommand for snapbox::cmd::Command {
fn cargo_ui() -> Self {
Self::new(cargo_exe())
.with_assert(compare::assert_ui())
.env("CARGO_TERM_COLOR", "always")
.test_env()
}
}
Expand Down
4 changes: 2 additions & 2 deletions tests/testsuite/cargo/help/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@ fn case() {
.arg("--help")
.assert()
.success()
.stdout_matches(file!["stdout.log"])
.stderr_matches(file!["stderr.log"]);
.stdout_matches(file!["stdout.term.svg"])
.stderr_matches(file!["stderr.term.svg"]);
}
Empty file.
20 changes: 20 additions & 0 deletions tests/testsuite/cargo/help/stderr.term.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
40 changes: 0 additions & 40 deletions tests/testsuite/cargo/help/stdout.log

This file was deleted.

102 changes: 102 additions & 0 deletions tests/testsuite/cargo/help/stdout.term.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions tests/testsuite/cargo/z_help/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@ fn case() {
.args(["-Z", "help"])
.assert()
.success()
.stdout_matches(file!["stdout.log"])
.stderr_matches(file!["stderr.log"]);
.stdout_matches(file!["stdout.term.svg"])
.stderr_matches(file!["stderr.term.svg"]);
}
Empty file.
20 changes: 20 additions & 0 deletions tests/testsuite/cargo/z_help/stderr.term.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
38 changes: 0 additions & 38 deletions tests/testsuite/cargo/z_help/stdout.log

This file was deleted.

Loading

0 comments on commit 174e03b

Please sign in to comment.