Skip to content

Commit

Permalink
Auto merge of #13461 - epage:snapbox, r=weihanglo
Browse files Browse the repository at this point in the history
test(cli): Verify terminal styling

### What does this PR try to resolve?

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).

### How should we test and review this PR?

Potential concerns
- assert-rs/snapbox#257: If the snapshot file doesn't exist, you need to `SNAPSHOTS=overwrite` twice
- #9012: because we narrow the enabling of colors to cargo via `CARGO_TERM_COLOR`, clap doesn't know about it and those are rendered without color
- File size: `du -ch tests` reported 13MB before and after
- Loss of information: this doesn't yet include links but we already weren't snapshotting these
- Unconditionally turning on styling and snapshotting for it for all "ui" tests
- Too many SVGs in one PR can negatively affect github's UI

### Additional information
  • Loading branch information
bors committed Feb 23, 2024
2 parents 98079d9 + b14a70f commit 2b302a5
Show file tree
Hide file tree
Showing 791 changed files with 11,354 additions and 2,436 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.6", 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 @@ -1326,6 +1326,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
2 changes: 1 addition & 1 deletion tests/testsuite/cargo/help/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@ fn case() {
.arg("--help")
.assert()
.success()
.stdout_matches(file!["stdout.log"])
.stdout_matches(file!["stdout.term.svg"])
.stderr_matches(str![""]);
}
40 changes: 0 additions & 40 deletions tests/testsuite/cargo/help/stdout.log

This file was deleted.

106 changes: 106 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.
2 changes: 1 addition & 1 deletion tests/testsuite/cargo/z_help/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@ fn case() {
.args(["-Z", "help"])
.assert()
.success()
.stdout_matches(file!["stdout.log"])
.stdout_matches(file!["stdout.term.svg"])
.stderr_matches(str![""]);
}
38 changes: 0 additions & 38 deletions tests/testsuite/cargo/z_help/stdout.log

This file was deleted.

Loading

0 comments on commit 2b302a5

Please sign in to comment.