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

Function update_test

cranelift/filetests/src/subtest.rs:199–234  ·  view source on GitHub ↗
(output: &[&str], context: &Context)

Source from the content-addressed store, hash-verified

197}
198
199fn update_test(output: &[&str], context: &Context) -> Result<()> {
200 context
201 .file_update
202 .update_at(&context.details.location, |new_test, old_test| {
203 // blank newline after the function
204 new_test.push_str("\n");
205
206 // Splice in the test output
207 for output in output {
208 new_test.push(';');
209 if !output.is_empty() {
210 new_test.push(' ');
211 new_test.push_str(output);
212 }
213 new_test.push_str("\n");
214 }
215
216 // blank newline after test assertion
217 new_test.push_str("\n");
218
219 // Drop all remaining commented lines (presumably the old test expectation),
220 // but after we hit a real line then we push all remaining lines.
221 let mut in_next_function = false;
222 for line in old_test {
223 if !in_next_function
224 && (line.trim().is_empty()
225 || (line.starts_with(";") && !line.starts_with(";;")))
226 {
227 continue;
228 }
229 in_next_function = true;
230 new_test.push_str(line);
231 new_test.push_str("\n");
232 }
233 })
234}

Callers 1

check_precise_outputFunction · 0.85

Calls 4

update_atMethod · 0.80
push_strMethod · 0.45
pushMethod · 0.45
is_emptyMethod · 0.45

Tested by

no test coverage detected