]> git.xonotic.org Git - xonotic/gmqcc.git/commitdiff
Invoke tests
authorDale Weiler <killfieldengine@gmail.com>
Sun, 29 Apr 2012 21:28:01 +0000 (17:28 -0400)
committerDale Weiler <killfieldengine@gmail.com>
Sun, 29 Apr 2012 21:28:01 +0000 (17:28 -0400)
Makefile
main.c
test/ast-test.c
test/ir-test.c
util.c

index 25ee1a47c0ea70233c66a10bb8a9518a97224607..3b04712c001bf56e8e137c1c847c207d33e353be 100644 (file)
--- 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 81afc79a15a74a80adaab6bdca45137e473f3d79..2256dc444ff70179f5c7191e1bd93b1c0fe41c9e 100644 (file)
--- a/main.c
+++ b/main.c
 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<file>          -oprog.dat -- compile file\n"
index 5667c1892165b384f7b91ab6667daba29742c943..94cd82ac138c95705f85d3d0c25d53a5b95620de 100644 (file)
@@ -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;
 }
index aedc290d04bf202fddd459533ed15e5eabb01e31..c90bfd6f206d16708bb1ae8d4a2c03dedfbf9fba 100644 (file)
@@ -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 9a23aed96400f62270240cc7d3d3d5421858e9da..7735a52457dba0e8a12b45ab1bf2013273b7f1f9 100644 (file)
--- 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;