mirror of
https://github.com/AleoHQ/leo.git
synced 2024-12-19 07:32:26 +03:00
fixed bug
This commit is contained in:
parent
64c47f8bf9
commit
d0cfa983b5
@ -4,5 +4,5 @@ expectation: Pass
|
||||
outputs:
|
||||
- output:
|
||||
- initial_input_ast: c7315faf1ac3ceeb90260e64e4a411a27a8aa732892a64c15f49e81adf464beb
|
||||
initial_ast: b80eed2960509f11bce6294687558fb7b907f1d83455287f944dfa981ebe1ec8
|
||||
symbol_table: 9d42b1d8f167826635e5169bc3a50c14f722fba8e5ce2480fbde3b8cf2e75237
|
||||
initial_ast: 767d8228dd9818cb115e7369cec91352dd406008981487380e863deb06dc11a0
|
||||
symbol_table: e8029086f943767e4f98014b3991bff8336cb6472c2d2dc3d51b4b13e5c72ea5
|
||||
|
@ -5,5 +5,5 @@ outputs:
|
||||
- output:
|
||||
- initial_input_ast: dc6b4b00185dd6c1f2b83a1bfae619c1d6e3f68ac0f1d3d87ae3bd0ed5caf083
|
||||
- initial_input_ast: 73a38568160c3d2be402043d04ccdc2290abe27647bc81c4bd50367834c206cf
|
||||
initial_ast: 6514080a9452d6e193510250dec3b87081e0741d05cc59ca456f2b2f3f36ec72
|
||||
symbol_table: 7ec407fabcae0eeef889009b8ba99beac3d18b2d79cc49e7760261d80bd59728
|
||||
initial_ast: 31f3fdca173acafc69b0975e91e891bbb27bf6d63bdc986c86b4d22c70d928cc
|
||||
symbol_table: 25f09247dfa86534ff321b8e1b2ca1666c92751d37a611d62e56b8cfac96261d
|
||||
|
@ -5,5 +5,5 @@ outputs:
|
||||
- output:
|
||||
- initial_input_ast: b6371958e735320861c84ed514f258ae8a9858b34615364b2f9ebbaa2aaadd8c
|
||||
- initial_input_ast: d384cfea1a36220e9ea4e246ece89d8fffa320f90aeeb85660bc445ab62a0829
|
||||
initial_ast: 7085f8bf0a01a4fd7b73b5e3fc1c2c812d0cd459a5b6ea85791fc3c01118c7a0
|
||||
symbol_table: 5a12f141aef86a7a00b86650e23cfd9af657d6f418df7b1ee9eab06714305d31
|
||||
initial_ast: d3a4a7e3effdc165649d9e1239ee983eb2385c4b93646472395a05f4df982ca2
|
||||
symbol_table: 5fddde57167344769d00e423fb56692291d57ac8c953c512b82a4626bbdcb6c9
|
||||
|
@ -113,21 +113,19 @@ impl TestCases {
|
||||
let mut configs = Vec::new();
|
||||
|
||||
self.tests = find_tests(&self.path_prefix.clone())
|
||||
.filter(|(path, content)| {
|
||||
let config = match extract_test_config(content) {
|
||||
.filter(|(path, content)| match extract_test_config(content) {
|
||||
None => {
|
||||
self.fail_categories.push(TestFailure {
|
||||
path: path.to_str().unwrap_or("").to_string(),
|
||||
errors: vec![TestError::MissingTestConfig],
|
||||
});
|
||||
return true;
|
||||
true
|
||||
}
|
||||
Some(cfg) => cfg,
|
||||
};
|
||||
|
||||
let res = additional_check(&config);
|
||||
configs.push(config);
|
||||
Some(cfg) => {
|
||||
let res = additional_check(&cfg);
|
||||
configs.push(cfg);
|
||||
res
|
||||
}
|
||||
})
|
||||
.collect();
|
||||
|
||||
@ -155,12 +153,11 @@ impl TestCases {
|
||||
|
||||
output.push(process(self, (path, content, &test_name, config)));
|
||||
|
||||
std::env::remove_var("LEO_TESTFRAMEWORK");
|
||||
}
|
||||
output
|
||||
}
|
||||
|
||||
fn clear_expectations(&self, path: &Path, expectation_category: &str) -> (PathBuf, Option<TestExpectation>) {
|
||||
fn load_expectations(&self, path: &Path, expectation_category: &str) -> (PathBuf, Option<TestExpectation>) {
|
||||
let test_dir = [env!("CARGO_MANIFEST_DIR"), "../../tests/"].iter().collect::<PathBuf>();
|
||||
let relative_path = path.strip_prefix(&test_dir).expect("path error for test");
|
||||
let expectation_path = test_dir
|
||||
@ -168,7 +165,7 @@ impl TestCases {
|
||||
.join(expectation_category)
|
||||
.join(relative_path.parent().expect("no parent dir for test"))
|
||||
.join(relative_path.file_name().expect("no file name for test"))
|
||||
.with_extension("out");
|
||||
.with_extension("leo.out");
|
||||
|
||||
if expectation_path.exists() {
|
||||
if !is_env_var_set("CLEAR_LEO_TEST_EXPECTATIONS") {
|
||||
@ -200,7 +197,7 @@ pub fn run_tests<T: Runner>(runner: &T, expectation_category: &str) {
|
||||
None => return,
|
||||
};
|
||||
|
||||
let (expectation_path, expectations) = cases.clear_expectations(path, expectation_category);
|
||||
let (expectation_path, expectations) = cases.load_expectations(path, expectation_category);
|
||||
|
||||
let tests = match namespace.parse_type() {
|
||||
ParseType::Line => crate::fetch::split_tests_one_line(content)
|
||||
@ -267,6 +264,45 @@ pub fn run_tests<T: Runner>(runner: &T, expectation_category: &str) {
|
||||
})
|
||||
}
|
||||
});
|
||||
|
||||
if !cases.fail_categories.is_empty() {
|
||||
for (i, fail) in cases.fail_categories.iter().enumerate() {
|
||||
println!(
|
||||
"\n\n-----------------TEST #{} FAILED (and shouldn't have)-----------------",
|
||||
i + 1
|
||||
);
|
||||
println!("File: {}", fail.path);
|
||||
for error in &fail.errors {
|
||||
println!("{}", error);
|
||||
}
|
||||
}
|
||||
panic!(
|
||||
"failed {}/{} tests in {}/{} categories",
|
||||
pass_tests,
|
||||
fail_tests + pass_tests,
|
||||
cases.fail_categories.len(),
|
||||
cases.fail_categories.len() + pass_categories
|
||||
);
|
||||
} else {
|
||||
for (path, new_expectation) in outputs {
|
||||
std::fs::create_dir_all(path.parent().unwrap()).expect("failed to make test expectation parent directory");
|
||||
std::fs::write(
|
||||
&path,
|
||||
serde_yaml::to_string(&new_expectation).expect("failed to serialize expectation yaml"),
|
||||
)
|
||||
.expect("failed to write expectation file");
|
||||
}
|
||||
println!(
|
||||
"passed {}/{} tests in {}/{} categories",
|
||||
pass_tests,
|
||||
fail_tests + pass_tests,
|
||||
pass_categories,
|
||||
pass_categories
|
||||
);
|
||||
}
|
||||
|
||||
std::env::remove_var("LEO_TESTFRAMEWORK");
|
||||
|
||||
}
|
||||
|
||||
/// returns (name, content) for all benchmark samples
|
||||
|
Loading…
Reference in New Issue
Block a user