Skip to content

sed: retain buffered output on runtime errors - #668

Open
Himanshu-singh04 wants to merge 2 commits into
uutils:mainfrom
Himanshu-singh04:fix/649-runtime-output
Open

Himanshu-singh04 wants to merge 2 commits into
uutils:mainfrom
Himanshu-singh04:fix/649-runtime-output

Conversation

@Himanshu-singh04

Copy link
Copy Markdown
Contributor

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.

@codecov

codecov Bot commented Nov 10, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 95.48%. Comparing base (6ae5577) to head (3afcc22).
⚠️ Report is 9 commits behind head on main.

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              
Flag Coverage Δ
macos_latest 96.87% <100.00%> (+0.12%) ⬆️
ubuntu_latest 96.88% <100.00%> (+0.19%) ⬆️
windows_latest 0.00% <0.00%> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@sylvestre

Copy link
Copy Markdown
Contributor

a bunch of jobs are failing

Comment thread src/sed/processor.rs Outdated
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()?;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread src/sed/processor.rs Outdated
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()?;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if this flush fails, the original error is lost, no?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@Himanshu-singh04

Copy link
Copy Markdown
Contributor Author

I checked the two pending Codecov checks on head 3afcc22. All three Code Coverage jobs succeeded, including their Codecov upload steps. Codecov's API shows three merged uploads (Ubuntu, macOS, Windows), a complete report, and 100% patch coverage. However, codecov/patch and codecov/project have remained in_progress on GitHub since November 11.

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

sed - output already produced is lost when a runtime error stops processing

2 participants