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

Function run_filecheck

cranelift/filetests/src/subtest.rs:113–138  ·  view source on GitHub ↗

Run filecheck on `text`, using directives extracted from `context`.

(text: &str, context: &Context)

Source from the content-addressed store, hash-verified

111
112/// Run filecheck on `text`, using directives extracted from `context`.
113pub fn run_filecheck(text: &str, context: &Context) -> anyhow::Result<()> {
114 log::debug!(
115 "Filecheck Input:\n\
116 =======================\n\
117 {text}\n\
118 ======================="
119 );
120 let checker = build_filechecker(context)?;
121 if checker
122 .check(text, NO_VARIABLES)
123 .context("filecheck failed")?
124 {
125 Ok(())
126 } else {
127 // Filecheck mismatch. Emit an explanation as output.
128 let (_, explain) = checker
129 .explain(text, NO_VARIABLES)
130 .context("filecheck explain failed")?;
131 anyhow::bail!(
132 "filecheck failed for function on line {}:\n{}{}",
133 context.details.location.line_number,
134 checker,
135 explain
136 );
137 }
138}
139
140/// Build a filechecker using the directives in the file preamble and the function's comments.
141pub fn build_filechecker(context: &Context) -> anyhow::Result<Checker> {

Callers 10

runMethod · 0.85
runMethod · 0.85
runMethod · 0.85
runMethod · 0.85
runMethod · 0.85
runMethod · 0.85
runMethod · 0.85
runMethod · 0.85
runMethod · 0.85
runMethod · 0.85

Calls 4

build_filecheckerFunction · 0.85
OkFunction · 0.85
checkMethod · 0.80
contextMethod · 0.45

Tested by

no test coverage detected