-
Notifications
You must be signed in to change notification settings - Fork 5
Improve testing coverage #84
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
…correctly on ranges
Summary of ChangesHello @noamteyssier, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request focuses on enhancing the robustness and testability of the Highlights
🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console. Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code Review
The code changes involve modifications to the bq, cbq, error, parallel, policy, utils/fastx, and vbq modules. The ReadError enum in error.rs was updated to use structs for OutOfRange and add InvalidRange errors. The ParallelReader trait in parallel.rs gained a validate_range method. The MmapReader implementations in bq/reader.rs, cbq/read.rs, and vbq/reader.rs now use this method for range validation. New tests were added for error handling, parallel processing, and record access in bq/reader.rs, cbq/read.rs, error.rs, parallel.rs, policy.rs, utils/fastx.rs, and vbq/reader.rs. Review comments highlight bugs in is_index_mismatch and IndexError::is_mismatch that always return true, the BreakOnInvalid policy's handle method always returning an error, and loose assertions in parallel processing tests. Additionally, there are comments about tautological assertions in is_paired tests, weak checks for invalid file formats, and missing verification of set_default_quality_score's effect.
| // Note: The current implementation has a bug - it always returns true | ||
| assert!(error.is_index_mismatch()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The comment // Note: The current implementation has a bug - it always returns true indicates a known bug in the is_index_mismatch logic. This should be fixed to correctly identify only ByteSizeMismatch errors as index mismatches, as per the method's documentation.
| // Note: The current implementation has a bug - it always returns true | |
| assert!(error.is_index_mismatch()); | |
| // Note: The current implementation has a bug - it always returns true | |
| assert!(!error.is_index_mismatch()); |
| assert!(error.is_mismatch()); | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Similar to the previous comment, the IndexError::is_mismatch method has a bug where it always returns true. This test should reflect the correct behavior once the bug is fixed, asserting false for InvalidMagicNumber.
// Note: Current implementation bug - always returns true
assert!(!error.is_mismatch());| // Valid sequences should error because handle() doesn't validate for BreakOnInvalid | ||
| // It only returns an error immediately | ||
| assert!(result.is_err()); | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The BreakOnInvalid policy's handle method currently always returns an error, even for valid sequences, as indicated by the comment // Valid sequences should error because handle() doesn't validate for BreakOnInvalid // It only returns an error immediately. This contradicts the policy's description: 'Fail with an error when invalid nucleotides are encountered'. The method should only return an error if an actual invalid nucleotide is present in the sequence. Please adjust the logic to perform validation before returning an error.
| let reader = MmapReader::new(TEST_BQ_FILE).unwrap(); | ||
| let is_paired = reader.is_paired(); | ||
| // Test that the method returns a boolean | ||
| assert!(is_paired || !is_paired); // Always true, tests the method works |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| let num_records = reader.num_records(); | ||
| // The number might be nonsensical for invalid data | ||
| let _ = num_records; // Just verify it doesn't panic | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The assertion let _ = num_records; // Just verify it doesn't panic is a very weak check for an invalid file format. For an invalid file like Cargo.toml, num_records() should ideally return an error or a specific, expected value indicating invalidity, rather than just not panicking. Consider asserting that an error is returned or that num_records is 0 if that's the expected behavior for an invalid file.
| let reader = MmapReader::new(TEST_CBQ_FILE).unwrap(); | ||
| let is_paired = reader.is_paired(); | ||
| // Test that the method returns a boolean | ||
| assert!(is_paired || !is_paired); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| let custom_score = 42u8; | ||
|
|
||
| reader.set_default_quality_score(custom_score); | ||
| // Just verify it doesn't panic |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| let reader = MmapReader::new(TEST_VBQ_FILE).unwrap(); | ||
| let is_paired = reader.is_paired(); | ||
| // Test that the method returns a boolean | ||
| assert!(is_paired || !is_paired); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No description provided.