Add more tests for RGBASM coverage

This commit is contained in:
Rangi42
2025-09-25 12:21:08 -04:00
parent 96b953fe51
commit 0297da4d4c
29 changed files with 112 additions and 19 deletions

View File

@@ -0,0 +1,15 @@
macro careful
if _NARG == 20
warn "You're in too deep!"
else
careful \#, deeper
endc
endm
careful surface
macro recurse
recurse
endm
rept 3
recurse
endr

View File

@@ -0,0 +1,4 @@
warning: You're in too deep! [-Wuser]
at backtrace-collapsed.asm::careful(3) <- backtrace-collapsed.asm::careful(5) <- backtrace-collapsed.asm::careful(5) <- ...16 more... <- backtrace-collapsed.asm::careful(5) <- backtrace-collapsed.asm(8)
FATAL: Recursion limit (64) exceeded
at backtrace-collapsed.asm::recurse(11) <- backtrace-collapsed.asm::recurse(11) <- backtrace-collapsed.asm::recurse(11) <- ...60 more... <- backtrace-collapsed.asm::REPT~1(14) <- backtrace-collapsed.asm(13)

View File

@@ -0,0 +1 @@
-B 5 -B collapse

View File

@@ -0,0 +1 @@
FATAL: Empty feature for option '-s'

View File

@@ -0,0 +1 @@
-s :-

View File

@@ -1 +1 @@
--color yes
--color=always --color=never --color=auto --color=yes

View File

@@ -0,0 +1 @@
FATAL: Invalid feature for option '-s': "invalid"

View File

@@ -0,0 +1 @@
-s invalid:-

View File

@@ -0,0 +1,10 @@
MACRO test
assert warn, 0, "-Wassert is on by default"
warn "-Wuser is on by default"
ENDM
test ; no warnings because of -w
OPT -Weverything
test ; still no warnings because of -w
OPT Werror=everything
test ; now errors can occur

View File

@@ -0,0 +1 @@
-w

View File

@@ -1 +1 @@
-B all
-B no-all -B all

0
test/asm/make-deps.asm Normal file
View File

1
test/asm/make-deps.flags Normal file
View File

@@ -0,0 +1 @@
-M - -MT preserve$dollars$$ -MQ escape$dollars$$

1
test/asm/make-deps.out Normal file
View File

@@ -0,0 +1 @@
preserve$dollars$$ escape$$dollars$$$$: make-deps.asm

1
test/asm/opt-r.flags Normal file
View File

@@ -0,0 +1 @@
-r9 -r$f -r%1 -r&7 -r0xFF -r0b11 -r0o77 -r64

View File

@@ -0,0 +1,7 @@
MACRO one
!@#$%^&* /* anything */ :'<,>./? ; goes!
ENDM
CHARMAP "char", 2, 3
DEF string EQUS "four"
DEF variable = 5
DEF constant EQU 6

View File

@@ -0,0 +1,2 @@
warning: Ignoring duplicate feature for option '-s': "equ"
warning: Redundant feature before "all" for option '-s'

View File

@@ -0,0 +1 @@
-s equ,var,equ,all:-

View File

@@ -0,0 +1,19 @@
; File generated by rgbasm
; Numeric constants
def constant equ $6
; Variables
def variable = $5
; String constants
def string equs "four"
; Character maps
newcharmap main
charmap "char", $2, $3
; Macros
macro one
!@#$%^&* /* anything */ :'<,>./? ; goes!
endm

View File

@@ -84,10 +84,11 @@ for i in *.asm notexist.asm; do
desired_output=$desired_outname
desired_errput=$desired_errname
else
# `include-recursion.asm` refers to its own name inside the test code.
# "notexist" doesn't exist, so there's no point in trying to `cat` it.
# Skip testing with stdin input for those file.
if [[ "$i" = include-recursion.asm || "$i" = notexist.asm ]]; then
# "include-recursion.asm" refers to its own name inside the test code.
# "make-deps.asm" refers to its output filename in its desired output.
# "notexist.asm" doesn't exist, so there's no point in trying to `cat` it.
# Skip testing with stdin input for those files.
if [[ "$i" = include-recursion.asm || "$i" = make-deps.asm || "$i" = notexist.asm ]]; then
continue
fi
@@ -193,18 +194,20 @@ i="state-file"
if which cygpath &>/dev/null; then
# MinGW translates path names before passing them as command-line arguments,
# but does not do so when they are prefixed, so we have to do it ourselves.
RGBASMFLAGS="-Weverything -Bcollapse -s all:$(cygpath -w "$o")"
state_outname="$(cygpath -w "$o")"
else
RGBASMFLAGS="-Weverything -Bcollapse -s all:$o"
state_outname="$o"
fi
state_features=" all " # Test trimming whitespace
RGBASMFLAGS="-Weverything -Bcollapse"
for variant in '' '.pipe'; do
(( tests++ ))
echo "${bold}${green}${i%.asm}${variant}...${rescolors}${resbold}"
if [ -z "$variant" ]; then
"$RGBASM" $RGBASMFLAGS "$i"/a.asm >"$output" 2>"$errput"
"$RGBASM" $RGBASMFLAGS -s "$state_features:$state_outname" "$i"/a.asm >"$output" 2>"$errput"
else
# shellcheck disable=SC2002
cat "$i"/a.asm | "$RGBASM" $RGBASMFLAGS - >"$output" 2>"$errput"
cat "$i"/a.asm | "$RGBASM" $RGBASMFLAGS -s "$state_features:$state_outname" - >"$output" 2>"$errput"
fi
tryDiff /dev/null "$output" out

View File

View File

@@ -0,0 +1,2 @@
warning: Unknown warning flag "noexist"
warning: Unknown warning flag parameter "noexistparam=2"

View File

@@ -0,0 +1 @@
-Wnoexist -Wnoexistparam=2

View File

@@ -0,0 +1,14 @@
DEF n = -99 >> 1 ; -Wshift
DEF n = 999_999_999_999 ; -Wlarge-constant
MACRO test
WARN "warning or error?"
ENDM
test
OPT Werror
test
OPT Wno-error
test

View File

@@ -0,0 +1,10 @@
warning: Shifting right negative value -99 [-Wshift]
at warning-as-error.asm(1)
error: Integer constant is too large [-Werror=large-constant]
at warning-as-error.asm(2)
warning: warning or error? [-Wuser]
at warning-as-error.asm::test(5) <- warning-as-error.asm(8)
error: warning or error? [-Werror=user]
at warning-as-error.asm::test(5) <- warning-as-error.asm(11)
warning: warning or error? [-Wuser]
at warning-as-error.asm::test(5) <- warning-as-error.asm(14)

View File

@@ -0,0 +1 @@
-Werror=shift -Wno-error=shift -Werror=large-constant