From a29eca57a1c047828ce38026a8b65326396129b3 Mon Sep 17 00:00:00 2001 From: Paul Hauner Date: Sun, 3 Mar 2019 15:12:19 +1100 Subject: [PATCH] Rename test_harness::manifest to test_case I thing `TestCase` is better than manifest -- a manifest is more of a list of items than a series of steps and checks. Plus it conflicts with a Cargo manifest. --- .../beacon_chain/test_harness/src/bin.rs | 20 +++++++++---------- .../beacon_chain/test_harness/src/lib.rs | 2 +- .../src/{manifest => test_case}/config.rs | 0 .../src/{manifest => test_case}/mod.rs | 16 +++++++-------- .../src/{manifest => test_case}/results.rs | 2 +- .../{manifest => test_case}/state_check.rs | 2 +- .../{manifest => test_case}/yaml_helpers.rs | 0 7 files changed, 21 insertions(+), 21 deletions(-) rename beacon_node/beacon_chain/test_harness/src/{manifest => test_case}/config.rs (100%) rename beacon_node/beacon_chain/test_harness/src/{manifest => test_case}/mod.rs (94%) rename beacon_node/beacon_chain/test_harness/src/{manifest => test_case}/results.rs (98%) rename beacon_node/beacon_chain/test_harness/src/{manifest => test_case}/state_check.rs (99%) rename beacon_node/beacon_chain/test_harness/src/{manifest => test_case}/yaml_helpers.rs (100%) diff --git a/beacon_node/beacon_chain/test_harness/src/bin.rs b/beacon_node/beacon_chain/test_harness/src/bin.rs index 5411efc4a..b4a2cf05e 100644 --- a/beacon_node/beacon_chain/test_harness/src/bin.rs +++ b/beacon_node/beacon_chain/test_harness/src/bin.rs @@ -1,11 +1,11 @@ use clap::{App, Arg}; use env_logger::{Builder, Env}; -use manifest::Manifest; use std::{fs::File, io::prelude::*}; +use test_case::TestCase; use yaml_rust::YamlLoader; mod beacon_chain_harness; -mod manifest; +mod test_case; mod validator_harness; use validator_harness::ValidatorHarness; @@ -14,12 +14,12 @@ fn main() { let matches = App::new("Lighthouse Test Harness Runner") .version("0.0.1") .author("Sigma Prime ") - .about("Runs `test_harness` using a YAML manifest.") + .about("Runs `test_harness` using a YAML test_case.") .arg( Arg::with_name("yaml") .long("yaml") .value_name("FILE") - .help("YAML file manifest.") + .help("YAML file test_case.") .required(true), ) .get_matches(); @@ -37,21 +37,21 @@ fn main() { }; for doc in &docs { - // For each `test_cases` YAML in the document, build a `Manifest`, execute it and - // assert that the execution result matches the manifest description. + // For each `test_cases` YAML in the document, build a `TestCase`, execute it and + // assert that the execution result matches the test_case description. // // In effect, for each `test_case` a new `BeaconChainHarness` is created from genesis - // and a new `BeaconChain` is built as per the manifest. + // and a new `BeaconChain` is built as per the test_case. // - // After the `BeaconChain` has been built out as per the manifest, a dump of all blocks + // After the `BeaconChain` has been built out as per the test_case, a dump of all blocks // and states in the chain is obtained and checked against the `results` specified in // the `test_case`. // // If any of the expectations in the results are not met, the process // panics with a message. for test_case in doc["test_cases"].as_vec().unwrap() { - let manifest = Manifest::from_yaml(test_case); - manifest.assert_result_valid(manifest.execute()) + let test_case = TestCase::from_yaml(test_case); + test_case.assert_result_valid(test_case.execute()) } } } diff --git a/beacon_node/beacon_chain/test_harness/src/lib.rs b/beacon_node/beacon_chain/test_harness/src/lib.rs index a7ada2433..2303dc064 100644 --- a/beacon_node/beacon_chain/test_harness/src/lib.rs +++ b/beacon_node/beacon_chain/test_harness/src/lib.rs @@ -26,7 +26,7 @@ //! ``` mod beacon_chain_harness; -pub mod manifest; +pub mod test_case; mod validator_harness; pub use self::beacon_chain_harness::BeaconChainHarness; diff --git a/beacon_node/beacon_chain/test_harness/src/manifest/config.rs b/beacon_node/beacon_chain/test_harness/src/test_case/config.rs similarity index 100% rename from beacon_node/beacon_chain/test_harness/src/manifest/config.rs rename to beacon_node/beacon_chain/test_harness/src/test_case/config.rs diff --git a/beacon_node/beacon_chain/test_harness/src/manifest/mod.rs b/beacon_node/beacon_chain/test_harness/src/test_case/mod.rs similarity index 94% rename from beacon_node/beacon_chain/test_harness/src/manifest/mod.rs rename to beacon_node/beacon_chain/test_harness/src/test_case/mod.rs index 7b9c9cb02..f6d8d42e8 100644 --- a/beacon_node/beacon_chain/test_harness/src/manifest/mod.rs +++ b/beacon_node/beacon_chain/test_harness/src/test_case/mod.rs @@ -23,18 +23,18 @@ pub use state_check::StateCheck; /// /// Typical workflow is: /// -/// 1. Instantiate the `Manifest` from YAML: `let manifest = Manifest::from_yaml(&my_yaml);` -/// 2. Execute the manifest: `let result = manifest.execute();` -/// 3. Test the results against the manifest: `manifest.assert_result_valid(result);` +/// 1. Instantiate the `TestCase` from YAML: `let test_case = TestCase::from_yaml(&my_yaml);` +/// 2. Execute the test_case: `let result = test_case.execute();` +/// 3. Test the results against the test_case: `test_case.assert_result_valid(result);` #[derive(Debug)] -pub struct Manifest { +pub struct TestCase { /// Defines the execution. pub config: Config, /// Defines tests to run against the execution result. pub results: Results, } -/// The result of executing a `Manifest`. +/// The result of executing a `TestCase`. /// pub struct ExecutionResult { /// The canonical beacon chain generated from the execution. @@ -43,8 +43,8 @@ pub struct ExecutionResult { pub spec: ChainSpec, } -impl Manifest { - /// Load the manifest from a YAML document. +impl TestCase { + /// Load the test case from a YAML document. pub fn from_yaml(test_case: &Yaml) -> Self { Self { results: Results::from_yaml(&test_case["results"]), @@ -65,7 +65,7 @@ impl Manifest { spec } - /// Executes the manifest, returning an `ExecutionResult`. + /// Executes the test case, returning an `ExecutionResult`. pub fn execute(&self) -> ExecutionResult { let spec = self.spec(); let validator_count = self.config.deposits_for_chain_start; diff --git a/beacon_node/beacon_chain/test_harness/src/manifest/results.rs b/beacon_node/beacon_chain/test_harness/src/test_case/results.rs similarity index 98% rename from beacon_node/beacon_chain/test_harness/src/manifest/results.rs rename to beacon_node/beacon_chain/test_harness/src/test_case/results.rs index d16c91874..596418c0f 100644 --- a/beacon_node/beacon_chain/test_harness/src/manifest/results.rs +++ b/beacon_node/beacon_chain/test_harness/src/test_case/results.rs @@ -3,7 +3,7 @@ use super::yaml_helpers::as_usize; use yaml_rust::Yaml; /// A series of tests to be carried out upon an `ExecutionResult`, returned from executing a -/// `Manifest`. +/// `TestCase`. #[derive(Debug)] pub struct Results { pub num_skipped_slots: Option, diff --git a/beacon_node/beacon_chain/test_harness/src/manifest/state_check.rs b/beacon_node/beacon_chain/test_harness/src/test_case/state_check.rs similarity index 99% rename from beacon_node/beacon_chain/test_harness/src/manifest/state_check.rs rename to beacon_node/beacon_chain/test_harness/src/test_case/state_check.rs index a729811d5..90c622894 100644 --- a/beacon_node/beacon_chain/test_harness/src/manifest/state_check.rs +++ b/beacon_node/beacon_chain/test_harness/src/test_case/state_check.rs @@ -4,7 +4,7 @@ use types::*; use yaml_rust::Yaml; /// Tests to be conducted upon a `BeaconState` object generated during the execution of a -/// `Manifest`. +/// `TestCase`. #[derive(Debug)] pub struct StateCheck { /// Checked against `beacon_state.slot`. diff --git a/beacon_node/beacon_chain/test_harness/src/manifest/yaml_helpers.rs b/beacon_node/beacon_chain/test_harness/src/test_case/yaml_helpers.rs similarity index 100% rename from beacon_node/beacon_chain/test_harness/src/manifest/yaml_helpers.rs rename to beacon_node/beacon_chain/test_harness/src/test_case/yaml_helpers.rs