make should fail in case of test failure
This commit is contained in:
parent
b154a83b35
commit
8112dda4e8
4 changed files with 15 additions and 14 deletions
12
Makefile
12
Makefile
|
@ -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 $@
|
||||
|
|
|
@ -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");
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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) {
|
||||
sprintf(error_buf, "mh_hash_default_length: hash %d"
|
||||
" returned invalid (%d) default length",
|
||||
i, length);
|
||||
return error_buf;
|
||||
}
|
||||
length = mh_hash_default_length((mh_hash) i);
|
||||
sprintf(error_buf, "mh_hash_default_length: hash %d"
|
||||
" returned invalid (%d) default length",
|
||||
i, length);
|
||||
mu_assert(error_buf, length > 0);
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue