Commit graph

51 commits

Author SHA1 Message Date
n4n5
ab67947321
fix clippy tests 2024-06-30 16:27:08 +02:00
sreehari prasad
3c096ee6ac
util: added umask manipulation (#6404)
Co-authored-by: Terts Diepraam <terts.diepraam@gmail.com>
2024-05-19 21:56:41 +02:00
binlingyu
9d1d4cc5f6 Fix warning when executing Clippy 2024-04-17 11:14:03 +08:00
Matei Mantu
095eced4be
chmod: Fix chmod -c --reference reporting when no change is made (#6016)
* Make fperm hold 6 digit octal permission. Set it to 4 digits when displaying

* Add test

* Make every permission 4 octal digits

* Change test name to be more suggestive

* chmod: merge two args in test

---------

Co-authored-by: Daniel Hofstetter <daniel.hofstetter@42dh.com>
2024-02-26 11:01:50 +01:00
Sylvestre Ledru
bfca6bf70f Add license headers on all files 2023-08-21 10:49:27 +02:00
Sylvestre Ledru
75e33695e5 Disable test_gnu_options on android 2023-04-30 20:08:06 +02:00
Sylvestre Ledru
ac068e0487 Disable test_sort::test_compress_fail & test_chmod::test_mode_after_dash_dash on android 2023-04-29 19:23:56 +02:00
Daniel Hofstetter
7a888da409 tests: remove all "extern crate" statements 2023-04-10 08:31:31 +02:00
Daniel Hofstetter
6988eb7ec6 tests: expand wildcard imports 2023-03-20 15:32:35 +01:00
leon3s
be51f9aa5b fix: clippy long literal lacking separators 2023-03-19 15:01:59 +01:00
Benjamin Bara
e982d57819 chmod: fix GNU test 'chmod/usage' 2023-03-16 21:25:26 +01:00
Benjamin Bara
787d854f89 chmod: add GNU usage tests 2023-03-16 21:16:51 +01:00
David Matos
d9a21ff8f0 chmod: allow verbose and quiet flags to be used more than once 2023-02-23 20:21:38 +01:00
Terts Diepraam
6bd42fde6a
Merge pull request #4293 from Joining7943/tests-util-refactor-ucommand-add-run-in-shell
`tests/util`: Small Refactor/Fixes of `UCommand` and add method to run a `UCommand` in a shell platform independently
2023-02-21 22:41:20 +01:00
David Matos
dd4299c32e chmod: supress verbose output when not verbose 2023-02-20 22:18:07 +01:00
Joining7943
1c230fd779 tests/util: Refactor UCommand and TestScenario.
Summary of changes in UCommand:
* Extend UCommand by builder methods and simplify methods in TestScenario
* Simplify code structures where possible. Add documentation.
* Store bin_path as PathBuf and util_name as String in all structs
* Remove UCommand::util and make bin_path, temp_dir private
* Rename UCommand::with_limit -> UCommand::limit

Summary of changes in TestScenario:
* Rename some parameters in TestScenario methods to be more descriptive
* Remove ucmd_keepenv, cmd_keepenv from TestScenario. Use UCommand::keep_env instead.
2023-02-18 23:38:20 +01:00
Joining7943
fdf0f96a01 tests/util: Restructure UCommand to run in shell per default. Introduce constant TESTS_BINARY.
Summary of changes in tests/util:

* Introduce global constant TESTS_BINARY holding the path to `coreutils`
* Implement running an arbitrary command in a sh or cmd shell per default.
* Implement std::fmt::Display for UCommand.
* Change usages of UCommand::util_name from &Option<OsStr> to Option<OsStr>
* `UCommand::new_from_tmp`: Use OsStr directly instead of TempDir -> String -> OsStr
* Collect arguments in `UCommand::args` field
* Build environment variables in `UCommand` itself instead of `std::process::Command`
* Move building of std::process:Command from fields in UCommand to own method `build`
* Remove assertions of UCommand::has_run in arg, args and env.

Summary of changes in tests/by-util:

* Remove usages of UCommand::raw. Fix tests to use UCommand::to_string.
* test_test: Adjust test_invalid_utf8_integer_compare to use `UCommand::args`
* test_chmod: run_single_test
* test_pwd: symlinked_env
* test_cp:
    Fix the usage of &Option<OsStr> in `test_src_base_dot`
    Refactor test_src_base_dot to not use UCommand::new but ts.ucmd() instead
2023-02-17 17:39:33 +01:00
David Matos
946c8d2d4a chmod: change permissions for files present even when there is a missing file 2023-02-16 23:13:06 +01:00
Daniel Hofstetter
f6b646e4e5 clippy: fix warnings introduced with Rust 1.67.0 2023-01-27 17:37:56 +01:00
Joining7943
1fadeb43b2 tests/util: Do not trim stderr in CmdResult::stderr_is. Add method stderr_trimmed_is.
Fix tests assert whitespace instead of trimming it. Disable some tests in `test_tr` because `tr`
produces too many newlines.
2023-01-22 14:56:19 +01:00
Sylvestre Ledru
6e14dea73b Fix some clippy warnings
Fixed with `cargo clippy --features unix  --fix`
and manually
2022-10-13 09:07:22 +02:00
Terts Diepraam
9177cb7b24 all: add tests for usage error exit code 2022-09-10 20:59:42 +02:00
Jamie Quigley
1a270361c0
Replace lazy_static with once_cell 2022-07-12 14:08:30 +01:00
Terts Diepraam
18369dc0be all: use array intoiterator 2022-04-05 10:39:31 +02:00
xxyzz
ce385be575
chmod: ignore symbolic links during recursive directory traversal 2022-03-06 09:38:39 +08:00
xxyzz
3272a590db
test_chmod: update expected results of test_chmod_recursive
The test succeeds before because the files are read before the permission change and that's inconsistent with GNU chmod.
2022-03-06 08:40:36 +08:00
xxyzz
9083f236da
test_chmod: add read permission recursively test 2022-03-06 08:40:36 +08:00
Daniel Eades
a2d5f06be4 remove needless pass by value 2022-01-30 15:08:26 +01:00
Thomas Queiroz
fed596a23b
tests/chmod: change normal error to usage error 2021-11-12 19:07:37 -03:00
James Robson
0b2483452a Add symbolic mode support to mkdir 2021-10-16 12:57:55 +01:00
Michael Debertol
5121e2eec1 chmod: add check for quiet 2021-08-25 13:52:09 +02:00
Michael Debertol
5825889931 chmod: correctly handle modes after -- 2021-08-25 13:52:09 +02:00
Michael Debertol
b841a11421 chmod: fail if the operand list is empty 2021-08-25 13:52:09 +02:00
Michael Debertol
945e57ea22 chmod: show an error if a permission wasn't removed due to umask 2021-08-25 13:52:09 +02:00
Michael Debertol
15b40f6aa2 chmod: implement special handling of directory setuid/setgid 2021-08-25 13:52:09 +02:00
Michael Debertol
74958794c6 chmod: print change message to stdout, not stderr 2021-08-25 13:52:09 +02:00
Michael Debertol
080998b6ef chmod: pad all file modes to 4 digits 2021-08-25 13:52:09 +02:00
Roy Ivy III
4e20dedf58 tests ~ refactor/polish spelling (comments, names, and exceptions) 2021-05-31 08:23:57 -05:00
Jan Scheer
3aeccfd802 fix a lot of clippy warnings 2021-05-29 15:11:22 +02:00
Dean Li
fe25b51a66
chmod: match GNU error
Related to #2260

Signed-off-by: Dean Li <deantvv@gmail.com>
2021-05-26 22:31:02 +08:00
Yağız can Değirmenci
071899d24d tests: delete 'error:' prefix from the tests 2021-05-26 02:45:53 +03:00
Jan Scheer
646c6cacbc refactor tests (#1982) 2021-04-23 02:28:46 +02:00
Sylvestre Ledru
c5b43c0994 rustfmt the recent change 2021-04-17 13:21:30 +02:00
Gilad Naaman
81d42aa2b3 Fix some tests to not use CmdResult fields 2021-04-10 23:30:50 +03:00
Mikadore
b8079098f2 fixed panic! formatting 2021-03-31 13:30:06 +02:00
Jan Scheer
2647a72e9e chmod: fixed behavior for dangling symlinks (#1775) 2021-03-29 22:07:09 +02:00
Jan Scheer
a9a3794d5a chmod: add tests 2021-03-28 20:56:37 +02:00
Sylvestre Ledru
18370f39b8 Remove some warnings 2021-01-22 09:40:38 +01:00
Sylvestre Ledru
013bb285cd
bug(chmod): chmod on symlink pointing to non existing file is failing (#1694) 2021-01-18 23:09:00 +01:00
Sylvestre Ledru
576aa29f0f
refactor(chmod): move from walker to walkdir, simplify the code and add tests (#1645) 2020-12-12 10:31:12 +01:00