Skip to content

Instantly share code, notes, and snippets.

@aqjune
Last active February 8, 2021 07:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save aqjune/85b696292fd4f1685a3f71f7d8e3390d to your computer and use it in GitHub Desktop.
Save aqjune/85b696292fd4f1685a3f71f7d8e3390d to your computer and use it in GitHub Desktop.
list-nodiffs.sh
tempsrc=`mktemp`
temptgt=`mktemp`
# 1. src.ll/tgt.ll tests
for i in `find . -name "*.src.ll"`; do
itgt="${i%.src.ll}.tgt.ll"
grep -v '^;' $i | awk 'NF' >$tempsrc # ignore comments and whitespaces
grep -v '^;' $itgt | awk 'NF' >$temptgt
diff ${tempsrc} ${temptgt} >/dev/null
if [ "$?" == 0 ]; then
echo "NODIFF: $i"
fi
done
# 2. .srctgt.ll tests
temptxt=`mktemp`
for i in `find . -name "*.srctgt.ll"`; do
grep -v '^;' $i | awk 'NF' >$temptxt # ignore comments and whitespaces
rm -f $tempsrc $temptgt
dest=
while read -r line; do
if [[ $line == *"@src"* ]]; then
dest=$tempsrc
elif [[ $line == *"@tgt"* ]]; then
if [[ ! -f $tempsrc ]]; then
# no @src() but yes @tgt()?
break
fi
dest=$temptgt
fi
if [[ $dest != "" ]]; then
echo $line >>$dest
fi
done < $temptxt
if [ ! -f $temptgt ]; then
# it does not have @tgt()
echo "ill-formed test: $i"
continue
fi
sed 's/@tgt/@src/g' $temptgt >$temptxt
diff ${tempsrc} ${temptxt} >/dev/null
if [ "$?" == 0 ]; then
echo "NODIFF: $i"
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment