Skip to content

Commit

Permalink
cut: first take on delimiters refactor (#4)
Browse files Browse the repository at this point in the history
* ci: use codecov token in CICD/GnuTests workflows

* tee: fail test if string setup fails

* sort: add skipped test for combined flags

Now that clap#2624 has been resolved, we can and should test both variants.

* cat: don't flake even on exotic pipe buffer sizes

See also 9995c63.

There is a race condition between the writing thread and the command.
It is easily possible that on the developer's machine, the writing
thread is always faster, filling the kernel's buffer of the stdin pipe,
thus succeeding the write. It is also easily possible that on the busy
CI machines, the child command runs first for whatever reason, and exits
early, thus killing the pipe, which causes the later write to fail. This
results in a flaky test. Let's prevent flaky tests.

* numfmt: don't flake even on exotic pipe buffer sizes

* split: don't flake even on exotic pipe buffer sizes

* simulate terminal utility (squash)

* workaround: run builds with retry (a)

* added configurable terminal size

* chore(deps): update rust crate rayon to 1.9

* cargo: fix feature = "cargo-clippy" deprecation

* tests/printf: Fix char_as_byte test, add char and string padding tests

* printf: Change get_char and write_padded to handle bytes instead of chars

* uucore/format: add padlen to spell-checker:ignore

* tests/printf: Verify the correct error behavior of printf when provided with '%0c' or '%0s'

* printf: Raise error on '%0c' and '%0s' formats

* cp: fix flaky test test_cp_arg_interactive_update, document adjacent bug

* chore(deps): update rust crate walkdir to 2.5

* cat: permit repeating command-line flags

* cat: fix -b and -n anti-symmetry

* cat: ignore -u flag, just like GNU does

* tests/common/util.rs: add cfg(feature = "env")

* cat: prefix two test fns with "test_"

* Bump mio from 0.8.10 to 0.8.11

* extend error message for case when writer instanciation fails second time

* chmod: slightly adjust error message when preserve-root is triggered

One of the GNU tests checks for the exact error message.

* chgrp+chown: also trigger preserve-root during dirwalking, fix error message

This is explicitly tested in the GNU tests.

* uucore: drop unused function resolve_relative_path

This function is by necessity ill-defined: Depending on the context,
'..' is either the logical parent directory, sometimes the physical
parent directory. This function can only work for the latter case,
in which case `Path::canonicalize` is often a better approach.

* split: close as much fds as needed for opening new one

* use std::command::pre_exec() to set limits on child before exec

* chore(deps): update softprops/action-gh-release action to v2

* cut: first take on delimiters refactor

* cut: clippy and windows errors

* cut: refactor delimiters + tests

* cut: comments

* cut: comments

---------

Co-authored-by: Daniel Hofstetter <daniel.hofstetter@42dh.com>
Co-authored-by: Ben Wiederhake <BenWiederhake.GitHub@gmx.de>
Co-authored-by: Ulrich Hornung <hornunguli@gmx.de>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: Sylvestre Ledru <sylvestre@debian.org>
Co-authored-by: Dimitris Apostolou <dimitris.apostolou@icloud.com>
Co-authored-by: Dorian Péron <dorianperon.i@gmail.com>
Co-authored-by: Terts Diepraam <terts.diepraam@gmail.com>
  • Loading branch information
9 people committed Mar 12, 2024
1 parent 6d58744 commit 7d10c78
Show file tree
Hide file tree
Showing 29 changed files with 1,144 additions and 299 deletions.
2 changes: 1 addition & 1 deletion .cargo/config.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[target.x86_64-unknown-redox]
linker = "x86_64-unknown-redox-gcc"

[target.'cfg(feature = "cargo-clippy")']
[target.'cfg(clippy)']
rustflags = [
"-Wclippy::use_self",
"-Wclippy::needless_pass_by_value",
Expand Down
5 changes: 2 additions & 3 deletions .github/workflows/CICD.yml
Original file line number Diff line number Diff line change
Expand Up @@ -748,7 +748,7 @@ jobs:
fakeroot dpkg-deb --build "${DPKG_DIR}" "${{ steps.vars.outputs.STAGING }}/${{ steps.vars.outputs.DPKG_NAME }}"
fi
- name: Publish
uses: softprops/action-gh-release@v1
uses: softprops/action-gh-release@v2
if: steps.vars.outputs.DEPLOY
with:
files: |
Expand Down Expand Up @@ -1043,9 +1043,8 @@ jobs:
echo "report=${COVERAGE_REPORT_FILE}" >> $GITHUB_OUTPUT
- name: Upload coverage results (to Codecov.io)
uses: codecov/codecov-action@v4
# if: steps.vars.outputs.HAS_CODECOV_TOKEN
with:
# token: ${{ secrets.CODECOV_TOKEN }}
token: ${{ secrets.CODECOV_TOKEN }}
file: ${{ steps.coverage.outputs.report }}
## flags: IntegrationTests, UnitTests, ${{ steps.vars.outputs.CODECOV_FLAGS }}
flags: ${{ steps.vars.outputs.CODECOV_FLAGS }}
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/GnuTests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -399,6 +399,7 @@ jobs:
- name: Upload coverage results (to Codecov.io)
uses: codecov/codecov-action@v4
with:
token: ${{ secrets.CODECOV_TOKEN }}
file: ${{ steps.coverage.outputs.report }}
flags: gnutests
name: gnutests
Expand Down
16 changes: 8 additions & 8 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,7 @@ platform-info = "2.0.2"
quick-error = "2.0.1"
rand = { version = "0.8", features = ["small_rng"] }
rand_core = "0.6"
rayon = "1.8"
rayon = "1.9"
redox_syscall = "0.4"
regex = "1.10.3"
rstest = "0.18.2"
Expand All @@ -328,7 +328,7 @@ time = { version = "0.3" }
unicode-segmentation = "1.11.0"
unicode-width = "0.1.11"
utf-8 = "0.7.6"
walkdir = "2.4"
walkdir = "2.5"
winapi-util = "0.1.6"
windows-sys = { version = "0.48.0", default-features = false }
xattr = "1.3.1"
Expand Down Expand Up @@ -495,10 +495,10 @@ rstest = { workspace = true }

[target.'cfg(any(target_os = "linux", target_os = "android"))'.dev-dependencies]
procfs = { version = "0.16", default-features = false }
rlimit = "0.10.1"

[target.'cfg(unix)'.dev-dependencies]
nix = { workspace = true, features = ["process", "signal", "user"] }
nix = { workspace = true, features = ["process", "signal", "user", "term"] }
rlimit = "0.10.1"
rand_pcg = "0.3"
xattr = { workspace = true }

Expand Down
11 changes: 10 additions & 1 deletion src/uu/cat/src/cat.rs
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,7 @@ mod options {
pub static SHOW_NONPRINTING_TABS: &str = "t";
pub static SHOW_TABS: &str = "show-tabs";
pub static SHOW_NONPRINTING: &str = "show-nonprinting";
pub static IGNORED_U: &str = "ignored-u";
}

#[uucore::main]
Expand Down Expand Up @@ -231,6 +232,7 @@ pub fn uu_app() -> Command {
.override_usage(format_usage(USAGE))
.about(ABOUT)
.infer_long_args(true)
.args_override_self(true)
.arg(
Arg::new(options::FILE)
.hide(true)
Expand All @@ -249,7 +251,8 @@ pub fn uu_app() -> Command {
.short('b')
.long(options::NUMBER_NONBLANK)
.help("number nonempty output lines, overrides -n")
.overrides_with(options::NUMBER)
// Note: This MUST NOT .overrides_with(options::NUMBER)!
// In clap, overriding is symmetric, so "-b -n" counts as "-n", which is not what we want.
.action(ArgAction::SetTrue),
)
.arg(
Expand Down Expand Up @@ -299,6 +302,12 @@ pub fn uu_app() -> Command {
.help("use ^ and M- notation, except for LF (\\n) and TAB (\\t)")
.action(ArgAction::SetTrue),
)
.arg(
Arg::new(options::IGNORED_U)
.short('u')
.help("(ignored)")
.action(ArgAction::SetTrue),
)
}

fn cat_handle<R: FdReadable>(
Expand Down
2 changes: 1 addition & 1 deletion src/uu/chmod/src/chmod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@ impl Chmoder {
return Err(USimpleError::new(
1,
format!(
"it is dangerous to operate recursively on {}\nuse --no-preserve-root to override this failsafe",
"it is dangerous to operate recursively on {}\nchmod: use --no-preserve-root to override this failsafe",
filename.quote()
)
));
Expand Down
Loading

0 comments on commit 7d10c78

Please sign in to comment.