Skip to content

Commit 40d48c2

Browse files
authored
Merge branch 'uutils:main' into main
2 parents 3e90bfe + 50f8d0b commit 40d48c2

5 files changed

Lines changed: 64 additions & 23 deletions

File tree

.github/workflows/openbsd.yml

Lines changed: 24 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -85,8 +85,7 @@ jobs:
8585
# * determine sub-crate utility list
8686
UTILITY_LIST="\$(./util/show-utils.sh --features ${{ matrix.job.features }})"
8787
## Info
88-
# environment
89-
echo "## environment"
88+
echo "::group::environment"
9089
echo "CI='${CI}'"
9190
echo "REPO_NAME='${REPO_NAME}'"
9291
echo "TEST_USER='${TEST_USER}'"
@@ -95,24 +94,27 @@ jobs:
9594
echo "FAULT_PREFIX='\${FAULT_PREFIX}'"
9695
echo "UTILITY_LIST='\${UTILITY_LIST}'"
9796
env | sort
98-
# tooling info
99-
echo "## tooling info"
97+
echo "::endgroup::"
98+
echo "::group::tooling info"
10099
cargo -V
101100
rustc -V
101+
echo "::endgroup::"
102102
#
103103
# To ensure that files are cleaned up, we don't want to exit on error
104104
set +e
105105
unset FAULT
106106
## cargo fmt testing
107-
echo "## cargo fmt testing"
107+
echo "::group::cargo fmt"
108108
# * convert any errors/warnings to GHA UI annotations; ref: <https://help.github.com/en/actions/reference/workflow-commands-for-github-actions#setting-a-warning-message>
109109
S=\$(cargo fmt -- --check) && printf "%s\n" "\$S" || { printf "%s\n" "\$S" ; printf "%s\n" "\$S" | sed -E -n -e "s/^Diff[[:space:]]+in[[:space:]]+\${PWD//\//\\\\/}\/(.*)[[:space:]]+at[[:space:]]+[^0-9]+([0-9]+).*\$/::\${FAULT_TYPE} file=\1,line=\2::\${FAULT_PREFIX}: \\\`cargo fmt\\\`: style violation (file:'\1', line:\2; use \\\`cargo fmt -- \"\1\"\\\`)/p" ; FAULT=true ; }
110+
echo "::endgroup::"
110111
## cargo clippy lint testing
111112
if [ -z "\${FAULT}" ]; then
112-
echo "## cargo clippy lint testing"
113+
echo "::group::cargo clippy"
113114
CLIPPY_ARGS="--features ${{ matrix.job.features }} --fault-type \${FAULT_TYPE}"
114115
if [ -n "\${FAIL_ON_FAULT}" ]; then CLIPPY_ARGS="\${CLIPPY_ARGS} --fail-on-fault"; fi
115116
python3 util/run-clippy.py \${CLIPPY_ARGS} || FAULT=true
117+
echo "::endgroup::"
116118
fi
117119
# Clean to avoid to rsync back the files and free up disk space
118120
cargo clean
@@ -179,18 +181,18 @@ jobs:
179181
mkdir -p ~/.cargo/bin
180182
# Note: nextest might not have OpenBSD builds, so we'll use regular cargo test
181183
## Info
182-
# environment
183-
echo "## environment"
184+
echo "::group::environment"
184185
echo "CI='${CI}'"
185186
echo "REPO_NAME='${REPO_NAME}'"
186187
echo "TEST_USER='${TEST_USER}'"
187188
echo "WORKSPACE_PARENT='${WORKSPACE_PARENT}'"
188189
echo "WORKSPACE='${WORKSPACE}'"
189190
env | sort
190-
# tooling info
191-
echo "## tooling info"
191+
echo "::endgroup::"
192+
echo "::group::tooling info"
192193
cargo -V
193194
rustc -V
195+
echo "::endgroup::"
194196
#
195197
# To ensure that files are cleaned up, we don't want to exit on error
196198
set +e
@@ -203,14 +205,24 @@ jobs:
203205
# Avoid filling disk space
204206
export RUSTFLAGS="-C strip=symbols"
205207
# Use cargo test since nextest might not support OpenBSD
206-
if (test -z "\$FAULT"); then cargo test --features '${{ matrix.job.features }}' || FAULT=1 ; fi
208+
if (test -z "\$FAULT"); then
209+
echo "::group::cargo test (workspace)"
210+
cargo test --features '${{ matrix.job.features }}' || FAULT=1
211+
echo "::endgroup::"
212+
fi
207213
# There is no systemd-logind on OpenBSD, so test all features except feat_systemd_logind
208214
if (test -z "\$FAULT"); then
215+
echo "::group::cargo test (uucore)"
209216
UUCORE_FEATURES=\$(cargo metadata --format-version=1 --no-deps | jq -r '.packages[] | select(.name == "uucore") | .features | keys | .[]' | grep -v "feat_systemd_logind" | paste -s -d "," -)
210217
cargo test --features "\$UUCORE_FEATURES" -p uucore || FAULT=1
218+
echo "::endgroup::"
211219
fi
212220
# Test building with make
213-
if (test -z "\$FAULT"); then make MULTICALL=Y || FAULT=1 ; fi
221+
if (test -z "\$FAULT"); then
222+
echo "::group::make MULTICALL=Y"
223+
make MULTICALL=Y || FAULT=1
224+
echo "::endgroup::"
225+
fi
214226
# Clean to avoid to rsync back the files and free up disk space
215227
cargo clean
216228
# Additional cleanup to free disk space

.vscode/cspell.dictionaries/jargon.wordlist.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ discoverability
4242
duplicative
4343
dsync
4444
endianness
45+
endgroup
4546
enqueue
4647
ERANGE
4748
errored

src/uu/mv/src/mv.rs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1007,15 +1007,11 @@ fn copy_dir_contents(
10071007
// Create the destination directory
10081008
fs::create_dir_all(to)?;
10091009

1010-
// Preserve ownership (uid/gid) of the top-level directory
10111010
#[cfg(unix)]
10121011
{
1012+
// Preserve ownership (uid/gid) of the top-level directory
10131013
let _ = preserve_ownership(from, to);
1014-
}
10151014

1016-
// Recursively copy contents
1017-
#[cfg(unix)]
1018-
{
10191015
if let (Some(tracker), Some(scanner)) = (hardlink_tracker, hardlink_scanner) {
10201016
copy_dir_contents_recursive(
10211017
from,

src/uu/unexpand/src/unexpand.rs

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
use clap::{Arg, ArgAction, Command};
99
use std::ffi::OsString;
1010
use std::fs::File;
11-
use std::io::{BufReader, BufWriter, Read, Stdout, Write, stdin, stdout};
11+
use std::io::{self, BufReader, BufWriter, Read, Stdin, Stdout, Write, stdin, stdout};
1212
use std::num::IntErrorKind;
1313
use std::path::Path;
1414
use std::str::from_utf8;
@@ -279,19 +279,32 @@ pub fn uu_app() -> Command {
279279
)
280280
}
281281

282-
fn open(path: &OsString) -> UResult<BufReader<Box<dyn Read + 'static>>> {
283-
let file_buf;
282+
enum Input {
283+
Stdin(Stdin),
284+
File(File),
285+
}
286+
287+
impl Read for Input {
288+
fn read(&mut self, buf: &mut [u8]) -> io::Result<usize> {
289+
match self {
290+
Self::Stdin(s) => s.read(buf),
291+
Self::File(f) => f.read(buf),
292+
}
293+
}
294+
}
295+
296+
fn open(path: &OsString) -> UResult<BufReader<Input>> {
284297
let filename = Path::new(path);
285298
if filename.is_dir() {
286299
Err(USimpleError::new(
287300
1,
288301
translate!("unexpand-error-is-directory", "path" => filename.maybe_quote()),
289302
))
290303
} else if path == "-" {
291-
Ok(BufReader::new(Box::new(stdin()) as Box<dyn Read>))
304+
Ok(BufReader::new(Input::Stdin(stdin())))
292305
} else {
293-
file_buf = File::open(path).map_err_context(|| path.maybe_quote().to_string())?;
294-
Ok(BufReader::new(Box::new(file_buf) as Box<dyn Read>))
306+
let f = File::open(path).map_err_context(|| path.maybe_quote().to_string())?;
307+
Ok(BufReader::new(Input::File(f)))
295308
}
296309
}
297310

tests/by-util/test_touch.rs

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -622,6 +622,25 @@ fn test_touch_set_date7() {
622622
assert_eq!(mtime, expected);
623623
}
624624

625+
/// Regression test for https://github.com/uutils/coreutils/issues/11804
626+
///
627+
/// Setting a pre-epoch date like `0000-01-01` used to panic on 32-bit targets
628+
/// because the i64 Unix timestamp (~-62 billion) overflowed the i32 `tv_sec`
629+
/// expected by the old nix-based implementation. After switching to rustix
630+
/// (which uses i64 `tv_sec` natively), this should succeed on all targets.
631+
#[test]
632+
#[cfg(target_os = "linux")]
633+
fn test_touch_set_date_year_zero() {
634+
let (at, mut ucmd) = at_and_ucmd!();
635+
let file = "test_touch_year_zero";
636+
637+
ucmd.args(&["-d", "0000-01-01", file])
638+
.succeeds()
639+
.no_stderr();
640+
641+
assert!(at.file_exists(file));
642+
}
643+
625644
/// Test for setting the date by a relative time unit.
626645
#[test]
627646
fn test_touch_set_date_relative_smoke() {

0 commit comments

Comments
 (0)