coreutils icon indicating copy to clipboard operation
coreutils copied to clipboard

Added unit tests for stty.rs to improve test coverage

Open naoNao89 opened this issue 1 month ago • 25 comments

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

naoNao89 avatar Oct 30 '25 16:10 naoNao89

I would have preferred actual integration test ( in tests/by-util) Not unit test

sylvestre avatar Oct 30 '25 16:10 sylvestre

CodSpeed Performance Report

Merging #9094 will not alter performance

Comparing naoNao89:stty-add-unit-tests (70c9158) with main (7c62885)

Summary

✅ 127 untouched
⏩ 6 skipped[^skipped]

[^skipped]: 6 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports.

codspeed-hq[bot] avatar Oct 30 '25 17:10 codspeed-hq[bot]

GNU testsuite comparison:

Skip an intermittent issue tests/misc/tee (fails in this run but passes in the 'main' branch)

github-actions[bot] avatar Oct 30 '25 17:10 github-actions[bot]

GNU testsuite comparison:

Skipping an intermittent issue tests/misc/tee (passes in this run but fails in the 'main' branch)

github-actions[bot] avatar Oct 30 '25 19:10 github-actions[bot]

a lot of tests just do succeed(). We should check the output too

sylvestre avatar Oct 30 '25 21:10 sylvestre

GNU testsuite comparison:

Skipping an intermittent issue tests/tail/overlay-headers (passes in this run but fails in the 'main' branch)

github-actions[bot] avatar Oct 31 '25 05:10 github-actions[bot]

according to codecov: it only improved the code coverage by 2% https://app.codecov.io/gh/uutils/coreutils/pull/9094/indirect-changes did you check if it is correct ? :)

sylvestre avatar Oct 31 '25 07:10 sylvestre

currently using llvm-cov for coverage measurement, but something is wrong with it :v

naoNao89 avatar Oct 31 '25 09:10 naoNao89

Our 23% coverage reflects the TTY limitation, not poor testing.

GNU coreutils stty ALSO requires real TTY: https://github.com/coreutils/coreutils/blob/master/tests/stty/stty-invalid.sh

Both skip tests in CI. ~75% of stty code is TTY-dependent (terminal I/O, signals, device ops) and cannot be tested in CI.

naoNao89 avatar Oct 31 '25 11:10 naoNao89

GNU testsuite comparison:

Skipping an intermittent issue tests/misc/tee (passes in this run but fails in the 'main' branch)

github-actions[bot] avatar Oct 31 '25 12:10 github-actions[bot]

GNU testsuite comparison:

Skipping an intermittent issue tests/misc/tee (passes in this run but fails in the 'main' branch)

github-actions[bot] avatar Oct 31 '25 13:10 github-actions[bot]

GNU testsuite comparison:

Skip an intermittent issue tests/timeout/timeout (fails in this run but passes in the 'main' branch)
Skipping an intermittent issue tests/misc/tee (passes in this run but fails in the 'main' branch)

github-actions[bot] avatar Oct 31 '25 13:10 github-actions[bot]

GNU testsuite comparison:

Skipping an intermittent issue tests/misc/tee (passes in this run but fails in the 'main' branch)

github-actions[bot] avatar Oct 31 '25 16:10 github-actions[bot]

GNU testsuite comparison:

Skip an intermittent issue tests/timeout/timeout (fails in this run but passes in the 'main' branch)

github-actions[bot] avatar Nov 01 '25 09:11 github-actions[bot]

my local: 1.90.0 stable, CI might use different version 🙉

naoNao89 avatar Nov 01 '25 09:11 naoNao89

GNU testsuite comparison:

Skipping an intermittent issue tests/tail/overlay-headers (passes in this run but fails in the 'main' branch)

github-actions[bot] avatar Nov 01 '25 09:11 github-actions[bot]

GNU testsuite comparison:

Skipping an intermittent issue tests/misc/tee (passes in this run but fails in the 'main' branch)

github-actions[bot] avatar Nov 01 '25 11:11 github-actions[bot]

GNU testsuite comparison:

Skipping an intermittent issue tests/misc/tee (passes in this run but fails in the 'main' branch)

github-actions[bot] avatar Nov 01 '25 12:11 github-actions[bot]

GNU testsuite comparison:

Skipping an intermittent issue tests/misc/tee (passes in this run but fails in the 'main' branch)

github-actions[bot] avatar Nov 01 '25 12:11 github-actions[bot]

GNU testsuite comparison:

Skipping an intermittent issue tests/misc/tee (passes in this run but fails in the 'main' branch)

github-actions[bot] avatar Nov 01 '25 19:11 github-actions[bot]

GNU testsuite comparison:

Skip an intermittent issue tests/tail/overlay-headers (fails in this run but passes in the 'main' branch)

github-actions[bot] avatar Nov 07 '25 13:11 github-actions[bot]

http://github.com/uutils/coreutils/pull/9348 I made a PR that gives an example of a way to create a TTY for the integration tests. Was hoping to use that for stty and more.

ChrisDryden avatar Nov 21 '25 04:11 ChrisDryden

tks

naoNao89 avatar Nov 21 '25 11:11 naoNao89

GNU testsuite comparison:

Congrats! The gnu test tests/du/files0-from is no longer failing!

github-actions[bot] avatar Dec 06 '25 13:12 github-actions[bot]

GNU testsuite comparison:

Skip an intermittent issue tests/misc/tee (fails in this run but passes in the 'main' branch)
Skip an intermittent issue tests/tail/overlay-headers (fails in this run but passes in the 'main' branch)

github-actions[bot] avatar Dec 07 '25 03:12 github-actions[bot]