Skip to content

Commit 424e623

Browse files
authored
Merge branch 'main' into reduce_syscalls_acls
2 parents 72b60f3 + 7bca02c commit 424e623

File tree

6 files changed

+117
-68
lines changed

6 files changed

+117
-68
lines changed

.github/workflows/CICD.yml

Lines changed: 45 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ name: CICD
55
# spell-checker:ignore (jargon) SHAs deps dequote softprops subshell toolchain fuzzers dedupe devel profdata
66
# spell-checker:ignore (people) Peltoche rivy dtolnay Anson dawidd
77
# spell-checker:ignore (shell/tools) binutils choco clippy dmake dpkg esac fakeroot fdesc fdescfs gmake grcov halium lcov libclang libfuse libssl limactl mkdir nextest nocross pacman popd printf pushd redoxer rsync rustc rustfmt rustup shopt sccache utmpdump xargs
8-
# spell-checker:ignore (misc) aarch alnum armhf bindir busytest coreutils defconfig DESTDIR gecos getenforce gnueabihf issuecomment maint manpages msys multisize noconfirm nofeatures nullglob onexitbegin onexitend pell runtest Swatinem tempfile testsuite toybox uutils libsystemd
8+
# spell-checker:ignore (misc) aarch alnum armhf bindir busytest coreutils defconfig DESTDIR gecos getenforce gnueabihf issuecomment maint manpages msys multisize noconfirm nofeatures nullglob onexitbegin onexitend pell runtest Swatinem tempfile testsuite toybox uutils libsystemd codspeed
99

1010
env:
1111
PROJECT_NAME: coreutils
@@ -1221,3 +1221,47 @@ jobs:
12211221
lima bash -c "cd work && cargo test --features 'feat_selinux'"
12221222
- name: Lint with SELinux
12231223
run: lima bash -c "cd work && cargo clippy --all-targets --features 'feat_selinux' -- -D warnings"
1224+
1225+
benchmarks:
1226+
name: Run benchmarks (CodSpeed)
1227+
runs-on: ubuntu-latest
1228+
needs: min_version
1229+
steps:
1230+
- uses: actions/checkout@v5
1231+
with:
1232+
persist-credentials: false
1233+
1234+
- name: Install system dependencies
1235+
shell: bash
1236+
run: |
1237+
sudo apt-get -y update
1238+
sudo apt-get -y install libselinux1-dev
1239+
1240+
- uses: dtolnay/rust-toolchain@stable
1241+
1242+
- uses: Swatinem/rust-cache@v2
1243+
1244+
- name: Run sccache-cache
1245+
uses: mozilla-actions/sccache-action@v0.0.9
1246+
1247+
- name: Install cargo-codspeed
1248+
shell: bash
1249+
run: cargo install cargo-codspeed --locked
1250+
1251+
- name: Run benchmarks
1252+
uses: CodSpeedHQ/action@v4
1253+
env:
1254+
CODSPEED_LOG: debug
1255+
with:
1256+
mode: instrumentation
1257+
run: |
1258+
# Find all utilities with benchmarks and run them individually
1259+
echo "Starting CodSpeed benchmark collection..."
1260+
for bench_dir in $(ls -d src/uu/*/benches 2>/dev/null); do
1261+
prog_dir=$(dirname "$bench_dir")
1262+
prog_name=$(basename "$prog_dir")
1263+
echo "Processing benchmarks for uu_$prog_name"
1264+
cargo codspeed build -p uu_$prog_name
1265+
cargo codspeed run -p uu_$prog_name
1266+
done
1267+
token: ${{ secrets.CODSPEED_TOKEN }}

.github/workflows/codspeed.yml

Lines changed: 0 additions & 53 deletions
This file was deleted.

Cargo.lock

Lines changed: 13 additions & 13 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/uu/hashsum/locales/en-US.ftl

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
hashsum-about = Compute and check message digests.
22
hashsum-usage = hashsum --<digest> [OPTIONS]... [FILE]...
33
4+
# Utility-specific usage template
5+
hashsum-usage-specific = {$utility_name} [OPTION]... [FILE]...
6+
47
# Help messages
58
hashsum-help-binary-windows = read or check in binary mode (default)
69
hashsum-help-binary-other = read in binary mode

src/uu/hashsum/src/hashsum.rs

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -498,7 +498,7 @@ pub fn uu_app_custom() -> Command {
498498
/// hashsum is handled differently in build.rs
499499
/// therefore, this is different from other utilities.
500500
fn uu_app(binary_name: &str) -> (Command, bool) {
501-
match binary_name {
501+
let (mut command, is_hashsum_bin) = match binary_name {
502502
// These all support the same options.
503503
"md5sum" | "sha1sum" | "sha224sum" | "sha256sum" | "sha384sum" | "sha512sum" => {
504504
(uu_app_common(), false)
@@ -516,7 +516,17 @@ fn uu_app(binary_name: &str) -> (Command, bool) {
516516
"b3sum" => (uu_app_b3sum(), false),
517517
// We're probably just being called as `hashsum`, so give them everything.
518518
_ => (uu_app_custom(), true),
519+
};
520+
521+
// If not called as generic hashsum, override the command name and usage
522+
if !is_hashsum_bin {
523+
let usage = translate!("hashsum-usage-specific", "utility_name" => binary_name);
524+
command = command
525+
.help_template(uucore::localized_help_template(binary_name))
526+
.override_usage(format_usage(&usage));
519527
}
528+
529+
(command, is_hashsum_bin)
520530
}
521531

522532
#[allow(clippy::cognitive_complexity)]

tests/by-util/test_hashsum.rs

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1080,3 +1080,48 @@ fn test_check_sha256_binary() {
10801080
.no_stderr()
10811081
.stdout_is("binary.png: OK\n");
10821082
}
1083+
1084+
#[test]
1085+
fn test_help_shows_correct_utility_name() {
1086+
// Test that help output shows the actual utility name instead of "hashsum"
1087+
let scene = TestScenario::new(util_name!());
1088+
1089+
// Test md5sum
1090+
scene
1091+
.ccmd("md5sum")
1092+
.arg("--help")
1093+
.succeeds()
1094+
.stdout_contains("Usage: md5sum")
1095+
.stdout_does_not_contain("Usage: hashsum");
1096+
1097+
// Test sha256sum
1098+
scene
1099+
.ccmd("sha256sum")
1100+
.arg("--help")
1101+
.succeeds()
1102+
.stdout_contains("Usage: sha256sum")
1103+
.stdout_does_not_contain("Usage: hashsum");
1104+
1105+
// Test b2sum
1106+
scene
1107+
.ccmd("b2sum")
1108+
.arg("--help")
1109+
.succeeds()
1110+
.stdout_contains("Usage: b2sum")
1111+
.stdout_does_not_contain("Usage: hashsum");
1112+
1113+
// Test b3sum
1114+
scene
1115+
.ccmd("b3sum")
1116+
.arg("--help")
1117+
.succeeds()
1118+
.stdout_contains("Usage: b3sum")
1119+
.stdout_does_not_contain("Usage: hashsum");
1120+
1121+
// Test that generic hashsum still shows the correct usage
1122+
scene
1123+
.ccmd("hashsum")
1124+
.arg("--help")
1125+
.succeeds()
1126+
.stdout_contains("Usage: hashsum --<digest>");
1127+
}

0 commit comments

Comments
 (0)