Commit Graph
7 Commits
Author SHA1 Message Date
oech3andGitHub 918484bff9 Avoid non reproducible cache generation at codcov (#10926) 2026-02-19 10:06:33 +01:00
Sylvestre LedruandGitHub cd288fc401 ci: ensure test failures are caught in coverage script and fix them (#10286) 2026-01-17 10:20:39 -05:00
ec063a7c37 Added unit tests for stty.rs to improve test coverage (#9094)
* stty: Add 101 unit tests and 16 integration tests to improve coverage

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 #9061

* stty: Add essential unit tests and integration tests to improve coverage

- 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 #9061

* stty: Add comprehensive unit and integration tests for error handling

- 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.

* stty: Add Debug and PartialEq derives for test assertions

- Add #[derive(Debug, PartialEq)] to AllFlags enum
- Add PartialEq to Flag struct derives
- Enables assert_eq! macro usage in unit tests

* stty: Fix formatting and clippy warnings in 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

* stty: Add inline spell-checker ignores for test strings

- 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

* perf: gate PartialEq derive to test builds only

The PartialEq derive was being compiled into release builds even though
it's only used in test code. This caused a 3.33% performance regression
in the du_human_balanced_tree benchmark due to increased binary size
affecting CPU cache efficiency.

Changes:
- stty.rs: Gate PartialEq derive on Flag<T> with #[cfg_attr(test, derive(PartialEq))]
- flags.rs: Gate PartialEq derive on AllFlags enum with #[cfg_attr(test, derive(PartialEq))]

This eliminates the performance regression while keeping all test code
functional and unchanged.

---------

Co-authored-by: Sylvestre Ledru <sylvestre@debian.org>
2025-12-27 00:48:07 +01:00
Martin Kunkel 7067251a84 Exclude test modules from coverage report 2025-12-09 18:17:06 +00:00
Martin Kunkel c31de82629 unit test coverage: fix missing coverage
binary-path option of grcov needs to be set to full target/debug folder
to include unit test binaries.
2025-12-09 16:45:53 +00:00
Chris DrydenandGitHub 6d48b9879e Removing the per process file flag to reduce the llvm filemerge time 2025-11-22 14:14:12 -05:00
Dorian PeronandDorian Peron 73faa50ac3 create a script for automating code coverage 2025-04-07 10:19:00 +02:00