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

dd: move unit tests into dd.rs and test_dd.rs #3141

Merged
merged 2 commits into from
Feb 17, 2022

Conversation

jfinkels
Copy link
Collaborator

Clean up unit tests in the dd crate to make them easier to
manage. This commit does a few things.

  • move test cases that test the complete functionality of the dd
    program from the dd_unit_tests module up to the
    tests/by-util/test_dd.rs module so that they can take advantage of
    the testing framework and common testing tools provided by uutils,
  • move test cases that test internal functions of the dd
    implementation into the tests module within dd.rs so that they
    live closer to the code they are testing,
  • replace test cases defined by macros with test cases defined by
    plain old functions to make the test cases easier to read at a
    glance.

Comment on lines +813 to +823
// TODO I think uppercase and lowercase are unintentionally swapped in
// the code that parses the command-line arguments. See this line from
// `parseargs.rs`:
//
// (ConvFlag::FmtAtoI, ConvFlag::UCase) => Some(&ASCII_TO_IBM_UCASE_TO_LCASE),
// (ConvFlag::FmtAtoI, ConvFlag::LCase) => Some(&ASCII_TO_IBM_LCASE_TO_UCASE),
//
// If my reading is correct and that is a typo, then the
// UCASE_TO_LCASE and LCASE_TO_UCASE in those lines should be swapped,
// and the expected output for the following two tests should be
// updated accordingly.
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I think there is a bug in the code, but I didn't fix it in this pull request.

Add helper method `CmdResult::stdout_is_fixture_bytes()`, which is
like `stdout_is_fixture()` but compares stdout to the raw bytes of a
given file instead of decoding the contents of the file to a UTF-8
string.
Clean up unit tests in the `dd` crate to make them easier to
manage. This commit does a few things.

* move test cases that test the complete functionality of the `dd`
  program from the `dd_unit_tests` module up to the
  `tests/by-util/test_dd.rs` module so that they can take advantage of
  the testing framework and common testing tools provided by uutils,
* move test cases that test internal functions of the `dd`
  implementation into the `tests` module within `dd.rs` so that they
  live closer to the code they are testing,
* replace test cases defined by macros with test cases defined by
  plain old functions to make the test cases easier to read at a
  glance.
@sylvestre
Copy link
Contributor

This is great, thanks :)

@sylvestre sylvestre merged commit 8e79b7f into uutils:main Feb 17, 2022
@jfinkels jfinkels deleted the dd-modules branch February 28, 2022 02:47
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.

2 participants