Skip to content

Commit

Permalink
Convert fail_compile tests to CTest
Browse files Browse the repository at this point in the history
  • Loading branch information
kulp committed Jan 3, 2021
1 parent e56b238 commit 9b08818
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 12 deletions.
13 changes: 13 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,19 @@ check_failure(
ARGUMENTS -f does_not_exist /dev/null
)

file(GLOB fail_compile_INPUTS test/fail_compile/*.tas)
foreach(case ${fail_compile_INPUTS})

file(RELATIVE_PATH basename ${CMAKE_CURRENT_SOURCE_DIR}/test/fail_compile/ ${case})
check_failure(
NAME "fail_compile_${basename}"
EXPECT "syntax error|bailing|use before definition|Error|attempted"
COMMAND tas
ARGUMENTS ${case}
)

endforeach()

check_failure(
NAME "early end of file"
EXPECT "End of file unexpectedly reached"
Expand Down
14 changes: 2 additions & 12 deletions test/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,25 +6,15 @@ CPPFLAGS += -I$(TOP)/lib

vpath %.tas $(TOP)/lib

vpath %.tas pass_compile/ fail_compile/
vpath %.tas pass_compile/

get_obj_name = $(notdir $(patsubst %.tas,%.to,$1))

PASS_ASSEMBLE := $(call get_obj_name,$(wildcard pass_compile/*))
FAIL_ASSEMBLE := $(call get_obj_name,$(wildcard fail_compile/*))
# Force re-assembly of assembly-failure tests
.PHONY: $(FAIL_ASSEMBLE)

clean_FILES += *.to *.texe
clean_FILES += ops/*.texe

all: positive negative
all: positive
positive: $(PASS_ASSEMBLE)
negative: $(FAIL_ASSEMBLE)

$(filter %.to,$(FAIL_ASSEMBLE)): %.to: %.tas
@$(MAKESTEP) -n "Assembling `printf %-24s '$@'` (should fail) ... "
@(! $(tas) -o$@ $< 2>/dev/null) \
&& $(MAKESTEP) "failed as expected" \
|| ($(MAKESTEP) "succeeded unexpectedly" ; false)

0 comments on commit 9b08818

Please sign in to comment.