Skip to content

Commit 1847342

Browse files
committed
tests: Deny unknown fields when deserializing test.toml files
This will catch typos and misplaced options when modifying tests.
1 parent b00628f commit 1847342

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed

render/src/backend.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -207,6 +207,7 @@ pub enum Context3DCommand<'gc> {
207207
pub struct ShapeHandle(pub usize);
208208

209209
#[derive(Copy, Clone, Debug, Serialize, Deserialize)]
210+
#[serde(deny_unknown_fields)]
210211
pub struct ViewportDimensions {
211212
/// The dimensions of the stage's containing viewport.
212213
pub width: u32,

tests/tests/util/options.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ use std::path::{Path, PathBuf};
1010
use std::time::Duration;
1111

1212
#[derive(Deserialize)]
13-
#[serde(default)]
13+
#[serde(default, deny_unknown_fields)]
1414
pub struct TestOptions {
1515
pub num_frames: u32,
1616
pub output_path: PathBuf,
@@ -46,7 +46,7 @@ impl TestOptions {
4646
}
4747

4848
#[derive(Deserialize, Default)]
49-
#[serde(default)]
49+
#[serde(default, deny_unknown_fields)]
5050
pub struct Approximations {
5151
number_patterns: Vec<String>,
5252
epsilon: Option<f64>,
@@ -79,7 +79,7 @@ impl Approximations {
7979
}
8080

8181
#[derive(Deserialize, Default)]
82-
#[serde(default)]
82+
#[serde(default, deny_unknown_fields)]
8383
pub struct PlayerOptions {
8484
max_execution_duration: Option<Duration>,
8585
viewport_dimensions: Option<ViewportDimensions>,
@@ -142,7 +142,7 @@ impl PlayerOptions {
142142
}
143143

144144
#[derive(Deserialize, Default)]
145-
#[serde(default)]
145+
#[serde(default, deny_unknown_fields)]
146146
pub struct ImageComparison {
147147
tolerance: u8,
148148
max_outliers: usize,
@@ -226,7 +226,7 @@ impl ImageComparison {
226226
}
227227

228228
#[derive(Deserialize)]
229-
#[serde(default)]
229+
#[serde(default, deny_unknown_fields)]
230230
pub struct RenderOptions {
231231
optional: bool,
232232
sample_count: u32,

0 commit comments

Comments
 (0)