Commit Graph
38 Commits
Author SHA1 Message Date
Sylvestre LedruandDaniel Hofstetter f057cc6a01 tests: replace .no_stdout().no_stderr() chains with .no_output()
Bulk rename of the antipattern across 19 test files (136 occurrences).
.no_output() is the established shorthand in the uutests framework
for asserting both empty stdout and empty stderr.
2026-05-12 09:31:31 +02:00
Chris DrydenandGitHub a297d26cfa csplit: detect and report write errors (#9855)
* csplit: detect and report write errors

* Add Rust integration tests for csplit write error detection

* csplit: fix doc comment for finish_split
2025-12-31 20:09:39 +01:00
naoNao89 1afeb7a6e3 csplit: create final empty file with --suppress-matched to match GNU (fixes #7286)
Problem
- With , uutils csplit failed to create the final empty output file when the last split point consumed the trailing input.
- GNU csplit always creates a final segment after processing patterns; with , that empty final segment is elided.
- This broke the GNU test (tests/csplit/csplit-suppress-matched.pl) and the scenario:

Root cause
- Final-file creation was conditional on there being remaining input after pattern processing. If none remained, no final file was created, contrary to GNU semantics.

Fix (minimal, targeted)
- In , after :
  - If there is remaining input, always create a final split and copy the remainder, then finish.
  - Else, if all patterns were integer-based and  is set, create a final (possibly empty) split and finish;  elides it when  is set.

Tests (Rust integration)
- Added two Rust tests under  to lock down GNU-compatible behavior:
  -  (expects sizes 2,2,2,0 and a final empty )
  -  (final empty file is correctly elided)

Verification
- All  tests pass locally. The originally reported case now matches GNU.

Relation to PR #7806
- #7806 proposes a broader refactor to fix multiple issues, but remains a draft and notes remaining GNU suppress-matched differences.
- This PR provides a small, reviewable fix specifically for #7286, plus precise integration tests to safeguard behavior.

Fixes #7286
2025-09-18 00:29:55 +07:00
Sylvestre Ledru 20793600f7 Fix csplit to handle non-UTF-8 filenames 2025-08-14 10:52:24 +02:00
Dorian Peron 6e23d4e979 tests: patch tests to simplify imports 2025-07-01 03:36:46 +02:00
Daniel Hofstetter d5b6af5216 csplit: only allow ASCII digits as offset 2025-05-28 16:07:45 +02:00
Daniel Hofstetter 7439050d85 csplit: only allow ASCII digits for repeat pattern 2025-05-28 15:53:54 +02:00
Jeremy SmartandGitHub a752f73476 csplit: don't add a newline if the file doesn't end with one (#7901)
* csplit: don't add a newline if the file doesn't end with one

* refactor test

* refactor
2025-05-09 09:15:54 +02:00
Yuri Astrakhan 47b10539d0 chore: use inline formatting
Minor cleanup using clippy autofix.  This makes the code a bit more readable, and helps spot a few inefficiencies and possible bugs.

```
cargo clippy --fix --workspace -- -A clippy::all -W clippy::uninlined_format_args && cargo fmt
```
2025-04-07 22:56:21 -04:00
Sylvestre Ledru a0179ea239 uutests: adjust the tests to use them 2025-03-28 21:40:31 +01:00
Sylvestre Ledru 3e1adf40ee Use the new function 'fails_with_code' v2 2025-03-04 09:27:47 +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
Jeffrey Finkelstein 18f9ca9da4 csplit: don't panic on missing suppressed file
Avoid a panic that would occur when attempting to remove a file that
didn't exist. This would happen when scanning for a regular expression
match, advancing by a positive offset, and suppressing empty files. For
example, before this commit,

    echo a | csplit -z - %a%1

would cause a panic. After this commit, the process terminates as
expected: without error, without output, and without any files written.

Fixes #7251.
2025-02-09 22:04:47 -05:00
Daniel Hofstetter 6096767442 csplit: simplify test 2025-01-09 15:20:22 +01:00
Fuad IsmailandDaniel Hofstetter a4fdecbf48 tests/csplit: use printf instead of echo -n for maximum portability with all UNIX systems 2025-01-09 10:52:19 +01:00
Fuad IsmailandDaniel Hofstetter 981019138d tests/csplit: ignore IRWXU from cspell check 2025-01-09 10:52:19 +01:00
Fuad IsmailandDaniel Hofstetter 96929734ea tests/csplit: modify no_such_file test expected error to conform better with original csplit error 2025-01-09 10:52:19 +01:00
Fuad IsmailandDaniel Hofstetter c8bc5d2455 tests/csplit: handle directory input file test for Windows separately 2025-01-09 10:52:19 +01:00
Fuad IsmailandDaniel Hofstetter 19f990f29a tests/csplit: add directory input file test. 2025-01-09 10:52:19 +01:00
Fuad IsmailandDaniel Hofstetter 1dc463fd26 tests/csplit: add named pipe input file test. 2025-01-09 10:52:19 +01:00
Tommaso FellegaraandGitHub 33ac58383c csplit: fix bug when --suppress-matched flag is active and positive/negative offset is present (#7088)
* tests/csplit: modified test test_up_to_match_offset_option_suppress_matched according to issue #7052 and modified also test_up_to_match_negative_offset_option_suppress_matched

* csplit: managed the positive and negative offset when the --suppressed-matched flag is active

* tests/csplit: modified test test_up_to_match_offset_option_suppress_matched according to issue #7052 and modified also test_up_to_match_negative_offset_option_suppress_matched

* csplit: managed the positive and negative offset when the --suppressed-matched flag is active

* csplit: swapped if and else blocks for better readability
2025-01-09 09:20:48 +01:00
Daniel Hofstetter f62b8d7975 csplit: allow offset without sign in pattern 2024-12-27 16:08:48 +01:00
Daniel Hofstetter db37c316af csplit: add support for -q 2024-12-26 09:40:55 +01:00
Ben Wiederhake 27fd3e5d39 csplit: do not emit remainder of input after an error 2024-03-23 23:21:53 +01:00
Ben Wiederhake 44fa2e960a csplit: correctly handle repeated arguments 2024-03-23 23:21:53 +01:00