Simplified asma-test.sh.

This commit is contained in:
Andrew Alderwick 2021-10-07 22:30:19 +01:00
parent 2006b2a6ad
commit 80102ff212
1 changed files with 16 additions and 19 deletions

View File

@ -3,42 +3,39 @@ set -e
cd "$(dirname "${0}")/.." cd "$(dirname "${0}")/.."
rm -rf asma-test rm -rf asma-test
mkdir asma-test mkdir asma-test
cd asma-test
expect_failure() { expect_failure() {
cat > 'in.tal' cat > asma-test/in.tal
echo asma-test/in.tal | ( cd .. && bin/uxncli asma-test/asma.rom ) > out.rom 2> asma.log echo asma-test/in.tal | bin/uxncli asma-test/asma.rom > out.rom 2> asma-test/asma.log
if ! grep -qF "${1}" asma.log; then if ! grep -qF "${1}" asma-test/asma.log; then
echo "error: asma didn't report error ${1} in faulty code" echo "error: asma didn't report error ${1} in faulty code"
xxd asma.log cat asma-test/asma.log
fi fi
} }
echo 'Assembling asma with uxnasm' echo 'Assembling asma with uxnasm'
( cd .. && bin/uxnasm projects/software/asma.tal asma-test/asma.rom ) > uxnasm.log bin/uxnasm projects/software/asma.tal asma-test/asma.rom > asma-test/uxnasm.log
for F in $(find ../projects -path ../projects/library -prune -false -or -type f -name '*.tal' -not -name 'blank.tal' | sort); do for F in $(find projects -path projects/library -prune -false -or -type f -name '*.tal' | sort); do
echo "Comparing assembly of ${F}" echo "Comparing assembly of ${F}"
BN="$(basename "${F%.tal}")"
if ! ( cd .. && bin/uxnasm "asma-test/${F}" "asma-test/uxnasm-${BN}.rom" ) > uxnasm.log; then UASM_BASE="asma-test/uxnasm-$(basename "${F%.tal}")"
if ! bin/uxnasm "${F}" "${UASM_BASE}.rom" 2> "${UASM_BASE}.log"; then
echo "error: uxnasm failed to assemble ${F}" echo "error: uxnasm failed to assemble ${F}"
tail uxnasm.log cat "${UASM_BASE}.log"
exit 1 exit 1
fi fi
xxd "uxnasm-${BN}.rom" > "uxnasm-${BN}.hex" xxd "${UASM_BASE}.rom" > "${UASM_BASE}.hex"
cp "${F}" 'in.tal' ASMA_BASE="asma-test/asma-$(basename "${F%.tal}")"
rm -f 'out.rom' echo "${F}" | bin/uxncli asma-test/asma.rom > "${ASMA_BASE}.rom" 2> "${ASMA_BASE}.log"
echo asma-test/in.tal | ( cd .. && bin/uxncli asma-test/asma.rom ) > out.rom 2> asma.log if ! grep -qF 'bytes of heap used' "${ASMA_BASE}.log"; then
cat asma.log
if ! grep -qF 'bytes of heap used' asma.log; then
echo "error: asma failed to assemble ${F}, while uxnasm succeeded" echo "error: asma failed to assemble ${F}, while uxnasm succeeded"
tail asma.log cat "${ASMA_BASE}.log"
exit 1 exit 1
fi fi
xxd 'out.rom' > "asma-${BN}.hex" xxd "${ASMA_BASE}.rom" > "${ASMA_BASE}.hex"
diff -u "uxnasm-${BN}.hex" "asma-${BN}.hex" diff -u "${UASM_BASE}.hex" "${ASMA_BASE}.hex"
done done
expect_failure 'Invalid hexadecimal: $defg' <<'EOD' expect_failure 'Invalid hexadecimal: $defg' <<'EOD'
|1000 $defg |1000 $defg