Commit Graph
77 Commits
Author SHA1 Message Date
Chris DrydenandGitHub b684d1606d seq: add SIGPIPE handling for GNU compatibility (#9657) 2026-01-09 23:20:59 +01:00
mattsu 099a5ddfc8 test: ensure seq test triggers broken pipe with infinite output
Use an infinite sequence in `test_broken_pipe_still_exits_success` instead of
finite range (1-5) to guarantee a burst of output immediately after spawn,
preventing the process from finishing before stdout closure and avoiding
missed broken pipe errors.
2025-11-29 20:34:42 +09:00
mattsuandGitHub b9f97d4c7d fix(seq): handle BrokenPipe like GNU (#9471)
* fix(seq): handle BrokenPipe like GNU

* test: add Unix-specific test for seq command broken pipe handling

- Ensures seq exits gracefully with code 0 and reports "Broken pipe" error on stderr when stdout pipe is prematurely closed
- Validates correct behavior for common scenario where output is piped to commands like head that terminate early

* refactor(test): translate Japanese comment to English in test_seq.rs

- Updated a comment in the test for broken pipe behavior to use English instead of Japanese, enhancing readability for non-Japanese speakers and aligning with project standards. No functional changes to the test logic.
2025-11-26 23:20:45 +01:00
Daniel Hofstetter 001ab890d5 seq: support non-utf8 for --terminator 2025-09-20 17:50:47 +02:00
Daniel Hofstetter 0d621f0e07 seq: support non-utf8 for --separator 2025-09-20 17:49:42 +02:00
Dorian Peron 6e23d4e979 tests: patch tests to simplify imports 2025-07-01 03:36:46 +02:00
Luv-RayandGitHub fb2399f56b fix clippy (#8275)
* fix clippy

* update

* update
2025-06-27 09:15:24 +02:00
Nicolas Boichat 560d1eb1b7 seq: Add a print_seq fast path function for integer and positive increments
A lot of custom logic, we basically do arithmetic on character
arrays, but this comes at with huge performance gains.

Unlike coreutils `seq`, we do this for all positive increments
(because why not), and we do not fall back to slow path if
the last parameter is in scientific notation.

Also, add some tests for empty separator, as that may catch
some corner cases.
2025-04-21 11:25:54 +02:00
Nicolas Boichat e0a6482759 seq: Trim whitespaces, then try to remove +
Otherwise, `seq` crashes with ` 0xee.` as input.

Also update one of the tests to catch that.
2025-04-04 17:09:33 +02:00
Nicolas Boichat ae3756b434 seq: Do not allow -w and -f to be specified at the same time
Fixes #7466.
2025-04-04 10:17:17 +02:00
Nicolas BoichatandDaniel Hofstetter 84e5ee4b86 seq: Accept underflow in parameters
Also, add a test to check that a very, very, small number is
treated as 0. That's probably undefined behaviour, but it does
make some sense.
2025-04-03 17:26:38 +02:00
Nicolas BoichatandDaniel Hofstetter d58f1cc0f1 test_seq: Modify undefined behaviour tests
GNU `seq` doesn't support such large positive exponents anyway,
and we are limited by i64 range, so increase the exponent value
to make sure we fully overflow that range.

Also, add a test to check that a very, very, small number is
treated as 0 (that's also undefined behaviour, but it does
make sense in a way).
2025-04-03 17:26:38 +02:00
Sylvestre Ledru a0179ea239 uutests: adjust the tests to use them 2025-03-28 21:40:31 +01:00
Nicolas BoichatandSylvestre Ledru 596ea0a694 test_seq: Add a few more tests for corner cases
Some of these tests are not completely defined behavior, but
in many cases they make sense (or at least one can find some
consistent logic to it).

However, there are 2 edge cases that are more dubious IMHO.
One of them has been reported on list a while back, and I
just reported another.
2025-03-22 22:02:11 +01:00
Nicolas BoichatandSylvestre Ledru 59cd6e5e41 tests: Move seq/yes run function to Ucommand::run_stdout_starts_with
Tests for both `seq` and `yes` run a command that never terminates,
and check the beggining of their output in stdout, move the copied
parts of the wrapper function to common/util.

We still need to use slightly different logic to parse exit value
as `seq` returns success if stdout gets closed, while `yes` fails.
2025-03-22 22:02:11 +01:00
Nicolas BoichatandDorian Péron c0a1179e7c seq: Enable test_auto_precision and test_undefined
Those tests appear to have been fixed, enable them.
2025-03-14 12:05:16 +01:00
Nicolas BoichatandDorian Péron 1782de8999 seq: Add tests for default float formats
Add tests for some of the default float formats (%f, %g, %E), mostly
to check that the default precision is correctly set to 6 digits.
2025-03-14 12:05:16 +01:00
Daniel Hofstetter df4dfea852 tests: replace run() with succeeds() or fails() 2025-03-09 16:53:56 +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
Alexander Shirokov b3c0633b95 seq:add bounds for exponents
Add bounds for exponents to avoid overflow issues for inputs like 'seq
1e-9223372036854775808'
2025-01-15 22:35:24 +01:00
05ada0d204 seq:add floating point support (#6959)
* seq:enable parsing of hexadecimal floats

Turn on the float parser. Now it's possible to use hexadecimal floats as
parameters. For example,

    cargo run -- 0x1p-1 3
    0.5
    1.5
    2.5

Issue #6935

---------

Co-authored-by: Daniel Hofstetter <daniel.hofstetter@42dh.com>
Co-authored-by: Sylvestre Ledru <sylvestre@debian.org>
2025-01-15 11:53:18 +01:00
Jeffrey Finkelstein cccab35337 seq: improve error handling for invalid -f values
Improve the error message produced by `seq` when given invalid format
specifiers for the `-f` option. Before this commit:

    $ seq -f "%" 1
    seq: %: invalid conversion specification
    $ seq -f "%g%" 1
    seq: %: invalid conversion specification

After this commit:

    $ seq -f "%" 1
    seq: format '%' ends in %
    $ seq -f "%g%" 1
    seq: format '%g%' has too many % directives

This matches the behavior of GNU `seq`.
2024-12-30 12:30:26 -05:00
Daniel Hofstetter ee0426e3f3 seq: use allow_hyphen_values instead of
allow_negative_numbers because clap removed support for "exotic" negative
numbers like -.1
2024-12-15 16:14:01 +01:00
Daniel Hofstetter 1f6f7fbe8c tests/seq: fix ticket references of ignored tests 2024-12-07 17:04:05 +01:00
Daniel Hofstetter e654645974 tests/seq: use stdout_only() to remove no_stderr() 2024-12-07 16:59:13 +01:00