-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Added unit tests for stty.rs to improve test coverage #9094
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
base: main
Are you sure you want to change the base?
Conversation
d38a821 to
d83042c
Compare
|
I would have preferred actual integration test ( in tests/by-util) Not unit test |
d83042c to
1838e5b
Compare
Add comprehensive test coverage for stty: Unit tests (src/uu/stty/src/stty.rs): - Flag struct methods and builder pattern (7 tests) - Control character parsing and formatting (19 tests) - All combination settings expansion (26 tests) - Termios modification functions (13 tests) - String-to-flag/combo/baud parsing (19 tests) - TermiosFlag trait implementations (5 tests) - Helper and utility functions (10 tests) - Trait implementations (2 tests) Integration tests (tests/by-util/test_stty.rs): - Help and version output validation (2 tests) - Invalid argument handling (3 tests) - Control character overflow validation (2 tests) - Grouped flag removal validation (1 test) - File argument error handling (1 test) - Conflicting print modes (1 test) - Additional TTY-dependent tests (6 tests, ignored in CI) Unit test coverage improved from 0% to 43.76% (207/473 lines). Integration tests validate argument parsing and error handling. Addresses uutils#9061
a9c4cd9 to
2afc19c
Compare
CodSpeed Performance ReportMerging #9094 will not alter performanceComparing Summary
|
|
GNU testsuite comparison: |
2afc19c to
82d7875
Compare
|
GNU testsuite comparison: |
|
a lot of tests just do succeed(). We should check the output too |
5fd36da to
dc5f06a
Compare
- Added 11 essential unit tests for complex internal functions: * Control character parsing (string_to_control_char) * Control character formatting (control_char_to_string) * Combination settings expansion (combo_to_flags) * Terminal size parsing with overflow handling (parse_rows_cols) * Sane control character defaults (get_sane_control_char) - Added 16 integration tests for command behavior: * Help/version output validation * Invalid argument handling * Control character overflow validation * Grouped flag removal validation * File argument error handling * Conflicting print modes * TTY-dependent tests (marked as ignored for CI) Unit tests focus on complex parsing logic that's difficult to test via integration tests. Integration tests validate actual command behavior. Coverage improved from 0% to 43.76% (207/473 lines). Fixes uutils#9061
dc5f06a to
faf10db
Compare
|
GNU testsuite comparison: |
|
according to codecov: it only improved the code coverage by 2% |
|
currently using llvm-cov for coverage measurement, but something is wrong with it :v |
|
Our 23% coverage reflects the TTY limitation, not poor testing. GNU coreutils stty ALSO requires real TTY: Both skip tests in CI. ~75% of stty code is TTY-dependent |
- Add unit tests for parse_rows_cols() with edge cases and wraparound - Add unit tests for string_to_baud() with platform-specific handling - Add unit tests for string_to_combo() with all combo modes - Add 17 integration tests for missing arguments and invalid inputs - Enhance test_invalid_arg() with better error message assertions - Update coverage script for improved reporting Coverage improved from 22.26% to 23.14% regions.
|
GNU testsuite comparison: |
- Add #[derive(Debug, PartialEq)] to AllFlags enum - Add PartialEq to Flag struct derives - Enables assert_eq! macro usage in unit tests
- Replace assert_eq! with assert! for boolean comparisons
- Fix line wrapping for long logical expressions
- Use inline format string syntax (e.g., {err} instead of {})
- All 25 unit tests pass
- No clippy warnings
|
GNU testsuite comparison: |
|
GNU testsuite comparison: |
- Add spell-checker:ignore comments for test data (notachar, notabaud, susp) - Add spell-checker:ignore comments for French error strings (Valeur, entier, invalide) - Fixes cspell validation without modifying global config
|
GNU testsuite comparison: |
This adds comprehensive unit test coverage for the core functions in stty.rs. Tests cover flag parsing, control character handling, combination settings, termios modifications, and trait implementations.
Fixes #9061