Skip to content

Commit 4448da4

Browse files
committed
Run a more exhasutive clippy check
Signed-off-by: Mark Rossett <[email protected]>
1 parent 6ab6b2c commit 4448da4

File tree

2 files changed

+103
-0
lines changed

2 files changed

+103
-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: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
#!/usr/bin/env bash
2+
# filepath: /home/marosset/src/github.com/marosset/hyperlight/hack/clippy-package-features.sh
3+
4+
set -euo pipefail
5+
6+
# Check for required arguments
7+
if [[ $# -lt 2 ]]; then
8+
echo "Usage: $0 <package> <target>" >&2
9+
echo "Example: $0 hyperlight-host debug" >&2
10+
exit 1
11+
fi
12+
13+
PACKAGE="$1"
14+
TARGET="$2"
15+
16+
# Convert target for cargo profile
17+
PROFILE=$([ "$TARGET" = "debug" ] && echo "dev" || echo "$TARGET")
18+
19+
# Required features for compilation (only for hyperlight-host)
20+
if [[ "$PACKAGE" == "hyperlight-host" ]]; then
21+
REQUIRED_FEATURES="kvm,mshv3"
22+
# Get all features for the package (excluding default and required features)
23+
features=$(cargo metadata --format-version 1 --no-deps | jq -r ".packages[] | select(.name == \"$PACKAGE\") | .features | keys[]" | grep -v -E "^(default|kvm|mshv3)$" || true)
24+
else
25+
REQUIRED_FEATURES=""
26+
# Get all features for the package (excluding default)
27+
features=$(cargo metadata --format-version 1 --no-deps | jq -r ".packages[] | select(.name == \"$PACKAGE\") | .features | keys[]" | grep -v "^default$" || true)
28+
fi
29+
30+
# Test with minimal features
31+
if [[ -n "$REQUIRED_FEATURES" ]]; then
32+
echo "Testing $PACKAGE with required features only ($REQUIRED_FEATURES)..."
33+
cargo clippy -p "$PACKAGE" --all-targets --no-default-features --features "$REQUIRED_FEATURES" --profile="$PROFILE" -- -D warnings
34+
else
35+
echo "Testing $PACKAGE with no features..."
36+
cargo clippy -p "$PACKAGE" --all-targets --no-default-features --profile="$PROFILE" -- -D warnings
37+
fi
38+
39+
echo "Testing $PACKAGE with default features..."
40+
cargo clippy -p "$PACKAGE" --all-targets --profile="$PROFILE" -- -D warnings
41+
42+
# Test each additional feature individually
43+
for feature in $features; do
44+
if [[ -n "$REQUIRED_FEATURES" ]]; then
45+
echo "Testing $PACKAGE with feature: $REQUIRED_FEATURES,$feature"
46+
cargo clippy -p "$PACKAGE" --all-targets --no-default-features --features "$REQUIRED_FEATURES,$feature" --profile="$PROFILE" -- -D warnings || echo "Feature $feature failed for $PACKAGE"
47+
else
48+
echo "Testing $PACKAGE with feature: $feature"
49+
cargo clippy -p "$PACKAGE" --all-targets --no-default-features --features "$feature" --profile="$PROFILE" -- -D warnings || echo "Feature $feature failed for $PACKAGE"
50+
fi
51+
done
52+
53+
# Test all features together
54+
if [[ -n "$features" ]]; then
55+
all_features=$(echo $features | tr '\n' ',' | sed 's/,$//')
56+
if [[ -n "$REQUIRED_FEATURES" ]]; then
57+
echo "Testing $PACKAGE with all features: $REQUIRED_FEATURES,$all_features"
58+
cargo clippy -p "$PACKAGE" --all-targets --no-default-features --features "$REQUIRED_FEATURES,$all_features" --profile="$PROFILE" -- -D warnings || echo "All features failed for $PACKAGE"
59+
else
60+
echo "Testing $PACKAGE with all features: $all_features"
61+
cargo clippy -p "$PACKAGE" --all-targets --no-default-features --features "$all_features" --profile="$PROFILE" -- -D warnings || echo "All features failed for $PACKAGE"
62+
fi
63+
fi

0 commit comments

Comments
 (0)