From 2b8e8ce59e6e60254bb3f14e5dd7a572c68216c8 Mon Sep 17 00:00:00 2001 From: Paul Hauner Date: Wed, 15 May 2019 11:15:34 +1000 Subject: [PATCH] Replace `TestDoc` with `Doc` --- .../src/{test_case_result.rs => case_result.rs} | 0 tests/ef_tests/src/{test_doc.rs => doc.rs} | 11 +++++------ .../src/{test_doc_cases.rs => doc_cases.rs} | 4 ++-- .../{test_doc_cases => doc_cases}/ssz_generic.rs | 2 +- .../{test_doc_cases => doc_cases}/ssz_static.rs | 2 +- .../src/{test_doc_header.rs => doc_header.rs} | 2 +- tests/ef_tests/src/lib.rs | 16 ++++++++-------- tests/ef_tests/tests/tests.rs | 8 ++++---- 8 files changed, 22 insertions(+), 23 deletions(-) rename tests/ef_tests/src/{test_case_result.rs => case_result.rs} (100%) rename tests/ef_tests/src/{test_doc.rs => doc.rs} (84%) rename tests/ef_tests/src/{test_doc_cases.rs => doc_cases.rs} (89%) rename tests/ef_tests/src/{test_doc_cases => doc_cases}/ssz_generic.rs (98%) rename tests/ef_tests/src/{test_doc_cases => doc_cases}/ssz_static.rs (99%) rename tests/ef_tests/src/{test_doc_header.rs => doc_header.rs} (89%) diff --git a/tests/ef_tests/src/test_case_result.rs b/tests/ef_tests/src/case_result.rs similarity index 100% rename from tests/ef_tests/src/test_case_result.rs rename to tests/ef_tests/src/case_result.rs diff --git a/tests/ef_tests/src/test_doc.rs b/tests/ef_tests/src/doc.rs similarity index 84% rename from tests/ef_tests/src/test_doc.rs rename to tests/ef_tests/src/doc.rs index 99427779e..a32cfedfc 100644 --- a/tests/ef_tests/src/test_doc.rs +++ b/tests/ef_tests/src/doc.rs @@ -4,11 +4,11 @@ use std::{fs::File, io::prelude::*, path::PathBuf}; use types::{EthSpec, FoundationEthSpec}; #[derive(Debug, Deserialize)] -pub struct TestDoc { +pub struct Doc { pub yaml: String, } -impl TestDoc { +impl Doc { fn from_path(path: PathBuf) -> Self { let mut file = File::open(path).unwrap(); @@ -21,7 +21,7 @@ impl TestDoc { pub fn get_test_results(path: PathBuf) -> Vec { let doc = Self::from_path(path); - let header: TestDocHeader = serde_yaml::from_str(&doc.yaml.as_str()).unwrap(); + let header: DocHeader = serde_yaml::from_str(&doc.yaml.as_str()).unwrap(); match ( header.runner.as_ref(), @@ -54,12 +54,11 @@ impl TestDoc { pub fn run_test(test_doc_yaml: &String) -> Vec where - TestDocCases: Test + serde::de::DeserializeOwned + YamlDecode, + DocCases: Test + serde::de::DeserializeOwned + YamlDecode, { let test_cases_yaml = extract_yaml_by_key(test_doc_yaml, "test_cases"); - let test_cases: TestDocCases = - TestDocCases::yaml_decode(&test_cases_yaml.to_string()).unwrap(); + let test_cases: DocCases = DocCases::yaml_decode(&test_cases_yaml.to_string()).unwrap(); test_cases.test::() } diff --git a/tests/ef_tests/src/test_doc_cases.rs b/tests/ef_tests/src/doc_cases.rs similarity index 89% rename from tests/ef_tests/src/test_doc_cases.rs rename to tests/ef_tests/src/doc_cases.rs index 199222cf4..6c87f17c4 100644 --- a/tests/ef_tests/src/test_doc_cases.rs +++ b/tests/ef_tests/src/doc_cases.rs @@ -9,11 +9,11 @@ pub use ssz_generic::*; pub use ssz_static::*; #[derive(Debug, Deserialize)] -pub struct TestDocCases { +pub struct DocCases { pub test_cases: Vec, } -impl YamlDecode for TestDocCases { +impl YamlDecode for DocCases { /// Decodes a YAML list of test cases fn yaml_decode(yaml: &String) -> Result { let doc = &YamlLoader::load_from_str(yaml).unwrap()[0]; diff --git a/tests/ef_tests/src/test_doc_cases/ssz_generic.rs b/tests/ef_tests/src/doc_cases/ssz_generic.rs similarity index 98% rename from tests/ef_tests/src/test_doc_cases/ssz_generic.rs rename to tests/ef_tests/src/doc_cases/ssz_generic.rs index 9585332ac..2074e76bb 100644 --- a/tests/ef_tests/src/test_doc_cases/ssz_generic.rs +++ b/tests/ef_tests/src/doc_cases/ssz_generic.rs @@ -16,7 +16,7 @@ impl YamlDecode for SszGeneric { } } -impl Test for TestDocCases { +impl Test for DocCases { fn test(&self) -> Vec { self.test_cases .iter() diff --git a/tests/ef_tests/src/test_doc_cases/ssz_static.rs b/tests/ef_tests/src/doc_cases/ssz_static.rs similarity index 99% rename from tests/ef_tests/src/test_doc_cases/ssz_static.rs rename to tests/ef_tests/src/doc_cases/ssz_static.rs index 8b07ac645..a8f904406 100644 --- a/tests/ef_tests/src/test_doc_cases/ssz_static.rs +++ b/tests/ef_tests/src/doc_cases/ssz_static.rs @@ -41,7 +41,7 @@ impl SszStatic { } } -impl Test for TestDocCases { +impl Test for DocCases { fn test(&self) -> Vec { self.test_cases .iter() diff --git a/tests/ef_tests/src/test_doc_header.rs b/tests/ef_tests/src/doc_header.rs similarity index 89% rename from tests/ef_tests/src/test_doc_header.rs rename to tests/ef_tests/src/doc_header.rs index f605e85bb..6bd33c5cb 100644 --- a/tests/ef_tests/src/test_doc_header.rs +++ b/tests/ef_tests/src/doc_header.rs @@ -1,7 +1,7 @@ use super::*; #[derive(Debug, Deserialize)] -pub struct TestDocHeader { +pub struct DocHeader { pub title: String, pub summary: String, pub forks_timeline: String, diff --git a/tests/ef_tests/src/lib.rs b/tests/ef_tests/src/lib.rs index c028c6c12..430502f7a 100644 --- a/tests/ef_tests/src/lib.rs +++ b/tests/ef_tests/src/lib.rs @@ -4,18 +4,18 @@ use serde_derive::Deserialize; use ssz::Decode; use std::fmt::Debug; +pub use crate::case_result::*; +pub use crate::doc::*; +pub use crate::doc_cases::*; +pub use crate::doc_header::*; pub use crate::error::*; pub use crate::eth_specs::*; -pub use crate::test_case_result::*; -pub use crate::test_doc::*; -pub use crate::test_doc_cases::*; -pub use crate::test_doc_header::*; pub use yaml_decode::YamlDecode; +mod case_result; +mod doc; +mod doc_cases; +mod doc_header; mod error; mod eth_specs; -mod test_case_result; -mod test_doc; -mod test_doc_cases; -mod test_doc_header; mod yaml_decode; diff --git a/tests/ef_tests/tests/tests.rs b/tests/ef_tests/tests/tests.rs index 70966dc90..51083ae47 100644 --- a/tests/ef_tests/tests/tests.rs +++ b/tests/ef_tests/tests/tests.rs @@ -21,17 +21,17 @@ mod ssz_generic { #[test] fn uint_bounds() { - TestDoc::assert_tests_pass(ssz_generic_file("uint/uint_bounds.yaml")); + Doc::assert_tests_pass(ssz_generic_file("uint/uint_bounds.yaml")); } #[test] fn uint_random() { - TestDoc::assert_tests_pass(ssz_generic_file("uint/uint_random.yaml")); + Doc::assert_tests_pass(ssz_generic_file("uint/uint_random.yaml")); } #[test] fn uint_wrong_length() { - TestDoc::assert_tests_pass(ssz_generic_file("uint/uint_wrong_length.yaml")); + Doc::assert_tests_pass(ssz_generic_file("uint/uint_wrong_length.yaml")); } } @@ -48,6 +48,6 @@ mod ssz_static { #[test] fn minimal_nil() { - TestDoc::assert_tests_pass(ssz_generic_file("core/ssz_minimal_nil.yaml")); + Doc::assert_tests_pass(ssz_generic_file("core/ssz_minimal_nil.yaml")); } }