MCPcopy Create free account
hub / github.com/bytecodealliance/wasmtime / run

Method run

cranelift/filetests/src/test_verifier.rs:40–92  ·  view source on GitHub ↗
(&self, func: Cow<Function>, context: &Context)

Source from the content-addressed store, hash-verified

38 }
39
40 fn run(&self, func: Cow<Function>, context: &Context) -> anyhow::Result<()> {
41 let func = func.borrow();
42
43 // Scan source annotations for "error:" directives.
44 let mut expected = Vec::new();
45
46 for comment in &context.details.comments {
47 if let Some(tail) = match_directive(comment.text, "error:") {
48 expected.push((comment.entity, tail));
49 }
50 }
51
52 match verify_function(func, context.flags_or_isa()) {
53 Ok(()) if expected.is_empty() => Ok(()),
54 Ok(()) => anyhow::bail!("passed, but expected errors: {expected:?}"),
55
56 Err(ref errors) if expected.is_empty() => {
57 anyhow::bail!("expected no error, but got:\n{errors}");
58 }
59
60 Err(errors) => {
61 let mut errors = errors.0;
62 let mut msg = String::new();
63
64 // For each expected error, find a suitable match.
65 for expect in expected {
66 let pos = errors
67 .iter()
68 .position(|err| err.location == expect.0 && err.message.contains(expect.1));
69
70 match pos {
71 None => {
72 writeln!(msg, " expected error {}: {}", expect.0, expect.1).unwrap();
73 }
74 Some(pos) => {
75 errors.swap_remove(pos);
76 }
77 }
78 }
79
80 // Report remaining errors.
81 for err in errors {
82 writeln!(msg, "unexpected error {err}").unwrap();
83 }
84
85 if msg.is_empty() {
86 Ok(())
87 } else {
88 anyhow::bail!("{msg}");
89 }
90 }
91 }
92 }
93}

Callers

nothing calls this directly

Calls 13

match_directiveFunction · 0.85
verify_functionFunction · 0.85
OkFunction · 0.85
flags_or_isaMethod · 0.80
newFunction · 0.50
borrowMethod · 0.45
pushMethod · 0.45
is_emptyMethod · 0.45
positionMethod · 0.45
iterMethod · 0.45
containsMethod · 0.45
unwrapMethod · 0.45

Tested by

no test coverage detected