Browse code

Simplified asma-test.sh.

Andrew Alderwick authored on 07/10/2021 21:30:19
Showing 1 changed files
... ...
@@ -3,42 +3,39 @@ set -e
3 3
 cd "$(dirname "${0}")/.."
4 4
 rm -rf asma-test
5 5
 mkdir asma-test
6
-cd asma-test
7 6
 
8 7
 expect_failure() {
9
-	cat > 'in.tal'
10
-	echo asma-test/in.tal | ( cd .. && bin/uxncli asma-test/asma.rom ) > out.rom 2> asma.log
11
-	if ! grep -qF "${1}" asma.log; then
8
+	cat > asma-test/in.tal
9
+	echo asma-test/in.tal | bin/uxncli asma-test/asma.rom > out.rom 2> asma-test/asma.log
10
+	if ! grep -qF "${1}" asma-test/asma.log; then
12 11
 		echo "error: asma didn't report error ${1} in faulty code"
13
-		xxd asma.log
12
+		cat asma-test/asma.log
14 13
 	fi
15 14
 }
16 15
 
17 16
 echo 'Assembling asma with uxnasm'
18
-( cd .. && bin/uxnasm projects/software/asma.tal asma-test/asma.rom ) > uxnasm.log
19
-for F in $(find ../projects -path ../projects/library -prune -false -or -type f -name '*.tal' -not -name 'blank.tal' | sort); do
17
+bin/uxnasm projects/software/asma.tal asma-test/asma.rom > asma-test/uxnasm.log
18
+for F in $(find projects -path projects/library -prune -false -or -type f -name '*.tal' | sort); do
20 19
 	echo "Comparing assembly of ${F}"
21
-	BN="$(basename "${F%.tal}")"
22 20
 
23
-	if ! ( cd .. && bin/uxnasm "asma-test/${F}" "asma-test/uxnasm-${BN}.rom" ) > uxnasm.log; then
21
+	UASM_BASE="asma-test/uxnasm-$(basename "${F%.tal}")"
22
+	if ! bin/uxnasm "${F}" "${UASM_BASE}.rom" 2> "${UASM_BASE}.log"; then
24 23
 		echo "error: uxnasm failed to assemble ${F}"
25
-		tail uxnasm.log
24
+		cat "${UASM_BASE}.log"
26 25
 		exit 1
27 26
 	fi
28
-	xxd "uxnasm-${BN}.rom" > "uxnasm-${BN}.hex"
27
+	xxd "${UASM_BASE}.rom" > "${UASM_BASE}.hex"
29 28
 
30
-	cp "${F}" 'in.tal'
31
-	rm -f 'out.rom'
32
-	echo asma-test/in.tal | ( cd .. && bin/uxncli asma-test/asma.rom ) > out.rom 2> asma.log
33
-	cat asma.log
34
-	if ! grep -qF 'bytes of heap used' asma.log; then
29
+	ASMA_BASE="asma-test/asma-$(basename "${F%.tal}")"
30
+	echo "${F}" | bin/uxncli asma-test/asma.rom > "${ASMA_BASE}.rom" 2> "${ASMA_BASE}.log"
31
+	if ! grep -qF 'bytes of heap used' "${ASMA_BASE}.log"; then
35 32
 		echo "error: asma failed to assemble ${F}, while uxnasm succeeded"
36
-		tail asma.log
33
+		cat "${ASMA_BASE}.log"
37 34
 		exit 1
38 35
 	fi
39
-	xxd 'out.rom' > "asma-${BN}.hex"
36
+	xxd "${ASMA_BASE}.rom" > "${ASMA_BASE}.hex"
40 37
 
41
-	diff -u "uxnasm-${BN}.hex" "asma-${BN}.hex"
38
+	diff -u "${UASM_BASE}.hex" "${ASMA_BASE}.hex"
42 39
 done
43 40
 expect_failure 'Invalid hexadecimal: $defg' <<'EOD'
44 41
 |1000 $defg