tests: Add lzma feature and add a required_features.lzma flag

This commit is contained in:
Nathan Adams 2023-07-27 09:44:08 +02:00
parent 08b7a8c498
commit 7dc0224451
5 changed files with 22 additions and 2 deletions

View File

@ -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

View File

@ -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"

View File

@ -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

View File

@ -26,6 +26,7 @@ pub struct TestOptions {
pub approximations: Option<Approximations>,
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 {

View File

@ -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<()> {