Commit graph

87 commits

Author SHA1 Message Date
Mikadore
5e1d52d4be cargo-fmt :DDD 2021-05-26 22:20:16 +02:00
Mikadore
64598d9e26 Closing #1916 2021-05-26 22:15:28 +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
rethab
231bb7be93
Migrate mknod to clap, closes #2051 (#2056)
* mknod: add tests for fifo

* mknod: add test for character device
2021-05-05 22:59:40 +02:00
Christopher Regali
368e984fac
Change unchecked unwrapping to unwrap_or_default for Args-trait (#1845) (#1852)
* Change unchecked unwrapping to unwrap_or_default for argument parsing (resolving #1845)

* Added unit-testing for the collect_str function on invalid utf8 OsStrs

* Added a warning-message for identification purpose to the collect_str method.

* - Add removal of wrongly encoded empty strings to basename
- Add testing of broken encoding to basename
- Changed UCommand to use collect_str in args method to allow for integration testing of that method
- Change UCommand to use unwarp_or_default in arg method to match the behaviour of collect_str

* Trying out a new pattern for convert_str for getting a feeling of how the API feels with more control

* Adding convenience API for compact calls

* Add new API to everywhere, fix test for basename

* Added unit-testing for the conversion options

* Added unit-testing for the conversion options for windows

* fixed compilation and some merge hiccups

* Remove windows tests in order to make merge request build

* Fix formatting to match rustfmt for the merged file

* Improve documentation of the collect_str method and the unit-tests

* Fix compilation problems with test

Co-authored-by: Christopher Regali <chris.vdop@gmail.com>
Co-authored-by: Sylvestre Ledru <sylvestre@debian.org>
2021-04-25 23:28:42 +02:00
Michael Debertol
2084c3ddf3 tests: show pretty diffs for assertion failures
- All assert_eq in tests/common/util.rs now print a pretty diff on test
failures.
- {stdout, stderr}_is_fixture now compare the expected output and the
fixture as Strings, which leads to more usable diffs.
2021-04-24 16:43:13 +02:00
Sylvestre Ledru
8ccc6ade61
Merge branch 'master' into split-wsl-detection 2021-04-24 10:24:13 +02:00
Jan Scheer
646c6cacbc refactor tests (#1982) 2021-04-23 02:28:46 +02:00
Gilad Naaman
c5d7f63b3c Make CmdResult::code private 2021-04-17 18:50:41 +03:00
Gilad Naaman
0d1946a5d2 cksum: Remove direct usage of CmdResult fields in tests 2021-04-17 15:08:23 +03:00
Sylvestre Ledru
fc057b816b
Merge branch 'master' into split-wsl-detection 2021-04-17 10:22:54 +02:00
Sylvestre Ledru
7ae5f1d751
Merge pull request #2054 from rethab/improve-cksum-test
allow ignoring stdin write errors in tests & fix flaky test
2021-04-17 00:49:17 +02:00
Gilad Naaman
4695667c7c Added sanity checks for test utils 2021-04-11 02:28:47 +03:00
Gilad Naaman
cd3dba2481 Added some tests utils for future refactoring 2021-04-11 02:27:16 +03:00
Árni Dagur
eb4971e6f4
cat: Unrevert splice patch (#2020)
* cat: Unrevert splice patch

* cat: Add fifo test

* cat: Add tests for error cases

* cat: Add tests for character devices

* wc: Make sure we handle short splice writes

* cat: Fix tests for 1.40.0 compiler

* cat: Run rustfmt on test_cat.rs

* Run 'cargo +1.40.0 update'
2021-04-10 22:19:53 +02:00
Aleksandar Janicijevic
18191f9212
shred: Implemented --force option (#2012) 2021-04-10 10:41:59 +02:00
Reto Hablützel
d51ca40986 allow ignoring stdin write errors in tests
* if we want to test an irregular scenario, ignoring errors caused by
    writing to stdin of the command can be uselful.

  * for example, when writing some text to stdin of cksum in a scenario
    where it doesn't consume this input, the child process might have
    exited before the text was written. therefore, this test sometimes
    fails with a 'Broken pipe'.
2021-04-09 11:16:36 +02:00
Terts Diepraam
c65483f4be tests: improve docstrings a bit 2021-04-07 11:48:21 +02:00
ReggaeMuffin
b1fcb621a8
wsl2: wsl no longer differs in output
refactor `is_wsl` to `is_wsl_1` and `is_wsl_2`

On my tests with wsl2 ubuntu2004 all tests pass without special cases

I moved wsl detection into uucore so that it can be shared instead of duplicated

I moved `parse_mode` into uucode as it seemed to fit there better and anyway requires libc feature
2021-04-06 10:58:49 +01:00
ReggaeMuffin
2eb32d845e
chores: run cargo +1.40.0 fmt
Apparently fmt from 1.40.0 is a bit more strict in some places

Let me know if this is worthwhile merging :)
2021-04-02 10:56:49 +01:00
Sylvestre Ledru
dcbcf01665 Fix some clippy warnings 2021-04-01 23:42:30 +02:00
paulotten
090d29496a
Issue #1622 port du to windows (#1788)
* Issue #1622 port `du` to windows

* Attempt to support Rust 1.32

Old version was getting "attributes are not yet allowed on `if`
expressions" on Rust 1.32

* Less #[cfg]

* Less duplicate code.

I need the return and the semicolon after if otherwise the second #[cfg]
leads to unexpected token complilation error

* More accurate size on disk calculations for windows

* Expect the same output on windows as with WSL

* Better matches output from du on WSL

* In the absence of feedback I'm disabling these tests on Windows.
They require `ln`. Windows does not ship with this utility.

* Use the coreutils version of `ln` to test `du`

`fn ccmd` is courtesy of @Artoria2e5

* Look up inodes (file ids) on Windows

* One more #[cfg(windows)] to prevent unreachable statement warning on linux
2021-04-01 23:16:47 +02:00
Mikadore
b8079098f2 fixed panic! formatting 2021-03-31 13:30:06 +02:00
Mikadore
96643d6f91
fix #1970 (#1980) 2021-03-31 03:54:16 -07:00
Mikadore
a57f17ac5b
Expand CmdResult's API (#1977) 2021-03-31 02:25:23 -07:00
Ricardo Iglesias
5f17719a59
Implemented --indicator-style flag on ls. (#1907)
* Implemented --indicator-style flag on ls.

* Rust fmt

* Grouped indicator_style args.

* Added tests for sockets and pipes.

Needed to modify util.rs to add support for pipes (aka FIFOs).

* Updated util.rs to remove FIFO operations on Windows

* Fixed slight error in specifying (not(windows))

* Fixed style violations and added indicator_style test for non-unix systems
2021-03-29 13:10:13 +02:00
Neculai Balaban
93c7cbe65e documentation for usual macros
- removed repeat_str helper as it's now part of std
- added docstrings for usual macros and test utils
2021-03-22 12:13:38 +02:00
Jan Scheer
47f50a0f5f
tests/utils: fixed mode for write (#1802)
added `log_info`
2021-03-12 22:26:27 +01:00
Ali
5ced3a670b
paste: cleanup multi-stdin support (#1803)
cleaner impl for multi-stdin support
2021-03-12 13:26:09 +01:00
Alex Lyon
5431e947bc
uucore: process: fix exit status processing (#1743)
* uucore: process: fix exit status processing

* tests: timeout: check whether subcommand exit codes are returned
2021-02-23 10:21:01 +01:00
Sylvestre Ledru
992c113f09 Remove some old code 2021-01-22 09:40:38 +01:00
Sylvestre Ledru
e331186fee
unbreak build with rustc 1.32: force tempfile 3.1.0 (#1695) 2021-01-19 08:15:53 +01:00
Felipe Lema
88911be6e0
--filter argument for split (#1681) 2021-01-18 14:42:44 +01:00
Roy Ivy III
cbac6cc903 tests ~ increase test detail to diagnose MacOS hostname test failure 2020-06-14 23:38:30 -05:00
Roy Ivy III
407d455b12 tests ~ add is_ci() test 2020-06-14 12:20:31 -05:00
Sylvestre Ledru
ac34d136f2 refactor(global): Move from tempdir to tempfile:
* the crate has been deprecated
2020-06-09 11:30:19 +02:00
Roy Ivy III
039638de0e tests ~ use CARGO_PKG_NAME as name of binary used for testing 2020-05-29 22:59:47 -05:00
Roy Ivy III
75f05df119 refactor/polish ~ fix cargo clippy complaints (redundant_static_lifetimes) 2020-04-11 18:50:10 -05:00
Roy Ivy III
5af8503a5e cargo fmt 2020-01-28 00:05:06 -06:00
Roy Ivy III
14c3f3aa17 tests ~ fix WSL testing
+ ToDO added ~ when possible, test under WSL2 and differentiate/liberalize if possible
2020-01-27 21:33:47 -06:00
Roy Ivy III
d0f6f3d07e tests/refactor ~ change output test macros to 'actual = expected' format
- rust usually uses `assert_eq!(ACTUAL, EXPECTED)`
- ref: https://users.rust-lang.org/t/assert-eq-expected-and-actual/20304/3 @@ https://archive.is/xPp9R
2020-01-27 21:33:47 -06:00
Roy Ivy III
b4b0ee40d7 refactor/polish ~ convert to try! to ? syntax
- convert to newer `?` syntax, fixing compiler warnings

+ requires MinSRV >= v1.13.0

.# [why]

The `?` operator was stabilized in rust v1.13.0.

Warnings requesting conversion from the old `try!` macro to the `?` operator
were introduced in rust v1.39.0.

* ref: <https://github.com/rust-lang/rust/blob/master/RELEASES.md>
2020-01-27 21:33:47 -06:00
Alex Lyon
179de609b5 Replace trim_{left,right} with trim_{start,end} and co. (using Rerast) 2019-05-01 21:14:25 -07:00
Alex Lyon
c7d115b1ad Convert all try!() to ? 2019-05-01 21:14:25 -07:00
Roy Ivy III
f72fff7b42 augment UCommand with #[derive(Debug)] to allow improved test diagnostics 2019-04-29 09:46:15 -05:00
Reto Habluetzel
2d2042c8fc env: reject program with --null, error stderr 2019-04-28 11:17:44 +02:00
Alex Lyon
23f6dbf2d3
Merge pull request #1306 from rinconjc/1235
tests: untrimmed stdout assertion (fix #1235)
2019-04-05 22:22:18 -07:00
Julio Rincon
29c6ad5f6a tests: untrimmed stdout assertion (fix #1235) 2019-02-08 07:54:48 +11:00
Roy Ivy III
f3d43d775a fix ~ correct symlink creation in tests 2019-02-07 08:30:51 -06:00
Alex Lyon
880a4973c1 Format everything using rustfmt 2018-03-12 01:20:58 -07:00