(file: &str)
| 10 | |
| 11 | #[test_resources("src/tests/runtime/*.ab")] |
| 12 | fn test_runtime_errors(file: &str) { |
| 13 | let code = |
| 14 | fs::read_to_string(file).unwrap_or_else(|_| panic!("Failed to open {file} test file")); |
| 15 | |
| 16 | let output = extract_output(&code); |
| 17 | |
| 18 | let re = Regex::new(&format!(r#"(?m)"?{output}"?$"#)).unwrap(); |
| 19 | |
| 20 | let target = AmberCompiler::resolve_target_shell(None); |
| 21 | let options = CompilerOptions::default().with_target(Some(target)); |
| 22 | let mut compiler = AmberCompiler::new(code.to_string(), Some(file.to_string()), options); |
| 23 | |
| 24 | match compiler.test_eval() { |
| 25 | Ok((output, status)) => { |
| 26 | assert!(status.code().unwrap_or(0) > 0); |
| 27 | |
| 28 | assert!( |
| 29 | re.is_match(&output), |
| 30 | "Expected stderr to end with the specific error, but got:\n{:?}", |
| 31 | output |
| 32 | ); |
| 33 | } |
| 34 | _ => panic!("Expected runtime error."), |
| 35 | } |
| 36 | } |
nothing calls this directly
no test coverage detected