1use std::{2 fs, io,3 path::{Path, PathBuf},4};56use jrsonnet_evaluator::{7 trace::{CompactFormat, TraceFormat},8 FileImportResolver, State, Val,9};10use jrsonnet_stdlib::StateExt;1112mod common;1314fn run(file: &Path) {15 let s = State::default();16 s.with_stdlib();17 common::with_test(&s);18 s.set_import_resolver(FileImportResolver::default());19 let trace_format = CompactFormat::default();2021 match s.import(file) {22 Ok(Val::Bool(true)) => {}23 Ok(Val::Bool(false)) => panic!("test {} returned false", file.display()),24 Ok(_) => panic!("test {} returned wrong type as result", file.display()),25 Err(e) => panic!(26 "test {} failed:\n{}",27 file.display(),28 trace_format.format(&e).unwrap()29 ),30 };31}3233#[test]34fn test() -> io::Result<()> {35 let mut root = PathBuf::from(env!("CARGO_MANIFEST_DIR"));36 root.push("suite");3738 for entry in fs::read_dir(&root)? {39 let entry = entry?;40 if !entry.path().extension().map_or(false, |e| e == "jsonnet") {41 continue;42 }4344 run(&entry.path());45 }4647 Ok(())48}