Refactor: fixtures in its own files.

Added readme for creating tests.
Found and fixed interesting bugs in destroy_db when there is no world.
renamed the testfile to testrunner to make it clear it is actually running the texts. Also, made testrunner more focused on the actual running of the tests.
Added debug target to test makefile.
This commit is contained in:
welcor
2024-06-27 00:31:54 +02:00
parent 9399b68f26
commit c8fc70bf43
11 changed files with 318 additions and 181 deletions

View File

@@ -8,7 +8,7 @@ ASAN:=n
UBSAN:=n
EXTENSION:=
TEST_ENV:=
CFLAGS:=-Wall -Wno-char-subscripts -Wno-unused-but-set-variable
CFLAGS:=-Wall -Wno-char-subscripts -Wno-unused-but-set-variable -g
CFLAGS+=-Wl,--wrap=send_to_char,--wrap=vwrite_to_output
AGGRESSIVE_WARNINGS=n
LIBS:=-lcrypt
@@ -45,27 +45,31 @@ ifneq ($(CC),pgcc)
endif
endif
MUNIT_FILES := ../munit/munit.h ../munit/munit.c
#MUNIT_FILES := ../munit/munit.h ../munit/munit.c
TEST_FILES := $(ls *.c)
# exclude main.c to avoid having multiple entrypoints.
OBJ_FILES_FROM_MUD_CODE != ls ../*.c | grep -v main.c | sed 's/\.c$$/.o/g' | xargs
OBJ_FILES_FORM_MUNIT:= ../munit/munit.o
OBJ_FILES_FROM_TESTS!= ls *.c | sed 's/\$$.c/.o/g' | xargs
OBJ_FILES_FROM_MUNIT:= ../munit/munit.o
OBJ_FILES_FROM_TESTS!= ls *.c | sed 's/\.c/.o/g' | xargs
OBJ_FILES := $(OBJ_FILES_FROM_MUD_CODE) $(OBJ_FILES_FORM_MUNIT) $(OBJ_FILES_FROM_TESTS) $(LIBS)
OBJ_FILES := $(OBJ_FILES_FROM_MUD_CODE) $(OBJ_FILES_FROM_MUNIT) $(OBJ_FILES_FROM_TESTS) $(LIBS)
testfile: $(OBJ_FILES)
$(CC) $(CFLAGS) -o testfile $(OBJ_FILES)
testrunner: $(OBJ_FILES)
$(CC) $(CFLAGS) -o testrunner $(OBJ_FILES)
test: testrunner
$(TEST_ENV) ./testrunner
debug: testrunner
$(TEST_ENV) gdb -q --args ./testrunner --no-fork
test: testfile
$(TEST_ENV) ./testfile
$%.o: %.c
$(CC) $< $(CFLAGS) -c -o $@
clean:
rm -f *.o testfile depend
rm -f *.o testrunner depend
all: test
default: all