Skip to content

Instantly share code, notes, and snippets.

@aqjune
Last active Feb 8, 2021
Embed
What would you like to do?
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