From: Dale Weiler Date: Sun, 29 Apr 2012 21:28:01 +0000 (-0400) Subject: Invoke tests X-Git-Tag: 0.1-rc1~546 X-Git-Url: https://git.xonotic.org/?p=xonotic%2Fgmqcc.git;a=commitdiff_plain;h=8156374a71b8c4e7e5eb53703a74dcc15cc260d9 Invoke tests --- diff --git a/Makefile b/Makefile index 25ee1a4..3b04712 100644 --- a/Makefile +++ b/Makefile @@ -1,7 +1,6 @@ CC ?= clang CFLAGS += -Wall -I. -pedantic-errors -std=c90 -OBJ = main.o \ - lex.o \ +OBJ = lex.o \ error.o \ parse.o \ typedef.o \ @@ -10,9 +9,9 @@ OBJ = main.o \ asm.o \ ast.o \ ir.o -# ast and ir test -TEST_AST = test/ast-test.o -TEST_IR = test/ir-test.o +OBJ_A = test/ast-test.o +OBJ_I = test/ir-test.o +OBJ_C = main.o #default is compiler only default: gmqcc @@ -20,14 +19,14 @@ default: gmqcc $(CC) -c $< -o $@ $(CFLAGS) # test targets -test_ast: $(TEST_AST) $(OBJ) +test_ast: $(OBJ_A) $(OBJ) $(CC) -o $@ $^ $(CFLAGS) -test_ir: $(TEST_IR) $(OBJ) +test_ir: $(OBJ_I) $(OBJ) $(CC) -o $@ $^ $(CFLAGS) test: test_ast test_ir # compiler target -gmqcc: $(OBJ) +gmqcc: $(OBJ_C) $(OBJ) $(CC) -o $@ $^ $(CFLAGS) #all target is test and all diff --git a/main.c b/main.c index 81afc79..2256dc4 100644 --- a/main.c +++ b/main.c @@ -24,13 +24,6 @@ typedef struct { char *name, type; } argitem; VECTOR_MAKE(argitem, items); -/* global options */ -bool opts_debug = false; -bool opts_memchk = false; -bool opts_darkplaces_stringtablebug = false; -bool opts_omit_nullcode = false; -int opts_compiler = COMPILER_GMQCC; - static const int usage(const char *const app) { printf("usage:\n" " %s -c -oprog.dat -- compile file\n" diff --git a/test/ast-test.c b/test/ast-test.c index 5667c18..94cd82a 100644 --- a/test/ast-test.c +++ b/test/ast-test.c @@ -12,7 +12,7 @@ VECTOR_MAKE(ast_value*, globals); VECTOR_MAKE(ast_function*, functions); -void testast() +int main() { ast_expression *exp; ast_value *gfoo = NULL; @@ -117,4 +117,5 @@ void testast() } if (globals_data) mem_d(globals_data); + return 0; } diff --git a/test/ir-test.c b/test/ir-test.c index aedc290..c90bfd6 100644 --- a/test/ir-test.c +++ b/test/ir-test.c @@ -1,6 +1,6 @@ #include "gmqcc.h" #include "ir.h" -void builder1() +int main() { ir_builder *b = ir_builder_new("test"); ir_value *va = ir_builder_create_global(b, "a", TYPE_FLOAT); @@ -101,4 +101,5 @@ void builder1() ir_value_dump_life(la, printf); ir_builder_delete(b); + return 0; } diff --git a/util.c b/util.c index 9a23aed..7735a52 100644 --- a/util.c +++ b/util.c @@ -399,3 +399,11 @@ int util_getline(char **lineptr, size_t *n, FILE *stream) { *pos = '\0'; return (ret = pos - *lineptr); } + +/* TODO: opts.c? when it gets large enugh */ +/* global options */ +bool opts_debug = false; +bool opts_memchk = false; +bool opts_darkplaces_stringtablebug = false; +bool opts_omit_nullcode = false; +int opts_compiler = COMPILER_GMQCC;