canonical / multipass

Multipass orchestrates virtual Ubuntu instances
https://multipass.run
GNU General Public License v3.0
7.51k stars 632 forks source link

Refine utilities to `make_file_with_content` #3548

Closed ricab closed 1 week ago

ricab commented 2 weeks ago

This PR improves error handling around writing files via make_file_with_content().

There are actually two versions of make_file_with_content() before this PR: one in utils, one in tests. One started as a copy-paste of the other, then they drifter apart. Entropy always increases... That is fixed here (not entropy increasing unfortunately).

But what prompted this was this failure. That might arise if the test file is not properly flushed when closed, as that error would go undetected. This refines the implementation of make_file_with_content by calling QFile::flush() directly and checking the return. It also adds more details when QFile detects an error.

One further improvement is left for another occasion.

codecov[bot] commented 2 weeks ago

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Project coverage is 88.85%. Comparing base (62c4fc6) to head (06b6b8f). Report is 28 commits behind head on main.

Additional details and impacted files ```diff @@ Coverage Diff @@ ## main #3548 +/- ## ========================================== + Coverage 88.82% 88.85% +0.03% ========================================== Files 253 253 Lines 14121 14173 +52 ========================================== + Hits 12543 12594 +51 - Misses 1578 1579 +1 ```

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.