Skip to content

Commit 6246cec

Browse files
Ao-senXiongwmdietl
andauthored
Add consistency check for qualifiers in CF and JDK (#1142)
Co-authored-by: Werner Dietl <[email protected]>
1 parent 68f64c1 commit 6246cec

File tree

1 file changed

+54
-0
lines changed

1 file changed

+54
-0
lines changed

checker/bin-devel/test-misc.sh

+54
Original file line numberDiff line numberDiff line change
@@ -70,3 +70,57 @@ git diff --exit-code docs/manual/contributors.tex || \
7070
echo " https://github.com/eisop-plume-lib/git-scripts/blob/master/git-authors.sed" &&
7171
echo " and remake contributors.tex after that pull request is merged." &&
7272
false)
73+
74+
# Check the definition of qualifiers in Checker Framework against the JDK
75+
echo "Checking the definition of qualifiers in Checker Framework against the JDK"
76+
CURRENT_PATH=$(pwd)
77+
src_dir="$CURRENT_PATH/checker-qual/src/main/java/org/checkerframework"
78+
jdk_dir="$CURRENT_PATH/../jdk/src/java.base/share/classes/org/checkerframework"
79+
set +o xtrace # Turn off xtrace to avoid verbose output
80+
81+
difference_found=false
82+
file_missing_in_jdk=false
83+
file_removed_in_cf=false
84+
85+
while read -r file; do
86+
# Use parameter expansion to get the relative path of the file
87+
# e.g. rel_path= "checker/nullness/qual/Nullable.java"
88+
rel_path="${file#"$src_dir"/}"
89+
jdk_file="$jdk_dir/$rel_path"
90+
91+
# Check if the file exists in the JDK directory
92+
if [ ! -f "$jdk_file" ]; then
93+
echo "File missing in JDK: $rel_path"
94+
file_missing_in_jdk=true
95+
else
96+
diff_output=$(diff -q "$file" "$jdk_file" || true)
97+
98+
if [ "$diff_output" ]; then
99+
echo "Difference found in: $rel_path"
100+
diff "$file" "$jdk_file" || true # Show the full diff
101+
102+
difference_found=true
103+
fi
104+
fi
105+
done < <(find "$src_dir" -name "*.java")
106+
107+
# Check for files in the JDK that are not in CF
108+
while read -r jdk_file; do
109+
rel_path="${jdk_file#"$jdk_dir"/}"
110+
cf_file="$src_dir/$rel_path"
111+
112+
if [ ! -f "$cf_file" ]; then
113+
echo "File removed in CF: $rel_path"
114+
file_removed_in_cf=true
115+
fi
116+
done < <(find "$jdk_dir" -name "*.java")
117+
118+
# If any difference, missing, or removed file was found, exit with failure
119+
if [ "$difference_found" = true ] || [ "$file_missing_in_jdk" = true ] || [ "$file_removed_in_cf" = true ]; then
120+
echo "Differences found or files missing/removed. Exiting with failure."
121+
exit 1 # Exit with failure
122+
else
123+
echo "No differences found and no files missing/removed."
124+
fi
125+
126+
set -o xtrace # Turn on xtrace output

0 commit comments

Comments
 (0)