Skip to content

Commit 5f6b806

Browse files
test(cts): replace --quiet and --verbose with --print-output-when
2 parents 95ed11c + 3c6ef47 commit 5f6b806

10 files changed

Lines changed: 72 additions & 33 deletions

File tree

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ env:
1919
#
2020

2121
# This is the MSRV used by `wgpu` itself and all surrounding infrastructure.
22-
REPO_MSRV: "1.92"
22+
REPO_MSRV: "1.93"
2323
# This is the MSRV used by the `wgpu-core`, `wgpu-hal`, and `wgpu-types` crates,
2424
# to ensure that they can be used with firefox.
2525
CORE_MSRV: "1.82.0"

.github/workflows/cts.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ env:
1717
CARGO_INCREMENTAL: false
1818
CARGO_TERM_COLOR: always
1919
RUST_BACKTRACE: full
20-
MSRV: "1.92"
20+
MSRV: "1.93"
2121

2222
# Every time a PR is pushed to, cancel any previous jobs. This
2323
# makes us behave nicer to github and get faster turnaround times

.github/workflows/docs.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ on:
1515

1616
env:
1717
# This is the MSRV used by `wgpu` itself and all surrounding infrastructure.
18-
REPO_MSRV: "1.92"
18+
REPO_MSRV: "1.93"
1919

2020
CARGO_INCREMENTAL: false
2121
CARGO_TERM_COLOR: always

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ ref_as_ptr = "warn"
5656

5757
[workspace.package]
5858
edition = "2021"
59-
rust-version = "1.92"
59+
rust-version = "1.93"
6060
keywords = ["graphics"]
6161
license = "MIT OR Apache-2.0"
6262
homepage = "https://wgpu.rs/"

examples/standalone/01_hello_compute/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[package]
22
name = "wgpu-example-01-hello-compute"
33
edition = "2021"
4-
rust-version = "1.92"
4+
rust-version = "1.93"
55
publish = false
66

77
[dependencies]

examples/standalone/02_hello_window/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[package]
22
name = "wgpu-example-02-hello-window"
33
edition = "2021"
4-
rust-version = "1.92"
4+
rust-version = "1.93"
55
publish = false
66

77
[dependencies]

examples/standalone/custom_backend/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[package]
22
name = "wgpu-example-custom-backend"
33
edition = "2021"
4-
rust-version = "1.92"
4+
rust-version = "1.93"
55
publish = false
66

77
[features]

rust-toolchain.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
[toolchain]
2-
channel = "1.92"
2+
channel = "1.93"
33
components = ["rustfmt", "clippy"]
44
targets = ["wasm32-unknown-unknown"]

xtask/src/cts.rs

Lines changed: 57 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,8 @@
3030
//! Lines starting with `//` or `#` in the test list are treated as comments and
3131
//! ignored.
3232
33-
use anyhow::{bail, Context};
33+
use anyhow::{anyhow, bail, Context};
34+
use core::fmt;
3435
use pico_args::Arguments;
3536
use regex_lite::{Regex, RegexBuilder};
3637
use std::{ffi::OsString, sync::LazyLock};
@@ -56,6 +57,12 @@ struct TestLine {
5657
pub fails_if: Vec<String>,
5758
}
5859

60+
#[derive(Clone, Copy, Debug)]
61+
enum PrintOutputWhen {
62+
TestFails,
63+
Always,
64+
}
65+
5966
pub fn run_cts(
6067
shell: Shell,
6168
mut args: Arguments,
@@ -64,8 +71,31 @@ pub fn run_cts(
6471
let skip_checkout = args.contains("--skip-checkout");
6572
let llvm_cov = args.contains("--llvm-cov");
6673
let release = args.contains("--release");
67-
let mut quiet = args.contains("--quiet");
68-
let verbose = args.contains("--verbose");
74+
75+
let output_filter = args
76+
.opt_value_from_str::<_, String>("--print-output-when")?
77+
.map(|f| {
78+
let values = [
79+
("test-fails", PrintOutputWhen::TestFails),
80+
("always", PrintOutputWhen::Always),
81+
];
82+
let lowered = f.to_ascii_lowercase();
83+
values
84+
.iter()
85+
.find_map(|(cli_str, enum_value)| (&*lowered == *cli_str).then_some(*enum_value))
86+
.ok_or_else(|| {
87+
anyhow!(
88+
"`{f}` is not a valid `--print-output-when` value; expected one of {}",
89+
fmt::from_fn(|f| {
90+
f.debug_list()
91+
.entries(values.iter().map(|(cli, _enum)| cli))
92+
.finish()
93+
})
94+
)
95+
})
96+
})
97+
.transpose()?;
98+
6999
let running_on_backend = args.opt_value_from_str::<_, String>("--backend")?;
70100
let mut filter_pattern = args.opt_value_from_str::<_, String>("--filter")?;
71101
let mut filter_invert = false;
@@ -107,18 +137,21 @@ pub fn run_cts(
107137
})
108138
.collect::<Vec<_>>();
109139

140+
let mut default_output_filter = PrintOutputWhen::Always;
141+
110142
if tests.is_empty() && list_files.is_empty() {
111143
if passthrough_args.is_none() {
112144
log::info!("Reading default test list from {CTS_DEFAULT_TEST_LIST}");
113145
list_files.push(OsString::from(CTS_DEFAULT_TEST_LIST));
114146

115-
// Reduce output, unless `--verbose` was specified.
116-
quiet = !verbose;
147+
default_output_filter = PrintOutputWhen::TestFails;
117148
}
118149
} else if passthrough_args.is_some() {
119150
bail!("Test(s) and test list(s) are incompatible with passthrough arguments.");
120151
}
121152

153+
let output_filter = output_filter.unwrap_or(default_output_filter);
154+
122155
for file in list_files {
123156
tests.extend(shell.read_file(file)?.lines().filter_map(|line| {
124157
static TEST_LINE_REGEX: LazyLock<Regex> = LazyLock::new(|| {
@@ -309,7 +342,7 @@ pub fn run_cts(
309342
}
310343
}
311344

312-
if !quiet {
345+
if let PrintOutputWhen::Always = output_filter {
313346
log::info!("Running {}", test.selector.to_string_lossy());
314347
}
315348

@@ -328,26 +361,29 @@ pub fn run_cts(
328361
.args(["--", "./tools/run_deno", "--verbose"])
329362
.args([&test.selector]);
330363

331-
if quiet {
332-
let output = cmd.ignore_status().output().context("Failed to run CTS")?;
333-
let stdout = String::from_utf8_lossy(&output.stdout);
334-
let stderr = String::from_utf8_lossy(&output.stderr);
335-
336-
if output.status.success() {
337-
if let Some((_, summary)) = stdout.split_once("** Summary **") {
338-
println!("\n== Summary for {} ==", test.selector.to_string_lossy());
339-
println!("{}", summary.trim());
364+
match output_filter {
365+
PrintOutputWhen::TestFails => {
366+
let output = cmd.ignore_status().output().context("Failed to run CTS")?;
367+
let stdout = String::from_utf8_lossy(&output.stdout);
368+
let stderr = String::from_utf8_lossy(&output.stderr);
369+
370+
if output.status.success() {
371+
if let Some((_, summary)) = stdout.split_once("** Summary **") {
372+
println!("\n== Summary for {} ==", test.selector.to_string_lossy());
373+
println!("{}", summary.trim());
374+
} else {
375+
print!("{}", stdout);
376+
eprint!("{}", stderr);
377+
}
340378
} else {
341379
print!("{}", stdout);
342380
eprint!("{}", stderr);
381+
bail!("CTS failed");
343382
}
344-
} else {
345-
print!("{}", stdout);
346-
eprint!("{}", stderr);
347-
bail!("CTS failed");
348383
}
349-
} else {
350-
cmd.run().context("CTS failed")?;
384+
PrintOutputWhen::Always => {
385+
cmd.run().context("CTS failed")?;
386+
}
351387
}
352388
}
353389

xtask/src/main.rs

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,9 @@ Commands:
2222
cts [<options>] [<test selector...> | -f <test list file...> | -- <args...>]
2323
Check out, build, and run CTS tests
2424
25-
If no command-line arguments are specified, runs the default test list
26-
in `cts_runner/test.lst`, with quiet mode enabled.
25+
If no command-line arguments are specified, runs as if `cts
26+
cts_runner/test.lst --print-output-when=test-fails` were
27+
specified.
2728
2829
--skip-checkout Don't check out the pinned CTS version, use whatever
2930
is already checked out.
@@ -34,8 +35,10 @@ Commands:
3435
--filter <regex> Filter tests by selector using a regex pattern.
3536
Prefix with '!' to invert (exclude matching tests).
3637
Applied after all tests are collected.
37-
--quiet Only show test counts for suites without failures.
38-
--verbose Show full output when running the default test list.
38+
--print-output-when One of `test-fails` or `always`. When no `test
39+
selector`, `test list file`, or `args` are
40+
specified, this defaults to `test-fails`. Otherwise,
41+
this defaults to `always`.
3942
4043
run-wasm
4144
Build and run web examples

0 commit comments

Comments
 (0)