shithub: rgbds

Download patch

ref: 736b7727b6e8aeff780ded36b6621464d1228550
parent: f6b7e39ce7fc91f5e0320719625bae86761c09cc
parent: fa920f8449a97ba28dc6838a1f8f0f5d031d37d6
author: Eldred Habert <[email protected]>
date: Wed Sep 4 14:43:00 EDT 2019

Merge pull request #400 from NieDzejkob/out.pipe-substitute

test/asm: Generate .out.pipe files on the fly

--- a/test/asm/bracketed-symbols.out.pipe
+++ /dev/null
@@ -1,12 +1,0 @@
-ERROR: -(16):
-    Print types are only allowed for numbers
-ERROR: -(20):
-    Expression must have a constant value
-$2A
-2a
-2A
-42
-101010
-10100111001
-0
-You can't format me!
--- a/test/asm/correct-line-number.out.pipe
+++ /dev/null
@@ -1,4 +1,0 @@
-warning: -(5):
-    Am I geting ahead of myself?
-warning: -(11):
-    Hopefully not.
--- a/test/asm/divzero-instr.out.pipe
+++ /dev/null
@@ -1,2 +1,0 @@
-ERROR: -(2):
-    Division by zero
--- a/test/asm/divzero-section-bank.out.pipe
+++ /dev/null
@@ -1,4 +1,0 @@
-ERROR: -(1):
-    Invalid integer constant
-ERROR: -(1):
-    Division by zero
--- a/test/asm/equs-recursion.out.pipe
+++ /dev/null
@@ -1,2 +1,0 @@
-ERROR: -(2):
-    Recursion limit (64) exceeded
--- a/test/asm/garbage_char.out.pipe
+++ /dev/null
@@ -1,2 +1,0 @@
-ERROR: -(1):
-    Found garbage character: 0xFF
--- a/test/asm/include-recursion.out.pipe
+++ /dev/null
@@ -1,2 +1,0 @@
-ERROR: -(1) -> include-recursion.asm(1) -> include-recursion.asm(1) -> include-recursion.asm(1) -> include-recursion.asm(1) -> include-recursion.asm(1) -> include-recursion.asm(1) -> include-recursion.asm(1) -> include-recursion.asm(1) -> include-recursion.asm(1) -> include-recursion.asm(1) -> include-recursion.asm(1) -> include-recursion.asm(1) -> include-recursion.asm(1) -> include-recursion.asm(1) -> include-recursion.asm(1) -> include-recursion.asm(1) -> include-recursion.asm(1) -> include-recursion.asm(1) -> include-recursion.asm(1) -> include-recursion.asm(1) -> include-recursion.asm(1) -> include-recursion.asm(1) -> include-recursion.asm(1) -> include-recursion.asm(1) -> include-recursion.asm(1) -> include-recursion.asm(1) -> include-recursion.asm(1) -> include-recursion.asm(1) -> include-recursion.asm(1) -> include-recursion.asm(1) -> include-recursion.asm(1) -> include-recursion.asm(1) -> include-recursion.asm(1) -> include-recursion.asm(1) -> include-recursion.asm(1) -> include-recursion.asm(1) -> include-recursion.asm(1) -> include-recursion.asm(1) -> include-recursion.asm(1) -> include-recursion.asm(1) -> include-recursion.asm(1) -> include-recursion.asm(1) -> include-recursion.asm(1) -> include-recursion.asm(1) -> include-recursion.asm(1) -> include-recursion.asm(1) -> include-recursion.asm(1) -> include-recursion.asm(1) -> include-recursion.asm(1) -> include-recursion.asm(1) -> include-recursion.asm(1) -> include-recursion.asm(1) -> include-recursion.asm(1) -> include-recursion.asm(1) -> include-recursion.asm(1) -> include-recursion.asm(1) -> include-recursion.asm(1) -> include-recursion.asm(1) -> include-recursion.asm(1) -> include-recursion.asm(1) -> include-recursion.asm(1) -> include-recursion.asm(1) -> include-recursion.asm(1) -> include-recursion.asm(1):
-    Recursion limit (64) exceeded
--- a/test/asm/label-macro-arg.out.pipe
+++ /dev/null
@@ -1,10 +1,0 @@
-ERROR: -(45) -> -::test_char(31):
-    Macro 'something' not defined
-$5
-$6
-$7
-$8
-sizeof__something equals $1
-sizeof_@something equals $1
-sizeof_#something equals $1
-sizeof_.something equals $1
--- a/test/asm/label-redefinition.out.pipe
+++ /dev/null
@@ -1,3 +1,0 @@
-ERROR: -(7):
-    'Sym' already defined in -::m(6)
-error: Assembly aborted (1 errors)!
--- a/test/asm/local-ref-without-parent.out.pipe
+++ /dev/null
@@ -1,2 +1,0 @@
-ERROR: -(3):
-    Local label reference '.test' in main scope
--- a/test/asm/local-without-parent.out.pipe
+++ /dev/null
@@ -1,2 +1,0 @@
-ERROR: -(2):
-    Local label in main scope
--- a/test/asm/local-wrong-parent.out.pipe
+++ /dev/null
@@ -1,3 +1,0 @@
-ERROR: -(5):
-    Not currently in the scope of 'WrongParent'
-error: Assembly aborted (1 errors)!
--- a/test/asm/[email protected]
+++ /dev/null
@@ -1,2 +1,0 @@
-ERROR: -(1):
-    Macro '@' not defined
--- a/test/asm/macro-recursion.out.pipe
+++ /dev/null
@@ -1,2 +1,0 @@
-ERROR: -(4) -> -::recurse(2) -> -::recurse(2) -> -::recurse(2) -> -::recurse(2) -> -::recurse(2) -> -::recurse(2) -> -::recurse(2) -> -::recurse(2) -> -::recurse(2) -> -::recurse(2) -> -::recurse(2) -> -::recurse(2) -> -::recurse(2) -> -::recurse(2) -> -::recurse(2) -> -::recurse(2) -> -::recurse(2) -> -::recurse(2) -> -::recurse(2) -> -::recurse(2) -> -::recurse(2) -> -::recurse(2) -> -::recurse(2) -> -::recurse(2) -> -::recurse(2) -> -::recurse(2) -> -::recurse(2) -> -::recurse(2) -> -::recurse(2) -> -::recurse(2) -> -::recurse(2) -> -::recurse(2) -> -::recurse(2) -> -::recurse(2) -> -::recurse(2) -> -::recurse(2) -> -::recurse(2) -> -::recurse(2) -> -::recurse(2) -> -::recurse(2) -> -::recurse(2) -> -::recurse(2) -> -::recurse(2) -> -::recurse(2) -> -::recurse(2) -> -::recurse(2) -> -::recurse(2) -> -::recurse(2) -> -::recurse(2) -> -::recurse(2) -> -::recurse(2) -> -::recurse(2) -> -::recurse(2) -> -::recurse(2) -> -::recurse(2) -> -::recurse(2) -> -::recurse(2) -> -::recurse(2) -> -::recurse(2) -> -::recurse(2) -> -::recurse(2) -> -::recurse(2) -> -::recurse(2) -> -::recurse(2):
-    Recursion limit (64) exceeded
--- a/test/asm/multiple-charmaps.out.pipe
+++ /dev/null
@@ -1,44 +1,0 @@
-warning: -(75):
-    Using 'charmap' within a section when the current charmap is 'main' is deprecated
-ERROR: -(100) -> -::new_(7):
-    Charmap 'map1' already exists
-ERROR: -(102) -> -::set_(13):
-    Charmap 'map5' doesn't exist
-ERROR: -(104) -> -::pop_(23):
-    No entries in the charmap stack
-main charmap
-$0
-newcharmap map1
-$6162
-newcharmap map2, main
-$0
-setcharmap map1
-$6162
-newcharmap map3
-$1
-newcharmap map4, map3
-$1
-$2
-setcharmap map3
-$1
-$6364
-setcharmap main
-$0
-override main charmap
-$6162
-$3
-setcharmap map1
-pushc
-setcharmap map2
-pushc
-setcharmap map3
-$1
-$6364
-$6566
-popc
-$0
-popc
-$6162
-newcharmap map1
-setcharmap map5
-popc
--- a/test/asm/null-in-macro.out.pipe
+++ /dev/null
@@ -1,2 +1,0 @@
-ERROR: -(1):
-    Unterminated MACRO definition.
--- a/test/asm/operator-precedence.out.pipe
+++ /dev/null
@@ -1,2 +1,0 @@
-$1
-$1
--- a/test/asm/overflow.out.pipe
+++ /dev/null
@@ -1,18 +1,0 @@
-warning: -(24):
-    Division of min value by -1
-warning: -(25):
-    Division of min value by -1
-warning: -(34):
-    Left shift of negative value: -1
-warning: -(35):
-    Left shift of negative value: -1
-warning: -(39):
-    Integer constant '4294967296' is too large
-warning: -(42):
-    Graphics constant '`333333333' is too long
-$80000000
-$7FFFFFFF
-$80000000
-$80000000
-$0
-$FFFFFFFE
--- a/test/asm/pops-no-pushed-sections.out.pipe
+++ /dev/null
@@ -1,2 +1,0 @@
-ERROR: -(1):
-    No entries in the section stack
--- a/test/asm/pops-restore-no-section.out.pipe
+++ /dev/null
@@ -1,2 +1,0 @@
-ERROR: -(10):
-    Code generation before SECTION directive
--- a/test/asm/reference-undefined-sym.out.pipe
+++ /dev/null
@@ -1,3 +1,0 @@
-ERROR: -(4):
-    'X' already referenced at -(2)
-error: Assembly aborted (1 errors)!
--- a/test/asm/remote-local-noexist.out.pipe
+++ /dev/null
@@ -1,2 +1,0 @@
-ERROR: -(7):
-    'Parent.child.fail' is a nonsensical reference to a nested local symbol
--- a/test/asm/strlen.out.pipe
+++ /dev/null
@@ -1,2 +1,0 @@
-$3
-$4
--- a/test/asm/strsub.out.pipe
+++ /dev/null
@@ -1,31 +1,0 @@
-warning: -(13) -> -::xstrsub(4):
-    STRSUB: Length too big: 32
-warning: -(14) -> -::xstrsub(4):
-    STRSUB: Length too big: 300
-warning: -(15) -> -::xstrsub(4):
-    STRSUB: Position starts at 1
-warning: -(15) -> -::xstrsub(4):
-    STRSUB: Length too big: 300
-warning: -(16) -> -::xstrsub(4):
-    STRSUB: Position 4 is past the end of the string
-warning: -(17) -> -::xstrsub(4):
-    STRSUB: Position 4 is past the end of the string
-warning: -(17) -> -::xstrsub(4):
-    STRSUB: Length too big: 1
-warning: -(20) -> -::xstrsub(4):
-    STRSUB: Length too big: 10
-A
-B
-C
-AB
-BC
-BC
-BC
-ABC
-
-
-カタ
-カナ
-カナ
-g
-g̈
--- a/test/asm/symbol-override.out.pipe
+++ /dev/null
@@ -1,8 +1,0 @@
-ERROR: -(6):
-    'W' already defined as constant at -(5)
-ERROR: -(10):
-    'X' already defined as constant at -(9)
-ERROR: -(14):
-    'Y' already defined as non-constant at -(13)
-error: Assembly aborted (3 errors)!
-V=$1
--- a/test/asm/test.sh
+++ b/test/asm/test.sh
@@ -9,11 +9,27 @@
 	for variant in '' '.pipe'; do
 		if [ -z "$variant" ]; then
 			../../rgbasm -o $o $i > $after 2>&1
+			desired_output=${i%.asm}.out
 		else
+			# `include-recursion.asm` refers to its own name inside the test code.
+			# Skip testing with stdin input for that file.
+			if [ "$i" = "include-recursion.asm" ]; then
+				continue
+			fi
+
+			# Stop! This is not a Useless Use Of Cat. Using cat instead of
+			# stdin redirection makes the input an unseekable pipe - a scenario
+			# that's harder to deal with and was broken when the feature was
+			# first implemented.
 			cat $i | ../../rgbasm -o $o - > $after 2>&1
+
+			# Escape regex metacharacters
+			desired_output=$before
+			subst="$(printf '%s\n' "$i" | sed 's:[][\/.^$*]:\\&:g')"
+			sed "s/$subst/-/g" ${i%.asm}.out > $desired_output
 		fi
 
-		diff -u ${i%.asm}.out$variant $after
+		diff -u $desired_output $after
 		rc=$(($? || $rc))
 		bin=${i%.asm}.out.bin
 		if [ -f $bin ]; then
--- a/test/asm/undefined-dot.out.pipe
+++ /dev/null
@@ -1,1 +1,0 @@
-error: -(3) : '.' not defined