Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support multiple tests with libtab #123

Merged
merged 1 commit into from
Feb 28, 2013
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 11 additions & 6 deletions tests/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,11 @@
# libtap.so and tap.h must be in the local directory or on the system path.

# ODIR is realative, so we can use the one from the main Makefile
TEST_SOURCES = $(wildcard *.cpp)
TEST__OBJS = $(TEST_SOURCES:.cpp=.o)
TEST_OBJS = $(patsubst %,$(ODIR)/%,$(TEST__OBJS))

# As each test will have a main function we need to handle this file by file
TEST_SOURCES = $(wildcard *_test.cpp)
TEST_OBJS = $(TEST_SOURCES:%.cpp=$(ODIR)/%.o)
TESTS = $(TEST_SOURCES:.cpp=)

# Brute force solution, relative paths to EVERY .o file
SOURCE_OBJS = $(patsubst %,../$(ODIR)/%,$(filter-out main.o,$(_OBJS)))
Expand All @@ -14,13 +16,16 @@ LDFLAGS += -L. -ltap -lpthread

CXXFLAGS += -I..

tests: line_test
tests: $(TESTS)

line_test: $(ODIR) $(DDIR) $(TEST__OBJS)
$(CXX) $(W32FLAGS) -o line_test $(DEFINES) $(TEST__OBJS) $(SOURCE_OBJS) $(LDFLAGS)
%_test: $(ODIR) $(DDIR) $(SOURCE_OBJS) $(TEST_OBJS)
$(CXX) $(W32FLAGS) -o $@ $(DEFINES) $(ODIR)/$@.o $(SOURCE_OBJS) $(LDFLAGS)

$(ODIR):
mkdir $(ODIR)

$(DDIR):
@mkdir $(DDIR)

$(ODIR)/%.o: %.cpp
$(CXX) $(DEFINES) $(CXXFLAGS) -c $< -o $@