Skip to content

Conversation

@brian-pane
Copy link

No description provided.

Copy link
Member

@folkertdev folkertdev left a comment

Choose a reason for hiding this comment

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

Mostly looks good

  • I think it'll be more convenient to use Result for private functions that return "success or failure"
  • there are some blocks that are not covered by tests. This is mostly just fyi, and can be fixed later, but if it's easy to fix now, all the better.

Comment on lines 825 to 832
// No gzip header. If we were decoding gzip before, the remaining bytes
// are trailing garbage that can be ignored.
if !state.direct {
state.stream.avail_in = 0;
state.eof = true;
state.have = 0;
return 0;
}
Copy link
Member

Choose a reason for hiding this comment

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

this block is not currently hit by tests

Copy link
Author

Choose a reason for hiding this comment

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

I was able to cover the other blocks with new tests. This one got messy enough that I put in a FIXME comment for now. The cleanest way to get the GzState into the proper state to trigger this block is probably to finish implementing the read+decompress support, and then create a gzip file with junk content at the end.

@brian-pane
Copy link
Author

Thanks for reviewing, I'll post an update later today. Do you have a recommended test coverage measurement tool? I'm looking for something I can easily run locally.

@folkertdev
Copy link
Member

Yes, we use cargo llvm-cov test --open (or --html to just update the html and not open a (new) browser tab). see https://crates.io/crates/cargo-llvm-cov/0.1.13#installation for how to install that.

@brian-pane
Copy link
Author

Is it considered okay to do file I/O from unit tests within libz-rs-sys/src/gz.rs, and to add a directory libz-rs-sys/src/test-data, similar to what's in test-libz-rs-sys? (Some of the branches I want to cover with unit tests are difficult to trigger from outside the crate.)

@folkertdev
Copy link
Member

Let's go with that for now, and then see if there is a more elegant way. It might be possible to e.g. fake a file descriptor in some cases, or expose some testing functions with an additional feature flag to test-libz-rs-sys.

@codecov
Copy link

codecov bot commented Apr 14, 2025

Codecov Report

Attention: Patch coverage is 89.65517% with 30 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
libz-rs-sys/src/gz.rs 89.65% 30 Missing ⚠️
Flag Coverage Δ
test-aarch64-apple-darwin 89.45% <51.72%> (?)
test-x86_64-apple-darwin 87.62% <51.72%> (?)
test-x86_64-unknown-linux-gnu 90.07% <89.65%> (?)

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

Files with missing lines Coverage Δ
libz-rs-sys/src/gz.rs 94.88% <89.65%> (+7.95%) ⬆️

... and 39 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@brian-pane brian-pane force-pushed the gz branch 2 times, most recently from eb8ae1a to eb2c471 Compare April 14, 2025 22:41
@brian-pane
Copy link
Author

To make my new test cases work under Miri when running locally, I had to use MIRIFLAGS="-Zmiri-disable-isolation". Is there an equivalent of that setting for the CI run?

@brian-pane
Copy link
Author

Oops, I accidentally removed the Miri isolation fix. I'm restoring it now...

if state.stream.avail_in != 0 {
// Copy any remaining input to the start.
unsafe {
ptr::copy(
Copy link
Member

Choose a reason for hiding this comment

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

I suspect also here

Suggested change
ptr::copy(
ptr::copy_nonoverlapping(

Copy link
Author

Choose a reason for hiding this comment

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

In this case, we're shifting data from the middle of a buffer to the front, so it may overlap.

Copy link
Member

Choose a reason for hiding this comment

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

Maybe add a note then that they may overlap

Comment on lines 1354 to 1357
// Open a non-gzip file for reading. gzdirect should return 1.
#[test]
#[cfg_attr(not(target_os = "linux"), ignore = "lseek is not implemented")]
// Open a gzip file for reading. gzdirect should return 0.
Copy link
Member

Choose a reason for hiding this comment

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

something weird happed with the comments here.

@folkertdev folkertdev merged commit 9933dec into trifectatechfoundation:main Apr 16, 2025
24 checks passed
@brian-pane brian-pane deleted the gz branch April 16, 2025 21:01
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.

3 participants