From 7dc02244515ed819c69a8ce6715e07da56426ebc Mon Sep 17 00:00:00 2001 From: Nathan Adams Date: Thu, 27 Jul 2023 09:44:08 +0200 Subject: [PATCH] tests: Add lzma feature and add a required_features.lzma flag --- .github/workflows/test_rust.yml | 2 +- tests/Cargo.toml | 1 + tests/README.md | 4 ++++ tests/tests/util/options.rs | 14 ++++++++++++++ tests/tests/util/test.rs | 3 ++- 5 files changed, 22 insertions(+), 2 deletions(-) diff --git a/.github/workflows/test_rust.yml b/.github/workflows/test_rust.yml index d10f190b8..4f97d56ed 100644 --- a/.github/workflows/test_rust.yml +++ b/.github/workflows/test_rust.yml @@ -76,7 +76,7 @@ jobs: RUSTDOCFLAGS: -D warnings - name: Run tests with image tests - run: cargo test --all --locked --features imgtests + run: cargo test --all --locked --features imgtests,lzma env: XDG_RUNTIME_DIR: '' # dummy value, just to silence warnings about it missing diff --git a/tests/Cargo.toml b/tests/Cargo.toml index ccd0dc725..b7c3e74f0 100644 --- a/tests/Cargo.toml +++ b/tests/Cargo.toml @@ -24,6 +24,7 @@ url = "2.3.1" # since the images we compare against are generated on CI, and may # not match your local machine's Vulkan version / image output. imgtests = ["ruffle_video_software"] +lzma = ["ruffle_core/lzma"] [dev-dependencies] approx = "0.5.1" diff --git a/tests/README.md b/tests/README.md index d297ef271..e62b2e70c 100644 --- a/tests/README.md +++ b/tests/README.md @@ -46,6 +46,10 @@ with_video = false # If this test requires a video decoder backend to run. [image_comparison] tolerance = 0 # The tolerance per pixel channel to be considered "the same". Increase as needed with tests that aren't pixel perfect across platforms. max_outliers = 0 # Maximum number of outliers allowed over the given tolerance levels. Increase as needed with tests that aren't pixel perfect across platforms. + +# Which build features are required for this test to run. +[required_features] +lzma = false # If LZMA support is enabled in this build ``` ## Frame-based tests diff --git a/tests/tests/util/options.rs b/tests/tests/util/options.rs index bfcc45328..f2d1bbfc3 100644 --- a/tests/tests/util/options.rs +++ b/tests/tests/util/options.rs @@ -26,6 +26,7 @@ pub struct TestOptions { pub approximations: Option, pub player_options: PlayerOptions, pub log_fetch: bool, + pub required_features: RequiredFeatures, } impl Default for TestOptions { @@ -42,6 +43,7 @@ impl Default for TestOptions { approximations: None, player_options: PlayerOptions::default(), log_fetch: false, + required_features: RequiredFeatures::default(), } } } @@ -89,6 +91,18 @@ impl Approximations { } } +#[derive(Deserialize, Default)] +#[serde(default, deny_unknown_fields)] +pub struct RequiredFeatures { + lzma: bool, +} + +impl RequiredFeatures { + pub fn can_run(&self) -> bool { + !self.lzma || cfg!(feature = "lzma") + } +} + #[derive(Deserialize, Default)] #[serde(default, deny_unknown_fields)] pub struct PlayerOptions { diff --git a/tests/tests/util/test.rs b/tests/tests/util/test.rs index fad693f99..53c295cb6 100644 --- a/tests/tests/util/test.rs +++ b/tests/tests/util/test.rs @@ -71,7 +71,8 @@ impl Test { if self.options.ignore { return false; } - self.options.player_options.can_run(check_renderer) + self.options.required_features.can_run() + && self.options.player_options.can_run(check_renderer) } pub fn compare_output(&self, actual_output: &str) -> Result<()> {