Commit Graph
70 Commits
Author SHA1 Message Date
Sylvestre LedruandGitHub 163103355a head: strip os error suffix from stdout write error message (#12121) 2026-05-04 09:38:54 +02:00
oech3andGitHub 1d3dba8261 remove seekable from local cspell conf and use it (#11773) 2026-04-12 16:22:34 +02:00
AnthonyandGitHub 36ac85b1f3 tests: add WASI integration test support via wasmtime 2026-04-12 15:19:04 +02:00
Alvaro GuimaraesandGitHub d8688183ff head: fix error message when input is a directory (#11541)
* head: fix error message when input is a directory

* head: check for directory before trying to open
2026-03-30 16:54:50 +02:00
97e69f0055 head: reset stale partial line state on reused buffers (#11407)
Co-authored-by: Sylvestre Ledru <sylvestre@debian.org>
2026-03-27 15:05:01 +01:00
Sylvestre Ledru 0a7ea78733 split: bring back the test 2025-08-14 10:54:17 +02:00
Sylvestre Ledru 1c5b95d1bb non-utf8: address review commits 2025-08-14 10:54:17 +02:00
Sylvestre Ledru 5930ba0eb5 head: refactor the code a bit 2025-08-14 10:54:17 +02:00
Sylvestre Ledru f15dac138e chmod/readlink/du: improve non-UTF-8 filename handling and code style 2025-08-14 10:52:24 +02:00
Sylvestre Ledru becbc0e19d head: fix handling of non-UTF-8 filenames 2025-08-14 10:52:24 +02:00
3b4b769976 tests: fix execution on WSL2, Ubuntu 24.04 (#8235)
* tests: fix execution on WSL2, Ubuntu 24.04

Skip incompatible parts of tests to ensure that
    cargo nextest run --features unix
executes successfully in WSL2, Ubuntu 24.04 distribution.

Changes
* Skip tests that required sys/kernel/profiling which is not
available in WSL2 default configuration.
* Use timezones in tests that are part of the standard tzdata
list and not only available in backwards list. Backwards list is
not installed by default in Ubuntu 24.04 (package tzdata-legacy).
* check that /proc/modules is not empty when expecting content,
because it is empty in WSL2 default configuration.
* Skip logname test not only in WSL1, also in WSL2.

* Add workflow for WSL2

This will setup WSL2 on windows-latest runner, install
Ubuntu-24.04, and run the feat_os_unix tests.

* wsl2: implemented review findings

---------

Co-authored-by: Sylvestre Ledru <sylvestre@debian.org>
2025-08-03 14:38:49 +02:00
Brian Vincent 20d26aa074 head: fix meaning of ---presume-input-pipe
The option ---presume-input-pipe is debug option that should
disable the seeking optimization, not force it to read stdin.
This fixes the GNU test head-elide-tail.
2025-07-07 18:37:48 -07:00
Dorian PéronandGitHub 5936408922 Merge pull request #7484 from karlmcdowall/head_bug_bug_bug
head: fix bug with non-terminated files.
2025-06-14 21:22:24 +02:00
Jeremy SmartandSylvestre Ledru cc1112660a head: return to parse::<usize> and switch to parse_size_u64_max 2025-04-12 23:38:32 +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
Karl McDowall 9957d0a64e head: fix bug with non-terminated files.
Fixes issue #7472.
Update to head app when printing all-but-last-n-lines of a file.
Code now checks if the last line of the input file is missing a terminating
newline character, and if so prints an extra line.
This aligns with GNU-head behavior.
Also improved performance of this usecase by using an optimized iterator
(memchr-iter) for searching through the input file.
2025-03-25 14:20:08 -06:00
Daniel Hofstetter df4dfea852 tests: replace run() with succeeds() or fails() 2025-03-09 16:53:56 +01:00
Sylvestre Ledru dedd644016 head: improve error mgmt.
And provide more details than GNU

Should fix tests/head/head-write-error
2025-03-07 11:24:54 +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
Karl McDowall ad20cb35a0 Head: ensure stdin input stream is correct on exit
Fix issue #7028
Head tool now ensures that stdin is set to the last character
that was output by the tool. This ensures that if any subsequent
tools are run from the same input stream they will start at the
correct point in the stream.
2025-02-26 11:41:29 -07:00
Karl McDowallandSylvestre Ledru 84b42a8ce4 head: Fix bug printing large non-seekable files
Fixes issue #7288.
Rewrite logic for print-all-but-last-n-bytes in non-seekable
files.
2025-02-12 10:16:44 +01:00
karlmcdowallandGitHub f94ff78ea4 head: fix bug reading back through files (#7248)
* head: fix bug reading back through files

Fix issue #7247.
Rework logic for reading/seeking backwards through files.
Bug was seen when reading back through large files.
Added test case to validate fix.
2025-02-03 20:13:46 +01:00
Daringcuteseal 9202f23787 tests/head: add test to write to /dev/full 2025-01-05 09:14:05 +07:00
Jeffrey Finkelstein c9acf5ddd4 head: fix subtraction underflow with --bytes=-N
Fix a subtraction underflow that occurred on `head --bytes=-N` when the
input had fewer than `N` bytes. Before this commit,

    printf "a" | head -c -2

would panic. After this commit, it terminates successfully with no
output as expected.
2024-12-30 21:07:45 -05:00