tests: Extract TestOptions::read() for parsing a file
This commit is contained in:
parent
316df5b415
commit
ff8506d351
|
@ -4383,6 +4383,7 @@ dependencies = [
|
||||||
name = "tests"
|
name = "tests"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
|
"anyhow",
|
||||||
"approx",
|
"approx",
|
||||||
"env_logger",
|
"env_logger",
|
||||||
"futures",
|
"futures",
|
||||||
|
|
|
@ -29,6 +29,7 @@ serde = "1.0"
|
||||||
toml = "0.5.10"
|
toml = "0.5.10"
|
||||||
libtest-mimic = "0.6.0"
|
libtest-mimic = "0.6.0"
|
||||||
walkdir = "2.3.2"
|
walkdir = "2.3.2"
|
||||||
|
anyhow = "1.0"
|
||||||
|
|
||||||
[[test]]
|
[[test]]
|
||||||
name = "tests"
|
name = "tests"
|
||||||
|
|
|
@ -1,7 +1,10 @@
|
||||||
|
use anyhow::Result;
|
||||||
use approx::assert_relative_eq;
|
use approx::assert_relative_eq;
|
||||||
use regex::Regex;
|
use regex::Regex;
|
||||||
use ruffle_core::{Player, ViewportDimensions};
|
use ruffle_core::{Player, ViewportDimensions};
|
||||||
use serde::Deserialize;
|
use serde::Deserialize;
|
||||||
|
use std::fs;
|
||||||
|
use std::path::Path;
|
||||||
use std::sync::{Arc, Mutex};
|
use std::sync::{Arc, Mutex};
|
||||||
use std::time::Duration;
|
use std::time::Duration;
|
||||||
|
|
||||||
|
@ -29,6 +32,12 @@ impl Default for TestOptions {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl TestOptions {
|
||||||
|
pub fn read<P: AsRef<Path>>(path: P) -> Result<Self> {
|
||||||
|
Ok(toml::from_str(&fs::read_to_string(path)?)?)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#[derive(Deserialize, Default)]
|
#[derive(Deserialize, Default)]
|
||||||
#[serde(default)]
|
#[serde(default)]
|
||||||
pub struct Approximations {
|
pub struct Approximations {
|
||||||
|
|
|
@ -25,7 +25,6 @@ use ruffle_render_wgpu::backend::WgpuRenderBackend;
|
||||||
use ruffle_render_wgpu::{target::TextureTarget, wgpu};
|
use ruffle_render_wgpu::{target::TextureTarget, wgpu};
|
||||||
use std::cell::RefCell;
|
use std::cell::RefCell;
|
||||||
use std::collections::BTreeMap;
|
use std::collections::BTreeMap;
|
||||||
use std::fs;
|
|
||||||
use std::path::Path;
|
use std::path::Path;
|
||||||
use std::rc::Rc;
|
use std::rc::Rc;
|
||||||
use std::sync::{Arc, Mutex};
|
use std::sync::{Arc, Mutex};
|
||||||
|
@ -701,8 +700,7 @@ fn main() {
|
||||||
.map(Result::unwrap)
|
.map(Result::unwrap)
|
||||||
.filter(|entry| entry.file_type().is_file() && entry.file_name() == "test.toml")
|
.filter(|entry| entry.file_type().is_file() && entry.file_name() == "test.toml")
|
||||||
.map(|file| {
|
.map(|file| {
|
||||||
let options: TestOptions =
|
let options = TestOptions::read(file.path()).unwrap();
|
||||||
toml::from_str(&fs::read_to_string(&file.path()).unwrap()).unwrap();
|
|
||||||
let test_dir = file.path().parent().unwrap().to_owned();
|
let test_dir = file.path().parent().unwrap().to_owned();
|
||||||
let name = test_dir
|
let name = test_dir
|
||||||
.strip_prefix(root)
|
.strip_prefix(root)
|
||||||
|
|
Loading…
Reference in New Issue