fuzz: add cargo clippy check for fuzz directory (#10466)

This commit is contained in:
xtqqczze
2026-01-24 18:34:35 +00:00
committed by GitHub
parent 1ce8990141
commit 938039e9ac
4 changed files with 13 additions and 5 deletions
+6
View File
@@ -147,6 +147,12 @@ jobs:
CARGO_UTILITY_LIST_OPTIONS="$(for u in ${UTILITY_LIST}; do echo -n "-puu_${u} "; done;)"
S=$(cargo clippy --all-targets $extra --tests --benches -pcoreutils ${CARGO_UTILITY_LIST_OPTIONS} -- -D warnings 2>&1) && printf "%s\n" "$S" || { printf "%s\n" "$S" ; printf "%s" "$S" | sed -E -n -e '/^error:/{' -e "N; s/^error:[[:space:]]+(.*)\\n[[:space:]]+-->[[:space:]]+(.*):([0-9]+):([0-9]+).*$/::${fault_type} file=\2,line=\3,col=\4::${fault_prefix}: \`cargo clippy\`: \1 (file:'\2', line:\3)/p;" -e '}' ; fault=true ; }
if [ -n "${{ steps.vars.outputs.FAIL_ON_FAULT }}" ] && [ -n "$fault" ]; then exit 1 ; fi
- name: "cargo clippy on fuzz dir"
if: runner.os != 'Windows'
shell: bash
run: |
cd fuzz
cargo clippy --workspace --all-targets --all-features -- -D warnings
style_spellcheck:
name: Style/spelling
+2
View File
@@ -0,0 +1,2 @@
[build]
rustflags = ["--cfg", "fuzzing"]
+3 -3
View File
@@ -14,7 +14,7 @@ use std::env::temp_dir;
use std::ffi::{OsStr, OsString};
use std::fs;
use std::os::unix::ffi::{OsStrExt, OsStringExt};
use std::path::PathBuf;
use std::path::{Path, PathBuf};
use uufuzz::{CommandResult, run_gnu_cmd};
// Programs that typically take file/path arguments and should be tested
@@ -148,7 +148,7 @@ fn setup_test_files() -> Result<(PathBuf, Vec<PathBuf>), std::io::Error> {
// Try to create the file - this may fail on some filesystems
if let Ok(mut file) = fs::File::create(&file_path) {
use std::io::Write;
let _ = write!(file, "test content for file {}\n", i);
let _ = writeln!(file, "test content for file {}", i);
test_files.push(file_path);
}
}
@@ -156,7 +156,7 @@ fn setup_test_files() -> Result<(PathBuf, Vec<PathBuf>), std::io::Error> {
Ok((temp_root, test_files))
}
fn test_program_with_non_utf8_path(program: &str, path: &PathBuf) -> CommandResult {
fn test_program_with_non_utf8_path(program: &str, path: &Path) -> CommandResult {
let path_os = path.as_os_str();
// Use the locally built uutils binary instead of system PATH
+2 -2
View File
@@ -135,9 +135,9 @@ fn generate_test_arg() -> String {
if test_arg.arg_type == ArgType::INTEGER {
arg.push_str(&format!(
"{} {} {}",
rng.random_range(-100..=100).to_string(),
rng.random_range(-100..=100),
test_arg.arg,
rng.random_range(-100..=100).to_string()
rng.random_range(-100..=100)
));
} else if test_arg.arg_type == ArgType::STRINGSTRING {
let random_str = generate_random_string(rng.random_range(1..=10));