mirror of
https://github.com/cheat/cheat.git
synced 2026-03-07 11:13:33 +01:00
- Remove unused parameters, dead files, and inaccurate doc.go files - Extract shared helpers, eliminate duplication - Rename cheatpath.Cheatpath to cheatpath.Path - Optimize filesystem walks (WalkDir, skip .git) - Move sheet name validation to sheet.Validate - Move integration tests to test/integration/ - Consolidate internal/mock into mocks/ - Move fuzz.sh to test/ - Inline loadSheets helper into command callers - Extract config.New into its own file - Fix stale references in HACKING.md and CLAUDE.md - Restore plan9 build target - Remove redundant and low-value tests - Clean up project documentation Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
37 lines
1.2 KiB
Bash
Executable File
37 lines
1.2 KiB
Bash
Executable File
#!/bin/bash
|
|
#
|
|
# Run fuzz tests for cheat
|
|
# Usage: ./scripts/fuzz.sh [duration]
|
|
#
|
|
# Note: Go's fuzzer will fail immediately if it finds a known failing input
|
|
# in the corpus (testdata/fuzz/*). This is by design - it ensures you fix
|
|
# known bugs before searching for new ones. To see failing inputs:
|
|
# ls internal/*/testdata/fuzz/*/
|
|
#
|
|
|
|
set -e
|
|
|
|
DURATION="${1:-15s}"
|
|
|
|
# Define fuzz tests: "TestName:Package:Description"
|
|
TESTS=(
|
|
"FuzzParse:./internal/sheet:YAML frontmatter parsing"
|
|
"FuzzValidate:./internal/sheet:sheet name validation (path traversal protection)"
|
|
"FuzzSearchRegex:./internal/sheet:regex search operations"
|
|
"FuzzTagged:./internal/sheet:tag matching with malicious input"
|
|
"FuzzFilter:./internal/sheets:tag filtering operations"
|
|
"FuzzTags:./internal/sheets:tag aggregation and sorting"
|
|
"FuzzFindLocalCheatpath:./internal/config:recursive .cheat directory discovery"
|
|
)
|
|
|
|
echo "Running fuzz tests ($DURATION each)..."
|
|
echo
|
|
|
|
for i in "${!TESTS[@]}"; do
|
|
IFS=':' read -r test_name package description <<< "${TESTS[$i]}"
|
|
echo "$((i+1)). Testing $description..."
|
|
go test -fuzz="^${test_name}$" -fuzztime="$DURATION" "$package"
|
|
echo
|
|
done
|
|
|
|
echo "All fuzz tests passed!" |