more updates for kcl-samples (#5696)
* screenshots and step Signed-off-by: Jess Frazelle <github@jessfraz.com> * automations Signed-off-by: Jess Frazelle <github@jessfraz.com> * add manifest generation Signed-off-by: Jess Frazelle <github@jessfraz.com> * small refactor Signed-off-by: Jess Frazelle <github@jessfraz.com> * update readme Signed-off-by: Jess Frazelle <github@jessfraz.com> * write the readme Signed-off-by: Jess Frazelle <github@jessfraz.com> * fixes for comments Signed-off-by: Jess Frazelle <github@jessfraz.com> * derive-docs tests updates Signed-off-by: Jess Frazelle <github@jessfraz.com> * update all the generated artifact commands, since we dont need to clear scene at the start of run so we dont need to recreate all the planes Signed-off-by: Jess Frazelle <github@jessfraz.com> * updates Signed-off-by: Jess Frazelle <github@jessfraz.com> * updates Signed-off-by: Jess Frazelle <github@jessfraz.com> * updates Signed-off-by: Jess Frazelle <github@jessfraz.com> * updates Signed-off-by: Jess Frazelle <github@jessfraz.com> --------- Signed-off-by: Jess Frazelle <github@jessfraz.com>
This commit is contained in:
@ -26,6 +26,9 @@ struct Test {
|
||||
output_dir: PathBuf,
|
||||
}
|
||||
|
||||
pub(crate) const RENDERED_MODEL_NAME: &str = "rendered_model.png";
|
||||
//pub(crate) const EXPORTED_STEP_NAME: &str = "exported_step.step";
|
||||
|
||||
impl Test {
|
||||
fn new(name: &str) -> Self {
|
||||
Self {
|
||||
@ -116,10 +119,10 @@ fn unparse_test(test: &Test) {
|
||||
}
|
||||
|
||||
async fn execute(test_name: &str, render_to_png: bool) {
|
||||
execute_test(&Test::new(test_name), render_to_png).await
|
||||
execute_test(&Test::new(test_name), render_to_png, false).await
|
||||
}
|
||||
|
||||
async fn execute_test(test: &Test, render_to_png: bool) {
|
||||
async fn execute_test(test: &Test, render_to_png: bool, export_step: bool) {
|
||||
// Read the AST from disk.
|
||||
let input = read("ast.snap", &test.output_dir);
|
||||
let ast_res: Result<Node<Program>, KclError> = get(&input);
|
||||
@ -136,16 +139,26 @@ async fn execute_test(test: &Test, render_to_png: bool) {
|
||||
ast,
|
||||
crate::settings::types::UnitLength::Mm,
|
||||
Some(test.input_dir.join(&test.entry_point)),
|
||||
export_step,
|
||||
)
|
||||
.await;
|
||||
match exec_res {
|
||||
Ok((exec_state, env_ref, png)) => {
|
||||
Ok((exec_state, env_ref, png, step)) => {
|
||||
let fail_path = test.output_dir.join("execution_error.snap");
|
||||
if std::fs::exists(&fail_path).unwrap() {
|
||||
panic!("This test case is expected to fail, but it passed. If this is intended, and the test should actually be passing now, please delete kcl-lib/{}", fail_path.to_string_lossy())
|
||||
}
|
||||
if render_to_png {
|
||||
twenty_twenty::assert_image(test.output_dir.join("rendered_model.png"), &png, 0.99);
|
||||
twenty_twenty::assert_image(test.output_dir.join(RENDERED_MODEL_NAME), &png, 0.99);
|
||||
}
|
||||
if export_step {
|
||||
let step = step.unwrap();
|
||||
// TODO FIXME: This is failing because the step file is not deterministic.
|
||||
// But it should be, talk to @katie
|
||||
/*assert_snapshot(test, "Step file", || {
|
||||
insta::assert_binary_snapshot!(EXPORTED_STEP_NAME, step);
|
||||
});*/
|
||||
std::fs::write(test.output_dir.join("exported_step.snap.step"), step).unwrap();
|
||||
}
|
||||
let outcome = exec_state.to_wasm_outcome(env_ref);
|
||||
assert_common_snapshots(
|
||||
@ -179,7 +192,7 @@ async fn execute_test(test: &Test, render_to_png: bool) {
|
||||
Box::new(miette::MietteHandlerOpts::new().show_related_errors_as_nested().build())
|
||||
}))
|
||||
.unwrap();
|
||||
let report = error.clone().into_miette_report_with_outputs().unwrap();
|
||||
let report = error.clone().into_miette_report_with_outputs(&input).unwrap();
|
||||
let report = miette::Report::new(report);
|
||||
if previously_passed {
|
||||
eprintln!("This test case failed, but it previously passed. If this is intended, and the test should actually be failing now, please delete kcl-lib/{} and other associated passing artifacts", ok_path.to_string_lossy());
|
||||
|
Reference in New Issue
Block a user