From a820665eea71a64b40e74ed24afeaf07a7a99db4 Mon Sep 17 00:00:00 2001 From: Mike Buland Date: Fri, 26 May 2006 14:36:57 +0000 Subject: Added the first of many unit tests. For now the unit tests are just built with everything else in the all target of the makefile, which is fine, but relies on CppTest, which can be found at http://cpptest.sf.net Also fixed some things I've been meaning to get to for a while in the xml system, including a few bugs that will make coping with malformed data not hang other programs, and do the error reporting in a nice way. --- Makefile | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) (limited to 'Makefile') diff --git a/Makefile b/Makefile index 1add784..d034ffc 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,7 @@ OBJS:=$(patsubst %.cpp,%.o,$(wildcard src/*.cpp)) +USRCS:=$(wildcard src/unit/*.cpp) +UOBJS:=$(patsubst %.cpp,%.o,$(USRCS)) +UNIT:=$(foreach ut,$(patsubst %.cpp,%,$(wildcard src/unit/*.cpp)),unit/$(notdir $(ut))) TOBJS:=$(patsubst %.cpp,%.o,$(wildcard src/test/*.cpp)) TDIRS:=$(filter-out %.o %.cpp %.h %.d,$(wildcard src/test/*)) TESTS:=$(patsubst src/test/%.o,tests/%,$(TOBJS)) $(patsubst src/test/%,tests/%,$(TDIRS)) @@ -12,17 +15,17 @@ TXTDEP:="\ dep:\ \ \ " TXTARC:="\ \ ar:\ \ \ " .PHONY: all clean dist tests depclean cleanapi -.SILENT: clean $(OBJS) $(TOBJS) $(ATOBJS) $(TESTS) $(patsubst %.o,%.d,$(OBJS) $(TOBJS) $(ATOBJS) $(TESTS)) $(LIB) +.SILENT: clean $(OBJS) $(TOBJS) $(ATOBJS) $(UNIT) $(UOBJS) $(TESTS) $(patsubst %.o,%.d,$(OBJS) $(TOBJS) $(ATOBJS) $(TESTS)) $(LIB) -all: libbu++.a tests +all: libbu++.a tests unit depclean: - -rm $(patsubst %.o,%.d,$(OBJS) $(ATOBJS)) + -rm $(patsubst %.o,%.d,$(OBJS) $(ATOBJS) $(UOBJS)) --include $(patsubst %.o,%.d,$(OBJS) $(ATOBJS)) +-include $(patsubst %.o,%.d,$(OBJS) $(ATOBJS) $(UOBJS)) clean: - -rm $(OBJS) $(ATOBJS) $(TESTS) $(LIB) + -rm $(OBJS) $(ATOBJS) $(UOBJS) $(TESTS) $(LIB) # This bit I cribbed from the docs, seems to work great though! %.d: %.cpp @@ -41,8 +44,14 @@ $(TESTS): $(ATOBJS) $(LIB) echo "$(TXTLNK)$@" g++ $(LDFLAGS) -ggdb $(filter %$(patsubst tests/%,%,$@).o, $(TOBJS) ) $(patsubst %.cpp,%.o,$(wildcard $(filter %$(patsubst tests/%,%,$@), $(TDIRS))/*.cpp)) -L. -lbu++ -o $@ +$(UNIT): $(USRCS) $(LIB) + echo "$(TXTLNK)$@" + g++ $(LDFLAGS) -ggdb -Isrc -Isrc/unit src/$@.cpp -L. -lbu++ -lcpptest -o $@ + tests: $(TESTS) +unit: $(UNIT) + dist: clean depclean mkdir libbu++-$(DATE) cp -a --target-directory=libbu++-$(DATE) Makefile src -- cgit v1.2.3