Skip to content
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

Refactor PDF Cleaning Tests for Improved Modularity and Error Handling + Add Rust Distribution README #18

Merged
merged 2 commits into from
Apr 3, 2024

Conversation

carlosiborra
Copy link
Contributor

Description

This pull request introduces a significant refactor of the existing PDF cleaning tests. The primary focus is on enhancing modularity, readability, and error handling, ensuring a more maintainable and robust testing framework. Key changes include the introduction of a TestConfig struct, the use of Result for error handling, performance measurement via std::time::Instant, and improved function naming and structuring.

Also adds a dedicated README file for the Rust distribution.

Changes

  1. Introduction of TestConfig Struct: Centralizes test configuration, making it easier to extend tests with new parameters or PDF sources.
  2. Improved Modularity: Separates concerns by introducing dedicated functions for creating the output directory (create_output_directory), reading and cleaning PDFs (read_and_clean_pdf), and storing PDFs (store_pdf). This approach enhances code reusability and readability.
  3. Robust Error Handling: Shifts from using unwrap() and expect() to handling errors with Result, providing a safer and more idiomatic way to handle potential failures in file operations.
  4. Performance Measurement: Adds timing for each test execution using std::time::Instant, offering valuable insights into the performance and efficiency of the PDF cleaning process.
  5. Clear and Descriptive Function Names: Renames functions to more accurately reflect their purpose, improving the readability and maintainability of the code.
  6. Enhanced Documentation with Rust-Specific README: Introduced a dedicated README file for the Rust distribution and referenced in the main README document.

Testing

  • Updated tests have been run successfully, ensuring that the refactoring has not affected the existing functionality.
  • Performance measurements have been logged for both test cases, providing a baseline for future optimizations.

Example

Output example after running tests with cargo test --package gulagcleaner_rs --lib -- tests --nocapture:

running 2 tests
Test for `example_docs/studocu-example.pdf` completed in 133.804977ms
test tests::test_studocu_pdf ... ok
Test for `example_docs/wuolah-free-example.pdf` completed in 210.941144ms
test tests::test_wuolah_pdf ... ok

test result: ok. 2 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.22s

@carlosiborra carlosiborra changed the title Refactor PDF Cleaning Tests for Improved Modularity and Error Handling + Added Rust Distribution's README Refactor PDF Cleaning Tests for Improved Modularity and Error Handling + Add Rust Distribution's README Mar 15, 2024
@carlosiborra carlosiborra changed the title Refactor PDF Cleaning Tests for Improved Modularity and Error Handling + Add Rust Distribution's README Refactor PDF Cleaning Tests for Improved Modularity and Error Handling + Add Rust Distribution README Mar 15, 2024
@YM162 YM162 self-assigned this Mar 19, 2024
@YM162
Copy link
Owner

YM162 commented Apr 3, 2024

LGTM! Thanks for the contribution.

@YM162 YM162 merged commit 325c3a2 into YM162:main Apr 3, 2024
1 check passed
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.

None yet

2 participants