ef_tests: skipped tests and bls_setting support

This commit is contained in:
Michael Sproul 2019-06-11 18:06:15 +10:00
parent 4024a400c8
commit c649988189
No known key found for this signature in database
GPG Key ID: 77B1309D2E54E914
5 changed files with 58 additions and 3 deletions

View File

@ -15,6 +15,7 @@ hex = "0.3"
rayon = "1.0" rayon = "1.0"
serde = "1.0" serde = "1.0"
serde_derive = "1.0" serde_derive = "1.0"
serde_repr = "0.1"
serde_yaml = "0.8" serde_yaml = "0.8"
ssz = { path = "../../eth2/utils/ssz" } ssz = { path = "../../eth2/utils/ssz" }
tree_hash = { path = "../../eth2/utils/tree_hash" } tree_hash = { path = "../../eth2/utils/tree_hash" }

View File

@ -0,0 +1,30 @@
use self::BlsSetting::*;
use crate::error::Error;
use serde_repr::Deserialize_repr;
// TODO: use this in every test case
#[derive(Deserialize_repr, Debug, Clone, Copy)]
#[repr(u8)]
pub enum BlsSetting {
Flexible = 0,
Required = 1,
Ignored = 2,
}
impl Default for BlsSetting {
fn default() -> Self {
Flexible
}
}
impl BlsSetting {
/// Check the BLS setting and skip the test if it isn't compatible with the crypto config.
pub fn check(self) -> Result<(), Error> {
match self {
Flexible => Ok(()),
Required if !cfg!(feature = "fake_crypto") => Ok(()),
Ignored if cfg!(feature = "fake_crypto") => Ok(()),
_ => Err(Error::Skipped),
}
}
}

View File

@ -146,7 +146,14 @@ where
pub fn print_failures(doc: &Doc, results: &[CaseResult]) { pub fn print_failures(doc: &Doc, results: &[CaseResult]) {
let header: DocHeader = serde_yaml::from_str(&doc.header_yaml).unwrap(); let header: DocHeader = serde_yaml::from_str(&doc.header_yaml).unwrap();
let failures: Vec<&CaseResult> = results.iter().filter(|r| r.result.is_err()).collect(); let failures: Vec<&CaseResult> = results
.iter()
.filter(|r| r.result.as_ref().err().map_or(false, |e| !e.is_skipped()))
.collect();
let skipped: Vec<&CaseResult> = results
.iter()
.filter(|r| r.result.as_ref().err().map_or(false, |e| e.is_skipped()))
.collect();
println!("--------------------------------------------------"); println!("--------------------------------------------------");
println!("Test Failure"); println!("Test Failure");
@ -154,13 +161,18 @@ pub fn print_failures(doc: &Doc, results: &[CaseResult]) {
println!("File: {:?}", doc.path); println!("File: {:?}", doc.path);
println!(""); println!("");
println!( println!(
"{} tests, {} failures, {} passes.", "{} tests, {} failures, {} skipped, {} passes.",
results.len(), results.len(),
failures.len(), failures.len(),
results.len() - failures.len() skipped.len(),
results.len() - skipped.len() - failures.len()
); );
println!(""); println!("");
for case in skipped {
println!("-------");
println!("case[{}] ({}) skipped", case.case_index, case.desc);
}
for failure in failures { for failure in failures {
let error = failure.result.clone().unwrap_err(); let error = failure.result.clone().unwrap_err();

View File

@ -6,6 +6,8 @@ pub enum Error {
DidntFail(String), DidntFail(String),
/// Failed to parse the test (internal error). /// Failed to parse the test (internal error).
FailedToParseTest(String), FailedToParseTest(String),
/// Skipped the test.
Skipped,
} }
impl Error { impl Error {
@ -14,6 +16,7 @@ impl Error {
Error::NotEqual(_) => "NotEqual", Error::NotEqual(_) => "NotEqual",
Error::DidntFail(_) => "DidntFail", Error::DidntFail(_) => "DidntFail",
Error::FailedToParseTest(_) => "FailedToParseTest", Error::FailedToParseTest(_) => "FailedToParseTest",
Error::Skipped => "Skipped",
} }
} }
@ -22,6 +25,14 @@ impl Error {
Error::NotEqual(m) => m.as_str(), Error::NotEqual(m) => m.as_str(),
Error::DidntFail(m) => m.as_str(), Error::DidntFail(m) => m.as_str(),
Error::FailedToParseTest(m) => m.as_str(), Error::FailedToParseTest(m) => m.as_str(),
Error::Skipped => panic!(), // "Skipped",
}
}
pub fn is_skipped(&self) -> bool {
match self {
Error::Skipped => true,
_ => false,
} }
} }
} }

View File

@ -6,6 +6,7 @@ pub use doc::Doc;
pub use error::Error; pub use error::Error;
pub use yaml_decode::YamlDecode; pub use yaml_decode::YamlDecode;
mod bls_setting;
mod case_result; mod case_result;
mod cases; mod cases;
mod doc; mod doc;