-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
test-before-release.sh
executable file
·109 lines (69 loc) · 2.85 KB
/
test-before-release.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
#!/bin/bash
set -x
add_tmp_to_readme() {
cat tmp-file | sed -e 's/</\</g' | sed -e 's/>/\>/g' >>README.md
}
make_usage() {
cat <<EOF >>README.md
## Command line options
<pre>
EOF
$JAVA_HOME/bin/java -jar ./ls-annotations/build/libs/ls-annotations.jar -h >tmp-file 2>&1
add_tmp_to_readme
cat <<EOF >>README.md
</pre>
## Example usage
EOF
}
function run_it {
cmd="$1"
help="$2"
set -e
$JAVA_HOME/bin/java -jar ./ls-annotations/build/libs/ls-annotations.jar $cmd >tmp-file 2>&1
set +e
error=$(grep -ic error tmp-file)
if [[ "$error" != "0" ]]; then
echo "has error"
cat tmp-file
exit 1
fi
size=$(stat -f '%z' tmp-file)
if [[ "$size" == "0" ]]; then
echo "Error: empty result"
exit 1
fi
cat <<EOF >>README.md
<hr>
<details>
<summary>${help}</summary>
Command: <code>java -jar ls-annotations.jar ${cmd}</code>
<pre>
EOF
sed -i -e 's/<b>/@b@/g' tmp-file
sed -i -e 's/<\/b>/@\/b@/g' tmp-file
sed -i -e 's/</\</g' tmp-file
sed -i -e 's/>/\>/g' tmp-file
sed -i -e 's/@b@/<b>/g' tmp-file
sed -i -e 's/@\/b@/<\/b>/g' tmp-file
sed -i -e 's/^/ /g' tmp-file
cat tmp-file >>README.md
cat <<EOF >>README.md
</pre>
</details>
EOF
}
cp README.md.template README.md
make_usage
run_it "-l ./ls-annotations/build/libs/ls-annotations.jar" "show all annotations in jar file"
run_it "-l ./ls-annotations/build/classes" "show all annotations in classes within directory (recursive)"
run_it "-l ./ls-annotations/build/classes -c" "show all annotations in classes within directory (recursive), show constructor on classes with annotations"
run_it "-e @lsann.attrib.TestAttrib4 ./ls-annotations/build/classes" "show all annotation definitions that are used in definition of annotation @lsann.attrib.TestAttrib4"
run_it "-a @lsann.attrib.TestAttrib ./ls-annotations/build/classes" "show all annotation definitions that extend annotation @lsann.attrib.TestAttrib"
run_it "-u @lsann.attrib.TestAttrib4 ./ls-annotations/build/classes" "show all uses of @lsann.attrib.TestAttrib4 with highlight"
#LATEST_SPRING_JAR=$(find $HOME/.gradle/caches -name 'spring-context*.RELEASE.jar' -type f | perl -ne '/.*-(\d\.\d*.\d*).RELEASE.jar/ && print "$1 $_"' | sort -n -k 1 | tail -1 | cut -d " " -f 2)
#run_it "-u @org.springframework.context.annotation.Bean ${LATEST_SPRING_JAR}" "show all spring bean types defined in ${LATEST_SPRING_JAR}"
run_it "-w @lsann.attrib.TestAttrib ./ls-annotations/build/classes" "show all uses of @lsann.attrib.TestAttrib4, including use of derived annotations "
run_it "-l ./ls-annotations/build/classes -d java.lang.Object" "show all derived classes of java.lang.Object"
run_it "-l ./ls-annotations/build/classes -b lsann.attrib.TestDerived2" "show all base classes of lsann.attrib.TestDerived2"
cat README-eof.md.template >>README.md
echo "** test ok **"