mirror of
https://github.com/uutils/coreutils.git
synced 2026-06-10 15:48:22 -07:00
fuzz: add cargo clippy check for fuzz directory (#10466)
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -0,0 +1,2 @@
|
||||
[build]
|
||||
rustflags = ["--cfg", "fuzzing"]
|
||||
@@ -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
|
||||
|
||||
@@ -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));
|
||||
|
||||
Reference in New Issue
Block a user