diff options
author | Shawn O. Pearce <spearce@spearce.org> | 2008-11-03 17:00:54 -0800 |
---|---|---|
committer | Shawn O. Pearce <spearce@spearce.org> | 2008-11-03 18:42:54 -0800 |
commit | b923f2f97dc26e981c18da93b98bd5e7b44c3b79 (patch) | |
tree | 92142d22d55a2d449d5c563f6e72d827512cdd49 | |
parent | 3b8ab0b93539049b0f7c4a09f5dad48a1d89cd49 (diff) | |
download | libgit2-b923f2f97dc26e981c18da93b98bd5e7b44c3b79.tar.gz |
Fix Makefile to correctly handle 'make -j4 test'
If we have more than one test build running we cannot use the same
file for each test case; instead we need to use a per-test path so
there aren't any collisions.
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
-rw-r--r-- | Makefile | 42 | ||||
-rw-r--r-- | tests/.gitignore | 1 | ||||
-rw-r--r-- | tests/test_main.c | 4 |
3 files changed, 31 insertions, 16 deletions
@@ -28,7 +28,7 @@ all:: $(GIT_LIB) clean: rm -f $(GIT_LIB) rm -f src/*.o - rm -f tests/*.o tests/*.exe + rm -f tests/*.o tests/*.exe tests/*.toc rm -f include/git/config.h rm -rf apidocs @@ -50,22 +50,36 @@ $(GIT_LIB): $(OBJS) rm -f $(LIB) $(AR) cr $(GIT_LIB) $(OBJS) -T_HDR = tests/test_lib.h -T_LIB = tests/test_lib.o -T_MAIN_C = tests/test_main.c -T_MAIN_O = tests/test_main.o +T_HDR = tests/test_lib.h +T_LIB = tests/test_lib.o +T_MAIN_C = tests/test_main.c -$(T_LIB): tests/test_lib.h $(HDRS) -$(TEST_EXE): $(T_LIB) $(T_HDR) $(T_MAIN_C) $(HDRS) $(GIT_LIB) +$(T_LIB): $(T_HDR) $(HDRS) +$(TEST_OBJ): $(T_HDR) $(HDRS) -tests/%.exe: tests/%.o - grep BEGIN_TEST $(patsubst %.o,%.c,$<) >tests/test_contents - $(CC) $(CFLAGS) -Iinclude -c $(T_MAIN_C) -o $(T_MAIN_O) - $(CC) -o $@ $(T_MAIN_O) $< $(T_LIB) -L. -lgit2 - rm -f $(T_MAIN_O) tests/test_contents +$(patsubst %.exe,%.toc,$(TEST_EXE)): tests/%.toc: tests/%.c + grep BEGIN_TEST $< >$@+ + mv $@+ $@ -$(TEST_RUN): $(TEST_EXE) - $< +$(TEST_OBJ): tests/%.o: tests/%.c + $(CC) -Iinclude $(CFLAGS) -c $< -o $@ + +$(patsubst %.exe,%_main.o,$(TEST_EXE)): tests/%_main.o: $(HDRS) +$(patsubst %.exe,%_main.o,$(TEST_EXE)): tests/%_main.o: $(T_MAIN_C) +$(patsubst %.exe,%_main.o,$(TEST_EXE)): tests/%_main.o: tests/%.toc + $(CC) -Iinclude -I. '-DTEST_TOC="$<"' \ + -c $(T_MAIN_C) \ + -o $@ + +$(TEST_EXE): tests/%.exe: $(T_LIB) $(GIT_LIB) +$(TEST_EXE): tests/%.exe: tests/%.o tests/%_main.o + $(CC) -o $@ \ + $(patsubst %.exe,%_main.o,$@) \ + $(patsubst %.exe,%.o,$@) \ + $(T_LIB) -L. -lgit2 + +$(TEST_RUN): tests/%.run: tests/%.exe + @$< .PHONY: all .PHONY: clean diff --git a/tests/.gitignore b/tests/.gitignore new file mode 100644 index 000000000..690624bdf --- /dev/null +++ b/tests/.gitignore @@ -0,0 +1 @@ +*.toc diff --git a/tests/test_main.c b/tests/test_main.c index a870abdd5..6267cbc52 100644 --- a/tests/test_main.c +++ b/tests/test_main.c @@ -27,13 +27,13 @@ #undef BEGIN_TEST #define BEGIN_TEST(name) extern void testfunc__##name(void); -#include "test_contents" +#include TEST_TOC int main(int argc, char **argv) { #undef BEGIN_TEST #define BEGIN_TEST(name) testfunc__##name(); -#include "test_contents" +#include TEST_TOC return 0; } |