Speed up JSMoo tests by including them in the binary
parent
6eb5f42ea4
commit
a5e838dda4
|
@ -12,6 +12,7 @@ checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd"
|
||||||
name = "ferris-boi"
|
name = "ferris-boi"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
|
"include_dir",
|
||||||
"serde",
|
"serde",
|
||||||
"serde_derive",
|
"serde_derive",
|
||||||
"serde_json",
|
"serde_json",
|
||||||
|
@ -33,6 +34,25 @@ version = "0.4.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "2540771e65fc8cb83cd6e8a237f70c319bd5c29f78ed1084ba5d50eeac86f7f9"
|
checksum = "2540771e65fc8cb83cd6e8a237f70c319bd5c29f78ed1084ba5d50eeac86f7f9"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "include_dir"
|
||||||
|
version = "0.7.3"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "18762faeff7122e89e0857b02f7ce6fcc0d101d5e9ad2ad7846cc01d61b7f19e"
|
||||||
|
dependencies = [
|
||||||
|
"include_dir_macros",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "include_dir_macros"
|
||||||
|
version = "0.7.3"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "b139284b5cf57ecfa712bcc66950bb635b31aff41c188e8a4cfc758eca374a3f"
|
||||||
|
dependencies = [
|
||||||
|
"proc-macro2 1.0.67",
|
||||||
|
"quote 1.0.33",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "itoa"
|
name = "itoa"
|
||||||
version = "1.0.6"
|
version = "1.0.6"
|
||||||
|
|
|
@ -15,3 +15,7 @@ serde = "1.0"
|
||||||
serde_json = "1.0"
|
serde_json = "1.0"
|
||||||
serde_derive = "1.0"
|
serde_derive = "1.0"
|
||||||
test-generator = "0.3.0"
|
test-generator = "0.3.0"
|
||||||
|
include_dir = "0.7.3"
|
||||||
|
|
||||||
|
[profile.release]
|
||||||
|
debug = true
|
||||||
|
|
|
@ -1,14 +1,20 @@
|
||||||
use std::fs::File;
|
use std::path::Path;
|
||||||
|
|
||||||
use ferris_boi::cpu::Processor;
|
use ferris_boi::cpu::Processor;
|
||||||
|
use include_dir::{include_dir, Dir};
|
||||||
use test_generator::test_resources;
|
use test_generator::test_resources;
|
||||||
|
|
||||||
use super::TestCase;
|
use super::TestCase;
|
||||||
|
|
||||||
|
const TESTDATA_DIR: Dir<'_> = include_dir!("$CARGO_MANIFEST_DIR/tests/cpu/jsmoo/testdata");
|
||||||
|
|
||||||
#[test_resources("tests/cpu/jsmoo/testdata/*.json")]
|
#[test_resources("tests/cpu/jsmoo/testdata/*.json")]
|
||||||
fn test_jsmoo_test(filename: &str) {
|
fn test_jsmoo_test(filename: &str) {
|
||||||
let testdata_file = File::open(filename).expect("failed to open test data file");
|
let basename = Path::new(filename).file_name().unwrap();
|
||||||
let test_cases = serde_json::from_reader::<_, Vec<TestCase>>(testdata_file)
|
let testdata_file = TESTDATA_DIR
|
||||||
|
.get_file(basename)
|
||||||
|
.expect("could not find data file");
|
||||||
|
let test_cases = serde_json::from_slice::<Vec<TestCase>>(testdata_file.contents())
|
||||||
.expect("failed to parse test data file");
|
.expect("failed to parse test data file");
|
||||||
|
|
||||||
for test_case in test_cases {
|
for test_case in test_cases {
|
||||||
|
|
Loading…
Reference in New Issue