Skip to content

Commit 8ef999c

Browse files
committed
Run a more exhasutive clippy check
Signed-off-by: Mark Rossett <[email protected]>
1 parent ea6fa8f commit 8ef999c

File tree

2 files changed

+111
-0
lines changed

2 files changed

+111
-0
lines changed

Justfile

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,46 @@ clippy-apply-fix-unix:
176176
clippy-apply-fix-windows:
177177
cargo clippy --target x86_64-pc-windows-msvc --fix --all
178178

179+
# Generate and test all possible feature combinations for a package
180+
clippy-feature-combinations package target=default-target:
181+
#!/usr/bin/env bash
182+
set -euo pipefail
183+
184+
# Get all features for the package
185+
features=$(cargo metadata --format-version 1 --no-deps | jq -r '.packages[] | select(.name == "{{package}}") | .features | keys[]' | grep -v default || true)
186+
187+
echo "Testing {{package}} with no features..."
188+
cargo clippy -p {{package}} --all-targets --no-default-features --profile={{ if target == "debug" { "dev" } else { target } }} -- -D warnings
189+
190+
echo "Testing {{package}} with default features..."
191+
cargo clippy -p {{package}} --all-targets --profile={{ if target == "debug" { "dev" } else { target } }} -- -D warnings
192+
193+
# Test each feature individually
194+
for feature in $features; do
195+
echo "Testing {{package}} with feature: $feature"
196+
cargo clippy -p {{package}} --all-targets --no-default-features --features "$feature" --profile={{ if target == "debug" { "dev" } else { target } }} -- -D warnings || echo "Feature $feature failed for {{package}}"
197+
done
198+
199+
# Test all features together
200+
if [ -n "$features" ]; then
201+
all_features=$(echo $features | tr '\n' ',' | sed 's/,$//')
202+
echo "Testing {{package}} with all features: $all_features"
203+
cargo clippy -p {{package}} --all-targets --no-default-features --features "$all_features" --profile={{ if target == "debug" { "dev" } else { target } }} -- -D warnings || echo "All features failed for {{package}}"
204+
fi
205+
206+
# Run clippy with feature combinations for all packages
207+
clippy-exhaustive target=default-target: (witguest-wit)
208+
./hack/clippy-package-features.sh hyperlight-host {{ target }}
209+
./hack/clippy-package-features.sh hyperlight-guest {{ target }}
210+
./hack/clippy-package-features.sh hyperlight-guest-bin {{ target }}
211+
./hack/clippy-package-features.sh hyperlight-common {{ target }}
212+
./hack/clippy-package-features.sh hyperlight-testing {{ target }}
213+
just clippy-guests {{ target }}
214+
215+
# Test a specific package with all feature combinations
216+
clippy-package package target=default-target: (witguest-wit)
217+
./hack/clippy-package-features.sh {{ package }} {{ target }}
218+
179219
# Verify Minimum Supported Rust Version
180220
verify-msrv:
181221
./dev/verify-msrv.sh hyperlight-host hyperlight-guest hyperlight-guest-lib hyperlight-common

hack/clippy-package-features.sh

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
#!/usr/bin/env bash
2+
3+
set -euo pipefail
4+
5+
# Check for required arguments
6+
if [[ $# -lt 2 ]]; then
7+
echo "Usage: $0 <package> <target>" >&2
8+
echo "Example: $0 hyperlight-host debug" >&2
9+
exit 1
10+
fi
11+
12+
PACKAGE="$1"
13+
TARGET="$2"
14+
15+
# Convert target for cargo profile
16+
PROFILE=$([ "$TARGET" = "debug" ] && echo "dev" || echo "$TARGET")
17+
18+
# Required features needed so the rust packages can compile
19+
if [[ "$PACKAGE" == "hyperlight-host" ]]; then
20+
REQUIRED_FEATURES=("kvm" "mshv3")
21+
elif [[ "$PACKAGE" == "hyperlight-guest-bin" ]]; then
22+
REQUIRED_FEATURES=("printf")
23+
else
24+
REQUIRED_FEATURES=()
25+
fi
26+
27+
# Get all features for the package (excluding default and required features)
28+
# Always exclude "default", and exclude any required features using jq
29+
features=$(cargo metadata --format-version 1 --no-deps | jq -r --arg pkg "$PACKAGE" '.packages[] | select(.name == $pkg) | .features | keys[] | select(. != "default" and (IN($ARGS.positional[])|not))' --args "${REQUIRED_FEATURES[@]}" || true)
30+
31+
# Convert required features array to comma-separated string for cargo
32+
if [[ ${#REQUIRED_FEATURES[@]} -gt 0 ]]; then
33+
required_features_str=$(IFS=,; echo "${REQUIRED_FEATURES[*]}")
34+
else
35+
required_features_str=""
36+
fi
37+
38+
# Test with minimal features
39+
if [[ ${#REQUIRED_FEATURES[@]} -gt 0 ]]; then
40+
echo "Testing $PACKAGE with required features only ($required_features_str)..."
41+
(set -x; cargo clippy -p "$PACKAGE" --all-targets --no-default-features --features "$required_features_str" --profile="$PROFILE" -- -D warnings)
42+
else
43+
echo "Testing $PACKAGE with no features..."
44+
(set -x; cargo clippy -p "$PACKAGE" --all-targets --no-default-features --profile="$PROFILE" -- -D warnings)
45+
fi
46+
47+
echo "Testing $PACKAGE with default features..."
48+
(set -x; cargo clippy -p "$PACKAGE" --all-targets --profile="$PROFILE" -- -D warnings)
49+
50+
# Test each additional feature individually
51+
for feature in $features; do
52+
if [[ ${#REQUIRED_FEATURES[@]} -gt 0 ]]; then
53+
echo "Testing $PACKAGE with feature: $required_features_str,$feature"
54+
(set -x; cargo clippy -p "$PACKAGE" --all-targets --no-default-features --features "$required_features_str,$feature" --profile="$PROFILE" -- -D warnings)
55+
else
56+
echo "Testing $PACKAGE with feature: $feature"
57+
(set -x; cargo clippy -p "$PACKAGE" --all-targets --no-default-features --features "$feature" --profile="$PROFILE" -- -D warnings)
58+
fi
59+
done
60+
61+
# Test all features together
62+
if [[ -n "$features" ]]; then
63+
all_features=$(echo $features | tr '\n' ',' | sed 's/,$//')
64+
if [[ ${#REQUIRED_FEATURES[@]} -gt 0 ]]; then
65+
echo "Testing $PACKAGE with all features: $required_features_str,$all_features"
66+
(set -x; cargo clippy -p "$PACKAGE" --all-targets --no-default-features --features "$required_features_str,$all_features" --profile="$PROFILE" -- -D warnings)
67+
else
68+
echo "Testing $PACKAGE with all features: $all_features"
69+
(set -x; cargo clippy -p "$PACKAGE" --all-targets --no-default-features --features "$all_features" --profile="$PROFILE" -- -D warnings)
70+
fi
71+
fi

0 commit comments

Comments
 (0)