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)
|
OBJS = $(SRCS:.c=.o)
|
||||||
|
|
||||||
src/%.o: src/%.c
|
src/%.o: src/%.c
|
||||||
$(CC) $(CFLAGS) -c -I include $^ -o $@
|
$(CC) $(CFLAGS) -c -I include $< -o $@
|
||||||
|
|
||||||
all: $(TARGET_LIB) $(TARGET_BIN)
|
all: $(TARGET_LIB) $(TARGET_BIN)
|
||||||
|
|
||||||
|
@ -44,11 +44,13 @@ test: $(TEST_BINS)
|
||||||
@for t in $^; do \
|
@for t in $^; do \
|
||||||
echo; \
|
echo; \
|
||||||
echo '***' "$$t.c" '***'; \
|
echo '***' "$$t.c" '***'; \
|
||||||
"./$$t" || printf "\n!!! TEST FAILURE !!!\n"; \
|
"./$$t" || ERROR=1; \
|
||||||
done
|
done; \
|
||||||
|
echo; \
|
||||||
|
[ "$${ERROR-0}" -eq "1" ] && exit 1
|
||||||
|
|
||||||
tests/c/test_%.o: tests/c/test_%.c
|
tests/c/test_%.o: tests/c/test_%.c tests/c/minunit.h
|
||||||
$(CC) $(CFLAGS) -c -I include $^ -o $@
|
$(CC) $(CFLAGS) -c -I include $< -o $@
|
||||||
|
|
||||||
tests/c/test_%: tests/c/test_%.o $(TARGET_LIB)
|
tests/c/test_%: tests/c/test_%.o $(TARGET_LIB)
|
||||||
$(CC) $(LDFLAGS) $^ -o $@
|
$(CC) $(LDFLAGS) $^ -o $@
|
||||||
|
|
|
@ -11,6 +11,7 @@ int main(void) {
|
||||||
char *result = mu_all_tests();
|
char *result = mu_all_tests();
|
||||||
if (result != NULL) {
|
if (result != NULL) {
|
||||||
printf("error: %s\n", result);
|
printf("error: %s\n", result);
|
||||||
|
printf("!!! TEST FAILURE !!!\n");
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
printf("ALL TESTS PASSED\n");
|
printf("ALL TESTS PASSED\n");
|
||||||
|
|
|
@ -9,8 +9,8 @@ char error_buf[256];
|
||||||
static char *test_error_messages_exist(void) {
|
static char *test_error_messages_exist(void) {
|
||||||
int i = -1;
|
int i = -1;
|
||||||
for (; i > MH_E_LAST; i--) {
|
for (; i > MH_E_LAST; i--) {
|
||||||
sprintf(error_buf, "error: code %d has no message", i);
|
sprintf(error_buf, "error code %d has no message", i);
|
||||||
mu_assert(error_buf, strlen(mh_error_string((mh_error) i)));
|
mu_assert(error_buf, strlen(mh_error_string((mh_error) i)) > 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
|
@ -10,13 +10,11 @@ static char *test_all_hashes_have_lengths(void) {
|
||||||
int i = 0;
|
int i = 0;
|
||||||
int length = 0;
|
int length = 0;
|
||||||
for (; i < MH_H_COUNT; i++) {
|
for (; i < MH_H_COUNT; i++) {
|
||||||
length = mh_hash_default_length(i);
|
length = mh_hash_default_length((mh_hash) i);
|
||||||
if (length <= 0) {
|
sprintf(error_buf, "mh_hash_default_length: hash %d"
|
||||||
sprintf(error_buf, "mh_hash_default_length: hash %d"
|
" returned invalid (%d) default length",
|
||||||
" returned invalid (%d) default length",
|
i, length);
|
||||||
i, length);
|
mu_assert(error_buf, length > 0);
|
||||||
return error_buf;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue