Skip to content

Commit dbb771e

Browse files
Ao-senXiongwmdietl
andauthored
Seperate qualifier consistency check from misc (#1148)
Co-authored-by: Werner Dietl <[email protected]>
1 parent 6246cec commit dbb771e

File tree

2 files changed

+66
-52
lines changed

2 files changed

+66
-52
lines changed
+65
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
#!/bin/bash
2+
3+
reset_trace=false
4+
if [ -o xtrace ]; then
5+
# Turn off xtrace to avoid verbose output
6+
set +o xtrace
7+
reset_trace=true
8+
fi
9+
10+
# Check the definition of qualifiers in Checker Framework against the JDK
11+
# This script assume JDK is cloned and located in the parent directory of the Checker Framework
12+
echo "Checking the definition of qualifiers in Checker Framework against the JDK"
13+
CURRENT_PATH=$(pwd)
14+
src_dir="$CURRENT_PATH/checker-qual/src/main/java/org/checkerframework"
15+
jdk_dir="$CURRENT_PATH/../jdk/src/java.base/share/classes/org/checkerframework"
16+
17+
difference_found=false
18+
file_missing_in_jdk=false
19+
file_removed_in_cf=false
20+
21+
while read -r file; do
22+
# Use parameter expansion to get the relative path of the file
23+
# e.g. rel_path= "checker/nullness/qual/Nullable.java"
24+
rel_path="${file#"$src_dir"/}"
25+
jdk_file="$jdk_dir/$rel_path"
26+
27+
# Check if the file exists in the JDK directory
28+
if [ ! -f "$jdk_file" ]; then
29+
echo "File missing in JDK: $rel_path"
30+
file_missing_in_jdk=true
31+
else
32+
diff_output=$(diff -q "$file" "$jdk_file" || true)
33+
34+
if [ "$diff_output" ]; then
35+
echo "Difference found in: $rel_path"
36+
diff "$file" "$jdk_file" || true # Show the full diff
37+
38+
difference_found=true
39+
fi
40+
fi
41+
done < <(find "$src_dir" -name "*.java")
42+
43+
# Check for files in the JDK that are not in CF
44+
while read -r jdk_file; do
45+
rel_path="${jdk_file#"$jdk_dir"/}"
46+
cf_file="$src_dir/$rel_path"
47+
48+
if [ ! -f "$cf_file" ]; then
49+
echo "File removed in CF: $rel_path"
50+
file_removed_in_cf=true
51+
fi
52+
done < <(find "$jdk_dir" -name "*.java")
53+
54+
if [ "$reset_trace" = true ]; then
55+
# Turn on xtrace output
56+
set -o xtrace
57+
fi
58+
59+
# If any difference, missing, or removed file was found, exit with failure
60+
if [ "$difference_found" = true ] || [ "$file_missing_in_jdk" = true ] || [ "$file_removed_in_cf" = true ]; then
61+
echo "Differences found or files missing/removed. Exiting with failure."
62+
exit 1 # Exit with failure
63+
else
64+
echo "No differences found and no files missing/removed."
65+
fi

checker/bin-devel/test-misc.sh

+1-52
Original file line numberDiff line numberDiff line change
@@ -72,55 +72,4 @@ git diff --exit-code docs/manual/contributors.tex || \
7272
false)
7373

7474
# 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
75+
./checker/bin-devel/check-jdk-consistency.sh

0 commit comments

Comments
 (0)