Commit Graph
30 Commits
Author SHA1 Message Date
Sylvestre LedruandDaniel Hofstetter 8cc048b43c stty: add support for tabs/-tabs combination settings 2026-04-21 17:02:29 +02:00
oech3andGitHub ec1fcdb4ac ls, stty: reduce cfg by target_vendor (#11910) 2026-04-20 08:36:32 +02:00
✿ Fleur de BlueandGitHub 2a2cafdbd4 Re-enable unused_qualifications lint (#10571) 2026-02-03 21:55:21 +01:00
Chris DrydenandGitHub d737450383 Stty: Implemented input and output baud rate setting for stty (#9517) 2026-01-09 23:37:34 +01:00
c8790e6743 stty: use stdin for TTY operations instead of /dev/tty (#9881)
* stty: use stdin for TTY operations instead of /dev/tty

* Add tests for stty stdin behavior and fix platform-specific error messages

---------

Co-authored-by: Sylvestre Ledru <sylvestre@debian.org>
2025-12-31 20:02:05 +01: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
dbfe7c56ab stty: columns env support and integration testing (#9490)
* stty: Wrap parameters when using --all

Do the same as GNU stty when it has to prints the parameter, doing
proper text wrapping

* Adding integration tests for the COLUMNS env variable support in stty

* Adding integration tests for the COLUMNS env variable support in stty

---------

Co-authored-by: Marco Trevisan (Treviño) <mail@3v1n0.net>
2025-12-27 00:13:33 +01:00
Chris DrydenandGitHub 7cce907c0e Stty: implemented hex and octal parsing for rows and columns (#9516)
* Implemented hex and octal parsing for row columns for stty

* Adding more test cases with different upper and lowercase values

* stty: use ExtendedParser for hex/octal row/col parsing
2025-12-27 00:11:45 +01:00
Chris DrydenandGitHub 824c5c7c93 stty: Implemented saved state parser for stty (#9480)
* Implemented saved state parser for stty

* Add compatibility to macos flag type

* Added many example state parsing integration tests with GNU compatibility checks and documentation

* Spelling and formatting fixes

* Matching behaviour of adding the help command after invocations and spelling fixes

* GNU tests were being skipped because they were not at the sufficient version

* Fixed messaging error for invalid states to not show full path

* Normalizing the test output and reverting lib change

* Discovered that the limit depends on platform specific values derived from a LIBC value

* Spelling fixes and setting flags to 0 for cross platform compatibility

* Clippy fixes

* Disabling tests due to invalid printing of control chars and using GNU for printing

* Redisabling failing test as outside of the scope of this PR

* Adding g prefix support to normalize stderr

* Spell checker fixes

* Normalizing command for both gnu and uutils output

* removing single value from testing since it can be interpreted as Baud rate

* Fixing spelling mistake
2025-11-26 07:33:26 +01:00
Chris DrydenandGitHub 6a2b97273e stty: baud parsing integration tests and validation (#9454)
* Adding comprehensive gnu suite baud parsing rules

* Adding missing spellcheck words

* Fixed clippy errors and simplified rounding logic
2025-11-24 11:03:47 +01:00
Chris DrydenandGitHub 29adc24d0e Adding TTY helper for unix to be able to create tests for stty and more (#9348)
* Adding TTY helper for unix to be able to create tests for stty and more

* removing missing flag on github actions and spellcheck ignore
2025-11-21 23:40:00 +01:00
yuankunzhang a8fe603284 stty: support sane settings 2025-07-16 22:33:33 +08:00
Will Shuttleworth 93fc669258 stty: add combination settings 2025-07-10 08:19:27 -04:00
Will Shuttleworth 9e029f542b stty: add min and time settings 2025-07-06 22:29:47 -04:00
Will Shuttleworth ff11406c7a stty: add line setting 2025-07-06 22:28:10 -04:00
Dorian Peron 6e23d4e979 tests: patch tests to simplify imports 2025-07-01 03:36:46 +02:00
Will Shuttleworth 10f8d77560 stty: add option to print terminal size 2025-06-19 08:38:47 -04:00
Will Shuttleworth 93ac655936 stty: add tests for setting rows/cols 2025-06-19 08:38:08 -04:00
Will ShuttleworthandGitHub 01ac6dfd18 Merge pull request #8135 from willshuttleworth/stty-set-undefined
stty: fix mappings with empty string literal args
2025-06-16 09:45:11 +02:00
Will ShuttleworthandGitHub 6023888363 stty: add ispeed/ospeed settings (#8180)
* stty: add ispeed/ospeed settings

* stty: fix spell check errors
2025-06-15 16:46:54 +02:00
Will Shuttleworth 4be9e7679d stty: fix negated options getting rejected by clap 2025-06-09 17:35:06 -04:00
Will ShuttleworthandGitHub 61bd11a551 stty: set control characters (#7931)
* reworked arg processing. control character mappings are correctly grouped now, ie 'stty erase ^H'

* stty: setting control chars to undefined (disabling them) is implemented

* setting control chars

* stty: can now set control chars. need to improve checks on valid mappings

* stty: matches GNU in what control character mappings are allowed

* stty: run rustfmt and remove extra comments

* stty: setting control char code review fixes

* stty: fix rustfmt errors

* stty: more small edits after review

* stty: refactor set control char changes for better testing

* stty: fix ci error

* stty: fix issues from code review
2025-06-05 11:38:51 +02:00
Sylvestre Ledru a0179ea239 uutests: adjust the tests to use them 2025-03-28 21:40:31 +01:00
Sylvestre Ledru 18cb7dcf9e Use the new function fails_with_code
Done with
```
$ perl -0777 -i -pe 's/([ \t]+)\.fails\(\)[ \t]*\n[ \t]+\.no_stdout\(\)[ \t]*\n[ \t]+\.code_is\(([0-9]+)\);/\1.fails_with_code(\2)\n\1.no_stdout();/gs' *rs
$ sed -i -e "s|.fails()(.*).code_is(|.fails_with_code(|g" *rs
$ perl -0777 -i -pe 's/([ \t]+)\.fails\(\)[ \t]*\n[ \t]+\.code_is\(([0-9]+)\);/\1.fails_with_code(\2);/gs' *rs
$ perl -0777 -i -pe 's/([ \t]+)\.fails\(\)(.*?)[ \t]+\.code_is\(([0-9]+)\);/\1.fails_with_code(\3)\2;/gs' *rs
...
```
2025-03-01 17:26:20 +01:00
Sylvestre Ledru bfca6bf70f Add license headers on all files 2023-08-21 10:49:27 +02:00