build(make): adding unitary test to the lib
- The files in test/ directory will be compiled and executed
This commit is contained in:
parent
60e9279f3a
commit
75ac0ede8a
1 changed files with 19 additions and 1 deletions
20
Makefile
20
Makefile
|
|
@ -110,6 +110,7 @@ clean:
|
||||||
fclean: clean
|
fclean: clean
|
||||||
@printf '$(GREY) Removing $(END)$(RED)Program$(END)\n'
|
@printf '$(GREY) Removing $(END)$(RED)Program$(END)\n'
|
||||||
@$(RM) $(NAME)
|
@$(RM) $(NAME)
|
||||||
|
@$(RM) ./.test/
|
||||||
@echo ""
|
@echo ""
|
||||||
|
|
||||||
# Restart (make re)
|
# Restart (make re)
|
||||||
|
|
@ -156,7 +157,24 @@ footer:
|
||||||
@printf "$(GOLD) /| | | |\\_//$(END)\n"
|
@printf "$(GOLD) /| | | |\\_//$(END)\n"
|
||||||
@printf "$(GOLD) \\| |._.| |/-\`$(END)\n"
|
@printf "$(GOLD) \\| |._.| |/-\`$(END)\n"
|
||||||
@printf "$(GOLD) '\"' '\"'$(END)\n"
|
@printf "$(GOLD) '\"' '\"'$(END)\n"
|
||||||
@printf ' $(GREY)The compilation is$(END) $(GOLD)finish$(END)\n $(GREY)Have a good $(END)$(GOLD)correction !$(END)\n'
|
@printf ' $(GREY)The compilation is$(END) $(GOLD)finished$(END)\n $(GREY)Have a good $(END)$(GOLD)correction !$(END)\n'
|
||||||
|
|
||||||
|
TEST_SRCS := $(shell find test -type f -name '*.c' 2>/dev/null)
|
||||||
|
|
||||||
|
TEST_BINS := $(patsubst test/%.c,.test/%,$(TEST_SRCS))
|
||||||
|
|
||||||
|
test: all $(LIB_NAME) $(TEST_BINS) test-run footer
|
||||||
|
|
||||||
|
.test/%: test/%.c $(LIB_NAME)
|
||||||
|
@mkdir -p $(dir $@)
|
||||||
|
@$(CC) $(CFLAGS) $(CPPFLAGS) $< -L. -lft $(LDFLAGS) -o $@
|
||||||
|
|
||||||
|
test-run:
|
||||||
|
@set -e; \
|
||||||
|
for t in $(TEST_BINS); do \
|
||||||
|
printf "\n\n$(GREY)>> Running $(GOLD)$$t$(END)\n"; \
|
||||||
|
TERM=xterm $$t; \
|
||||||
|
done; \
|
||||||
|
|
||||||
clangd:
|
clangd:
|
||||||
@printf "CompileFlags:\n" > ./.clangd
|
@printf "CompileFlags:\n" > ./.clangd
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue