make should fail in case of test failure

This commit is contained in:
Jakub Sztandera 2016-07-27 10:45:53 +01:00
parent b154a83b35
commit 8112dda4e8
4 changed files with 15 additions and 14 deletions

View file

@ -23,7 +23,7 @@ SRCS = src/errors.c src/hashes.c
OBJS = $(SRCS:.c=.o)
src/%.o: src/%.c
$(CC) $(CFLAGS) -c -I include $^ -o $@
$(CC) $(CFLAGS) -c -I include $< -o $@
all: $(TARGET_LIB) $(TARGET_BIN)
@ -44,11 +44,13 @@ test: $(TEST_BINS)
@for t in $^; do \
echo; \
echo '***' "$$t.c" '***'; \
"./$$t" || printf "\n!!! TEST FAILURE !!!\n"; \
done
"./$$t" || ERROR=1; \
done; \
echo; \
[ "$${ERROR-0}" -eq "1" ] && exit 1
tests/c/test_%.o: tests/c/test_%.c
$(CC) $(CFLAGS) -c -I include $^ -o $@
tests/c/test_%.o: tests/c/test_%.c tests/c/minunit.h
$(CC) $(CFLAGS) -c -I include $< -o $@
tests/c/test_%: tests/c/test_%.o $(TARGET_LIB)
$(CC) $(LDFLAGS) $^ -o $@

View file

@ -11,6 +11,7 @@ int main(void) {
char *result = mu_all_tests();
if (result != NULL) {
printf("error: %s\n", result);
printf("!!! TEST FAILURE !!!\n");
}
else {
printf("ALL TESTS PASSED\n");

View file

@ -9,8 +9,8 @@ char error_buf[256];
static char *test_error_messages_exist(void) {
int i = -1;
for (; i > MH_E_LAST; i--) {
sprintf(error_buf, "error: code %d has no message", i);
mu_assert(error_buf, strlen(mh_error_string((mh_error) i)));
sprintf(error_buf, "error code %d has no message", i);
mu_assert(error_buf, strlen(mh_error_string((mh_error) i)) > 0);
}
return NULL;

View file

@ -10,13 +10,11 @@ static char *test_all_hashes_have_lengths(void) {
int i = 0;
int length = 0;
for (; i < MH_H_COUNT; i++) {
length = mh_hash_default_length(i);
if (length <= 0) {
length = mh_hash_default_length((mh_hash) i);
sprintf(error_buf, "mh_hash_default_length: hash %d"
" returned invalid (%d) default length",
i, length);
return error_buf;
}
mu_assert(error_buf, length > 0);
}
return NULL;
}