(output: &[&str], context: &Context)
| 197 | } |
| 198 | |
| 199 | fn 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 | } |
no test coverage detected