Open source Loom alternative. Beautiful, shareable screen recordings.
Rust appcapcossloommacnextjsnextjs15open-sourceossreactrecordrustscreen-capturescreen-recorderscreenshotsolidjstauritauri-apptypescriptvite
test(verify): Windows and Linux triage: unsupported outcome, decoder and adapter notes
Richie McIlroy0e89f1701851
diff --git a/crates/verify/src/report.rs b/crates/verify/src/report.rsindex 92b57b74d..4d0e421a9 100644--- a/crates/verify/src/report.rs+++ b/crates/verify/src/report.rs@@ -59,6 +59,9 @@ pub struct Case {/// Failure classes seen (see `expectations.toml`).pub classes: std::collections::BTreeSet<String>,pub notes: Vec<String>,+ /// Set when this runner cannot run the case at all (for example no+ /// D3D11 video device for Media Foundation on a GPU-less Windows VM).+ pub unsupported: Option<String>,}impl Case {@@ -72,6 +75,22 @@ impl Case {problems: Vec::new(),classes: Default::default(),notes: Vec::new(),+ unsupported: None,+ }+ }++ /// Marks the case as impossible on this machine. With+ /// `CAP_VERIFY_REQUIRE_SUPPORTED=1` (runners that must have every path)+ /// it is a failure of class `unsupported` instead.+ pub fn unsupported(&mut self, reason: impl Into<String>) {+ let reason = reason.into();+ if std::env::var("CAP_VERIFY_REQUIRE_SUPPORTED").as_deref() == Ok("1") {+ self.problem(+ "unsupported",+ format!("unsupported on this machine: {reason}"),+ );+ } else {+ self.unsupported = Some(reason);}}@@ -236,7 +255,9 @@ pub fn settle(case: Case) -> Result<CaseResult, String> {.iter().filter(|x| !x.flaky && !case.classes.contains(&x.class)).collect();- let outcome = if !unexpected.is_empty() {+ let outcome = if case.unsupported.is_some() && !failed {+ "unsupported"+ } else if !unexpected.is_empty() {"FAIL"} else if !fixed.is_empty() {"XPASS"@@ -245,7 +266,9 @@ pub fn settle(case: Case) -> Result<CaseResult, String> {} else {"pass"};- let mut summary = if failed {+ let mut summary = if let Some(reason) = case.unsupported.as_ref().filter(|_| !failed) {+ format!("not run: {reason}")+ } else if failed {case.problems.join("\n ")} else {let streams: Vec<String> = case@@ -272,7 +295,7 @@ pub fn settle(case: Case) -> Result<CaseResult, String> {id: case.id.clone(),platform: platform().to_string(),tier: tier(),- passed: blessing || matches!(outcome, "pass" | "xfail"),+ passed: blessing || matches!(outcome, "pass" | "xfail" | "unsupported"),summary: summary.clone(),streams: case.streams,notes: case.notes,diff --git a/crates/verify/tests/common/mod.rs b/crates/verify/tests/common/mod.rsindex e003bb50f..8023db473 100644--- a/crates/verify/tests/common/mod.rs+++ b/crates/verify/tests/common/mod.rs@@ -180,17 +180,66 @@ pub fn check_decoders(case: &mut Case, decoder: Decoder, segments: &[cap_editor:let kind = status.decoder_type.to_string();used.push(format!("{stream}{i}={kind}"));if !kind.starts_with(decoder.expected_type()) {- case.problem(format!(- "segment {i} {stream} decoded by {kind}, expected {} (fallback reason: {})",- decoder.expected_type(),- status.fallback_reason.as_deref().unwrap_or("none")- ));+ case.problem(+ "decoder-fallback",+ format!(+ "segment {i} {stream} decoded by {kind}, expected {} (fallback reason: {})",+ decoder.expected_type(),+ status.fallback_reason.as_deref().unwrap_or("none")+ ),+ );}}}case.note(format!("decoders: {}", used.join(" ")));}+/// Why `decoder` cannot run on this machine at all, probed once per+/// process. Only Windows has such a case: the Media Foundation decoder+/// needs a D3D11 device with video support, which GPU-less VMs (hosted CI+/// runners, where D3D11 falls back to WARP) cannot create, so the product+/// falls back to FFmpeg there. Any other Media Foundation failure stays a+/// `decoder-fallback` test failure.+pub fn decoder_unsupported(project: &Project, decoder: Decoder) -> Option<String> {+ if decoder != Decoder::Default || !cfg!(target_os = "windows") {+ return None;+ }+ static PROBE: std::sync::OnceLock<Option<String>> = std::sync::OnceLock::new();+ PROBE+ .get_or_init(|| {+ let meta = project.meta.studio_meta()?;+ let segments = runtime()+ .block_on(cap_editor::create_segments(&project.meta, meta, false))+ .ok()?;+ let reason = segments+ .first()?+ .decoders+ .screen_decoder_status()+ .fallback_reason+ .clone()?;+ reason.contains("D3D11CreateDevice").then(|| {+ format!(+ "Media Foundation needs a D3D11 device with video support and this machine has none (WARP has no video decode): {reason}"+ )+ })+ })+ .clone()+}++/// Starts a case, or settles it as unsupported and returns `None` when this+/// machine cannot run `decoder` (see [`decoder_unsupported`]).+pub fn begin(id: &str, project: &Project, decoder: Decoder) -> Option<Case> {+ let mut case = Case::new(id);+ if let Some(reason) = decoder_unsupported(project, decoder) {+ case.unsupported(reason);+ if case.unsupported.is_some() {+ let _ = report::settle(case);+ return None;+ }+ }+ Some(case)+}+/// Opens the project's decoders the way the exporter does and checks them./// The exporter's own decoders are private, so this probes the same/// `create_segments` decision on the same files.@@ -200,7 +249,7 @@ pub async fn probe_decoders(case: &mut Case, project: &Project, decoder: Decoder};match cap_editor::create_segments(&project.meta, meta, decoder == Decoder::Ffmpeg).await {Ok(segments) => check_decoders(case, decoder, &segments),- Err(e) => case.problem(format!("decoder probe failed: {e}")),+ Err(e) => case.problem("error", format!("decoder probe failed: {e}")),}}@@ -472,6 +521,15 @@ impl Player {/// mid-run fallback is caught too).pub fn check_decoders(&self, case: &mut Case, decoder: Decoder) {check_decoders(case, decoder, &self.segments);+ case.note(format!(+ "render adapter: {}{}",+ self.constants.adapter_name(),+ if self.constants.is_software_adapter {+ " (software)"+ } else {+ ""+ }+ ));}pub fn prefer_sequential(&self) {diff --git a/crates/verify/tests/export.rs b/crates/verify/tests/export.rsindex ea8898ff1..2fb403d6a 100644--- a/crates/verify/tests/export.rs+++ b/crates/verify/tests/export.rs@@ -7,7 +7,7 @@ use cap_project::{ProjectConfiguration, SceneMode, SceneSegment};use cap_verify::{catalog,fixture::FixtureSpec,- report::{self, Case, Tier},+ report::{self, Tier},};use common::{Decoder, ExportRun, Format};@@ -68,7 +68,9 @@ fn run_project(let mut config = project.config();(variant.apply)(&mut config);let model = project.model(&config);- let mut case = Case::new(&id);+ let Some(mut case) = common::begin(&id, &project, decoder) else {+ continue;+ };let dir = common::scratch_dir(&id);let ext = match format {Format::Gif => "gif",diff --git a/crates/verify/tests/playback.rs b/crates/verify/tests/playback.rsindex 926e142d6..94c419af6 100644--- a/crates/verify/tests/playback.rs+++ b/crates/verify/tests/playback.rs@@ -9,7 +9,7 @@ use cap_project::ProjectConfiguration;use cap_verify::{catalog,fixture::{FixtureSpec, Rng},- report::{self, Case, Tier},+ report::{self, Tier},};use common::Decoder;@@ -70,7 +70,9 @@ fn sequential_project(let model = project.model(&config);let total = model.output_frames(fps);let first = (f64::from(total) * start_fraction) as u32;- let mut case = Case::new(&id);+ let Some(mut case) = common::begin(&id, &project, decoder) else {+ continue;+ };let frames: Vec<u32> = (first..total).collect();let result = rt.block_on(async {let mut player = common::Player::open(&project, config, decoder, RES).await?;diff --git a/crates/verify/tests/seek.rs b/crates/verify/tests/seek.rsindex 03503d738..aaeba017c 100644--- a/crates/verify/tests/seek.rs+++ b/crates/verify/tests/seek.rs@@ -9,7 +9,7 @@ use cap_verify::{catalog,fixture::{FixtureSpec, Rng},media,- report::{self, Case, Tier},+ report::{self, Tier},};use common::{Decoder, Player};@@ -47,7 +47,9 @@ fn run_project(edit(&mut config);let model = project.model(&config);let requests = make(model.output_frames(fps), &project);- let mut case = Case::new(&id);+ let Some(mut case) = common::begin(&id, &project, decoder) else {+ continue;+ };case.note(format!("{} requests", requests.len()));let result = rt.block_on(async {let mut player = Player::open(&project, config, decoder, RES).await?;@@ -298,7 +300,9 @@ fn cold_open() {.iter().map(|p| (f64::from(total - 1) * p) as u32).collect();- let mut case = Case::new(&id);+ let Some(mut case) = common::begin(&id, &project, decoder) else {+ continue;+ };let mut readouts = Vec::new();for &frame in &frames {let result = rt.block_on(async {