Repository navigation
sed: retain buffered output on runtime errors - #668
Himanshu-singh04 wants to merge 2 commits into
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #668 +/- ##
==========================================
+ Coverage 95.25% 95.48% +0.23%
==========================================
Files 14 14
Lines 7500 7683 +183
Branches 442 458 +16
==========================================
+ Hits 7144 7336 +192
+ Misses 355 346 -9
Partials 1 1
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
|
a bunch of jobs are failing |
| context.input_name = path; | ||
| process_file(commands.clone(), &mut reader, output, context)?; | ||
| if let Err(error) = process_file(commands.clone(), &mut reader, output, context) { | ||
| output.flush()?; |
There was a problem hiding this comment.
what about the w files? named_writer::flush_all() is skipped on error too
please flush them as well and add a test (e.g. w out with an error on line 3)
There was a problem hiding this comment.
I added named_writer::flush_all() to the runtime-error path in 3afcc22. I also added a test using w with an error on line 3. It reads the output file before the test thread exits, so it verifies that the error path actually flushed it.
| context.input_name = path; | ||
| process_file(commands.clone(), &mut reader, output, context)?; | ||
| if let Err(error) = process_file(commands.clone(), &mut reader, output, context) { | ||
| output.flush()?; |
There was a problem hiding this comment.
if this flush fails, the original error is lost, no?
There was a problem hiding this comment.
Yes—that was true of the earlier output.flush()? code. In 3afcc22, both flushes are now best-effort, and the function returns the original processing error even if either flush fails. I added a Linux-only /dev/full regression test for this; it still needs to run in CI.
|
I checked the two pending Codecov checks on head Could a maintainer refresh these stale Codecov checks or advise on the preferred way to get their statuses updated? I haven't changed the code or rerun the workflow because the coverage report itself is complete. |
Fixes #649.
Flush the current output buffer before returning a processing error, preserving output from earlier lines on pipes and redirected stdout.
Add a regression that triggers an error on line 3 and checks that lines 1 and 2 remain in stdout. It failed on main and passes with this change.
Validation:
cargo test --offline --quiet;cargo fmt --check;cargo clippy --offline --all-targets -- -D warnings;git diff --check.