mirror of
https://git.proxmox.com/git/libgit2
synced 2025-05-02 16:34:37 +00:00
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>
This commit is contained in:
parent
3b8ab0b935
commit
b923f2f97d
42
Makefile
42
Makefile
@ -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
|
||||
|
1
tests/.gitignore
vendored
Normal file
1
tests/.gitignore
vendored
Normal file
@ -0,0 +1 @@
|
||||
*.toc
|
@ -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;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user