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.
This commit is contained in:
Paul Hauner 2019-03-03 15:12:19 +11:00
parent 48fc709109
commit a29eca57a1
No known key found for this signature in database
GPG Key ID: D362883A9218FCC6
7 changed files with 21 additions and 21 deletions

View File

@ -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 <contact@sigmaprime.io>")
.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())
}
}
}

View File

@ -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;

View File

@ -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;

View File

@ -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<usize>,

View File

@ -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`.