Load `path` and run the test in it. If running this test causes a panic, it will propagate as normal.
(
path: &Path,
passes: Option<&[String]>,
target: Option<&str>,
)
| 20 | /// |
| 21 | /// If running this test causes a panic, it will propagate as normal. |
| 22 | pub fn run( |
| 23 | path: &Path, |
| 24 | passes: Option<&[String]>, |
| 25 | target: Option<&str>, |
| 26 | ) -> anyhow::Result<time::Duration> { |
| 27 | let _tt = timing::process_file(); |
| 28 | info!("---\nFile: {}", path.to_string_lossy()); |
| 29 | let started = time::Instant::now(); |
| 30 | let buffer = |
| 31 | fs::read_to_string(path).with_context(|| format!("failed to read {}", path.display()))?; |
| 32 | |
| 33 | let options = ParseOptions { |
| 34 | target, |
| 35 | passes, |
| 36 | machine_code_cfg_info: true, |
| 37 | ..ParseOptions::default() |
| 38 | }; |
| 39 | |
| 40 | let testfile = match parse_test(&buffer, options) { |
| 41 | Ok(testfile) => testfile, |
| 42 | Err(e) => { |
| 43 | if e.is_warning { |
| 44 | log::warn!( |
| 45 | "skipping test {:?} (line {}): {}", |
| 46 | path, |
| 47 | e.location.line_number, |
| 48 | e.message |
| 49 | ); |
| 50 | return Ok(started.elapsed()); |
| 51 | } |
| 52 | return Err(e).context(format!("failed to parse {}", path.display())); |
| 53 | } |
| 54 | }; |
| 55 | |
| 56 | if testfile.functions.is_empty() { |
| 57 | anyhow::bail!("no functions found"); |
| 58 | } |
| 59 | |
| 60 | // Parse the test commands. |
| 61 | let mut tests = testfile |
| 62 | .commands |
| 63 | .iter() |
| 64 | .map(new_subtest) |
| 65 | .collect::<anyhow::Result<Vec<_>>>()?; |
| 66 | |
| 67 | // Flags to use for those tests that don't need an ISA. |
| 68 | // This is the cumulative effect of all the `set` commands in the file. |
| 69 | let flags = match testfile.isa_spec { |
| 70 | IsaSpec::None(ref f) => f, |
| 71 | IsaSpec::Some(ref v) => v.last().expect("Empty ISA list").flags(), |
| 72 | }; |
| 73 | |
| 74 | // Sort the tests so the mutators are at the end, and those that don't need the verifier are at |
| 75 | // the front. |
| 76 | tests.sort_by_key(|st| (st.is_mutating(), st.needs_verifier())); |
| 77 | |
| 78 | // Expand the tests into (test, flags, isa) tuples. |
| 79 | let tuples = test_tuples(&tests, &testfile.isa_spec, flags)?; |
nothing calls this directly
no test coverage detected