Commit graph

4682 commits

Author SHA1 Message Date
nicoo
a0a103b15e factor::table::chunked: Add test (equivalent to the single-number version) 2021-05-20 17:01:33 +02:00
nicoo
998b3c11d3 factor: Make random Factors instance generatable for tests 2021-05-20 17:00:49 +02:00
Sylvestre Ledru
52a7e07b3e
Merge pull request #2226 from nbraud/pin-GNU-tests
CI: Stabilise the version of GNU tests used in CI
2021-05-20 16:30:32 +02:00
Sylvestre Ledru
743db76056
Merge pull request #2238 from jfinkels/truncate-refactor-parse-size
truncate: simplify parse_size() function and correct error message
2021-05-20 08:21:19 +02:00
Jeffrey Finkelstein
63b496eaa8 truncate: refactor parse_size() function
Change the interface provided by the `parse_size()` function to reduce
its responsibilities to just a single task: parsing a number of bytes
from a string of the form '123KB', etc. Previously, the function was
also responsible for deciding which mode truncate would operate in.

Furthermore, this commit simplifies the code for parsing the number and
unit to be less verbose and use less mutable state.

Finally, this commit adds some unit tests for the `parse_size()`
function.
2021-05-19 23:07:11 -04:00
Sylvestre Ledru
0c6a848314
gnu results: also add the date (#2236) 2021-05-19 20:33:28 +02:00
Sylvestre Ledru
34d13324bf
Merge pull request #2233 from sylvestre/gnu
publish the results of the gnu testsuite as a json file too
2021-05-19 11:07:54 +02:00
Chad Brewbaker
9167a4128d
Update test_cat.rs
Refactored to constants
2021-05-19 04:06:46 -05:00
Sylvestre Ledru
ddf3c9cfcf
Merge pull request #2235 from jhscheer/fix_clippy_warnings
fix clippy warnings
2021-05-19 09:36:05 +02:00
Jan Scheer
8032c6d750 fix clippy warnings 2021-05-19 01:37:28 +02:00
Sylvestre Ledru
7bf342fa52 publish the results of the gnu testsuite as a json file too 2021-05-18 23:05:49 +02:00
Chad Brewbaker
a69cb11de9 Removing debug code 2021-05-18 15:17:07 -05:00
Chad Brewbaker
c60d3866c3 dev random blocks on linux 2021-05-18 15:10:51 -05:00
Sylvestre Ledru
cacd078a49
Merge pull request #2227 from jfinkels/tail-iocopy-bounded-tail
tail: use std::io::copy() to write bytes to stdout
2021-05-18 20:42:59 +02:00
Sylvestre Ledru
de5c1d90db
Merge pull request #2232 from jhscheer/stat_test_refactor
stat: remove unused/duplicate tests
2021-05-18 20:42:33 +02:00
Jan Scheer
ce5b852a31 stat: remove unused/duplicate tests 2021-05-18 19:58:33 +02:00
Sylvestre Ledru
3977eb8934
Merge pull request #2229 from jhscheer/issue_2223
tests: add test for issue #2223
2021-05-18 11:32:57 +02:00
Jan Scheer
7c7d622d54 tests: add test for issue #2223 2021-05-18 02:00:16 +02:00
Jeffrey Finkelstein
bc29645531 tail: fix off-by-one issue for +NUM args
Fix an off-by-one issue for `tail -c +NUM` and `tail -n +NUM` command
line options.
2021-05-17 19:45:42 -04:00
Jeffrey Finkelstein
fea1026669 tail: use std::io::copy() to write bytes to stdout 2021-05-17 18:15:39 -04:00
Sylvestre Ledru
dc02c36a6a
Merge pull request #2225 from sylvestre/gnu
gh action: fix the GNU testsuite job
2021-05-17 22:51:06 +02:00
Jan Scheer
dc93f29fe3 CICD: install GNU coreutils on macOS 2021-05-17 22:22:18 +02:00
Sylvestre Ledru
047d775e5e gh action: fix the GNU testsuite job 2021-05-17 21:24:58 +02:00
nicoo
f46b119493 CI: Stabilise the version of GNU tests used in CI
The “GNU tests” task is routinely broken on `master`.
Broken CI is worse than no CI, as it teaches people to ignore errors.

This PR pins the versions of the GNU testsuite (and GNUlib) used,
to current stable versions, so this task stops breaking unexpectedly.

Presumably, someone will update `GNU.yml` when a new stable version
of the GNU coreutils is released, but I'm not volunteering.
2021-05-17 21:07:05 +02:00
nicoo
9afed1f25f Update Cargo.lock
Adding array-init v2.0.0
Updating cast v0.2.5 -> v0.2.6
  Adding pest v2.1.3
Updating rustc_version v0.2.3 -> v0.3.3
  Adding semver v0.11.0
  Adding semver-parser v0.10.2
Updating serde v1.0.125 -> v1.0.126
Updating serde_derive v1.0.125 -> v1.0.126
  Adding ucd-trie v0.1.3
  Adding uu_factor_benches v0.0.0 (#tests/benches/factor)
2021-05-17 19:45:02 +02:00
nicoo
00322b986b factor: Move benchmarks out-of-crate 2021-05-17 19:43:38 +02:00
nicoo
1cd001f529 factor::benches::table: Match BenchmarkId w/ criterion's conventions
See https://bheisler.github.io/criterion.rs/book/user_guide/comparing_functions.html
2021-05-17 19:43:38 +02:00
nicoo
7c649bc74e factor::benches: Add check against ASLR 2021-05-17 19:43:38 +02:00
nicoo
ddfcd2eb14 factor::benchmarking: Add wishlist / planned work 2021-05-17 19:43:38 +02:00
nicoo
1d75f09743 factor::benchmarking(doc): Add guidance on writing µbenches 2021-05-17 19:43:38 +02:00
nicoo
e9f8194266 factor::benchmarking(doc): Add guidance on running µbenches 2021-05-17 19:43:38 +02:00
nicoo
ae15bf16a8 factor::benches::table: Report throughput (in numbers/s) 2021-05-17 19:43:38 +02:00
nicoo
12efaa6add factor: Add BENCHMARKING.md 2021-05-17 19:43:38 +02:00
nicoo
7c287542c7 factor::table: Fixup microbenchmark
Previous version would perform an amount of work proportional to `CHUNK_SIZE`,
so this wasn't a valid way to benchmark at multiple values of that constant.

The `TryInto` implementation for `&mut [T]` to `&mut [T; N]` relies on `const`
generics, and is available in (stable) Rust v1.51 and later.
2021-05-17 19:43:38 +02:00
nicoo
1fd5f9da25 factor::table::factor_chunk: Turn loop inside-out
This keeps the traversal of `P_INVS_U64` (a large table) to a single pass
in-order, rather than `CHUNK_SIZE` passes.
2021-05-17 19:43:38 +02:00
nicoo
cd047425aa factor::table: Add chunked implementation and microbenchmarks
The factor_chunk implementation is a strawman, but getting it in place allows us
to set up the microbenchmarking etc.
2021-05-17 19:43:38 +02:00
nicoo
c68c83c6dd factor::table: Take mutable refs
This will be easier to adapt to working with multiple numbers to process at once.
2021-05-17 19:43:38 +02:00
Jeffrey Finkelstein
eeef8290df head: display errors for each input file
Change the behavior of `head` to display an error for each problematic
file, instead of displaying an error message for the first problematic
file and terminating immediately at that point. This change now matches
the behavior of GNU `head`.

Before this commit, the first error caused the program to terminate
immediately:

    $ head a b c
    head: error: head: cannot open 'a' for reading: No such file or directory

After this commit:

    $ head a b c
    head: cannot open 'a' for reading: No such file or directory
    head: cannot open 'b' for reading: No such file or directory
    head: cannot open 'c' for reading: No such file or directory
2021-05-17 08:19:47 -04:00
Sylvestre Ledru
6c830e2f25
Merge pull request #2220 from chadbrewbaker/fix-ls-test-regex
fixing regex to take negative time offsets
2021-05-17 08:17:19 +02:00
Chad Brewbaker
2f84f59573 fixing regex to take negative time offsets 2021-05-16 19:43:53 -05:00
Michael Debertol
fcd48813e0 sort: read files as chunks, off-thread
Instead of using a BufReader and reading each line separately,
allocating a String for each one, we read to a chunk. Lines are
references to this chunk. This makes the allocator's job much easier
and yields performance improvements.

Chunks are read on a separate thread to further improve performance.
2021-05-16 21:13:37 +02:00
Sylvestre Ledru
9e2c82d8e7
Merge pull request #2217 from jfinkels/head-multiple-files
head: print headings when reading multiple files
2021-05-16 18:28:31 +02:00
Jeffrey Finkelstein
659bf58a4c head: print headings when reading multiple files
Fix a bug in which `head` failed to print headings for `stdin` inputs
when reading from multiple files, and fix another bug in which `head`
failed to print a blank line between the contents of a file and the
heading for the next file when reading multiple files. The output now
matches that of GNU `head`.
2021-05-16 12:03:10 -04:00
Sylvestre Ledru
7d2b6409e2
Merge pull request #2216 from jfinkels/head-refactor-rbuf-n-bytes
head: simplify rbuf_n_bytes() in head.rs
2021-05-16 12:25:53 +02:00
Jeffrey Finkelstein
733d347fa8 head: simplify rbuf_n_bytes() in head.rs
Simplify the code in `rbuf_n_bytes()` to use existing abstractions
provided by the standard library.
2021-05-15 23:04:01 -04:00
Jeffrey Finkelstein
97a49c7c95 wc: compute min width to format counts up front
Fix two issues with the string formatting width for counts displayed
by `wc`.

First, the output was previously not using the default minimum width
(seven characters) when reading from `stdin`. This commit corrects
this behavior to match GNU `wc`. For example,

    $ cat alice_in_wonderland.txt | wc
          5      57     302

Second, if at least 10^7 bytes were read from `stdin` *after* reading
from a smaller regular file, then every output row would have width
8. This disagrees with GNU `wc`, in which only the `stdin` row and the
total row would have width 8. This commit corrects this behavior to
match GNU `wc`. For example,

    $ printf "%.0s0" {1..10000000} | wc emptyfile.txt -
	  0       0       0 emptyfile.txt
	  0       1 10000000
	  0       1 10000000 total

Fixes #2186.
2021-05-15 21:41:47 -04:00
Sylvestre Ledru
620a5a5df6
Merge pull request #2210 from jhscheer/dns_lookup
who: fix `--lookup`
2021-05-15 21:18:12 +02:00
Sylvestre Ledru
46cf61b5b7
Merge pull request #2212 from jfinkels/2211-wc-error-messages
wc: correct some error messages for invalid inputs
2021-05-15 21:14:15 +02:00
Jeffrey Finkelstein
e8d911d9d5 wc: correct some error messages for invalid inputs
Change the error messages that get printed to `stderr` for compatibility
with GNU `wc` when an input is a directory and when an input does not
exist.

Fixes #2211.
2021-05-15 10:35:21 -04:00
Jan Scheer
a4fc2b5106 who: fix --lookup
This closes #2181.

`who --lookup` is failing with a runtime panic (double free).
Since `crate::dns-lookup` already includes a safe wrapper for `getaddrinfo`
I used this crate instead of further debugging the existing code in
utmpx::canon_host().

* It was neccessary to remove the version constraint for libc in uucore.
2021-05-13 22:16:15 +02:00