Skip to content

Commit

Permalink
test: Make tests not squelch color when being run by bazel. (#4006)
Browse files Browse the repository at this point in the history
What this literally does is sets the `CLICOLOR_FORCE` environment
variable to `true`. This causes terminal output to be colored, if the
test follows [that convention]. In particular, the Rust `colored`
library uses that convention. In particular, canbench uses `colored`.
This makes the output of canbench easier for humans to consume (and we
should really care about humans, such as ourselves).

[that convention]: http://bixense.com/clicolors/
  • Loading branch information
daniel-wong-dfinity-org authored Feb 19, 2025
1 parent 396b461 commit 1767e03
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 4 deletions.
5 changes: 5 additions & 0 deletions bazel/conf/.bazelrc.build
Original file line number Diff line number Diff line change
Expand Up @@ -141,3 +141,8 @@ common --remote_download_all
# This option (in conjunction with remote cache issues) creates build failures
# https://github.com/bazelbuild/bazel/issues/22387
common --noexperimental_inmemory_dotd_files

# This is particularly helpful for canbench, but other tests that follow this
# convention would also benefit. If the test does not support this, this "almost
# certainly" does no harm.
test --test_env=CLICOLOR_FORCE=true
2 changes: 1 addition & 1 deletion rs/ic_os/fstrim_tool/tests/integration_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ fn should_fail_if_arguments_missing() {
.assert()
.stdout(predicate::str::is_empty())
.stderr(predicate::str::contains(
"error: the following required arguments were not provided",
"the following required arguments were not provided",
))
.failure();
}
7 changes: 4 additions & 3 deletions rs/replica/tests/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,10 @@ fn too_many_arguments_causes_exit_code_1() {
new_replica_command()
.args(["arg1", "arg2"])
.assert()
.stderr(predicate::str::starts_with(
"error: unexpected argument 'arg1' found",
))
.stderr(predicate::str::contains("error"))
.stderr(predicate::str::contains("unexpected argument"))
.stderr(predicate::str::contains("arg1"))
.stderr(predicate::str::contains("found"))
.failure();
}

Expand Down

0 comments on commit 1767e03

Please sign in to comment.