Skip to content

Commit c9cf286

Browse files
committed
Improve the tested-functions-list generator
1 parent 2553413 commit c9cf286

File tree

2 files changed

+302
-265
lines changed

2 files changed

+302
-265
lines changed

tools/funcs_tested/gen_list.sh

Lines changed: 27 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,17 +19,38 @@ outfile=$DIR/tested-functions-list.md
1919

2020
echo "## List of tested functions" > $outfile
2121

22+
exampleFiles=$(find ./examples -type f \( -iname '*.c' -o -iname '*.cpp' -o -iname '*.h' -o -iname '*.hpp' -o -iname '*.asm' \))
23+
2224
for f in $files
2325
do
2426
echo -e "\n### $f" >> $outfile
25-
echo -e "| Function | Tested ? |" >> $outfile
26-
echo -e "| -------- | ----------- |" >> $outfile
27-
filectags=$(ctags -u --fields=n --c-kinds=p --output-format=json $f | sed -e 's/.*"name": "\(.*\)", "path.*/\1/g')
28-
for c in $filectags
27+
echo -e "| Function | Tested? | Search link |" >> $outfile
28+
echo -e "| -------- | ------- | ----------- |" >> $outfile
29+
30+
# This will produce a list of funcName:funcLine, which we'll parse i nthe for loop below.
31+
filefuncts=$(ctags -u --fields=n --c-kinds=p --output-format=json $f | sed -e 's/.*"name": "\(.*\)", "path.*"line": \(.*\)}/\1:\2/g')
32+
totalFuncs=0
33+
totalTested=0
34+
for funcAndLine in $filefuncts
2935
do
30-
grep -Rq --include \*.h --include \*.cpp --include \*.h --include \*.c "$c" ./examples && found="<span style='color:green'>✓</span>" || found="<span style='color:red'>✗</span>"
31-
echo "| \`$c\` | $found |" >> $outfile
36+
((totalFuncs++))
37+
func=${funcAndLine%:*}
38+
line=${funcAndLine##*:}
39+
count=$(grep -l "$func" ${exampleFiles} | wc -l | awk '{print $1}')
40+
if [[ "$count" == "0" ]]
41+
then
42+
foundStr=""
43+
searchLink=""
44+
else
45+
((totalTested++))
46+
foundStr="YES (x$count)"
47+
searchLink="[occurrences](https://github.com/search?q=${func}+repo%3ACE-Programming%2Ftoolchain+path%3Aexamples&type=Code)"
48+
fi
49+
echo -e "| [\`${func}\`](/${f}#L${line}) | $foundStr | $searchLink" >> $outfile
3250
done
51+
echo -e "\n**Total: ${totalTested}/${totalFuncs} tested.**" >> $outfile
3352
done
3453

54+
echo -e "\n\n---\n*Generated by [gen_list.sh](/tools/funcs_tested/gen_list.sh)*" >> $outfile
55+
3556
cat $outfile

0 commit comments

Comments
 (0)