Include full c source to assert static objects

To assert static objects, we either have to add a method into the
object under test itself and recompile on a test run with the activated test
method (but also recompile after tests, so that method is gone on
release builds).

Alternatively we can include the whole .c file in our test
infrastructure and save the object in the test directory. So there's no
necessity to clean it up prior to a release build and it's contained
away.

This requires, that the test folder isn't excluded in coveralls.
This commit is contained in:
Benedikt Heine 2018-10-10 12:03:43 +02:00
parent b4c319350a
commit 2e9d8300de
7 changed files with 12 additions and 24 deletions

View File

@ -33,7 +33,7 @@ matrix:
include:
- compiler: gcc
after_success:
- coveralls --exclude 'test'
- coveralls
- compiler: clang
after_success:
- coveralls --exclude 'test' --gcov llvm-cov --gcov-options gcov
- coveralls --gcov llvm-cov --gcov-options gcov

View File

@ -96,8 +96,11 @@ test-coverage-report: test-coverage
--html-details \
-o docs/internal/coverage/index.html
test/%.o: test/%.c src/%.c
${CC} -o $@ -c $< ${CFLAGS}
test/test: ${OBJ} ${TEST_OBJ}
${CC} -o ${@} ${TEST_OBJ} ${OBJ} ${CFLAGS} ${LDFLAGS}
${CC} -o ${@} ${TEST_OBJ} $(filter-out ${TEST_OBJ:test/%=src/%},${OBJ}) ${CFLAGS} ${LDFLAGS}
.PHONY: doc doc-doxygen
doc: docs/dunst.1

View File

@ -1,9 +1,5 @@
#include "../src/icon.c"
#include "greatest.h"
#include "../src/icon.h"
#include "../src/utils.h"
#include <gdk-pixbuf/gdk-pixbuf.h>
#include <glib.h>
#define ICONPREFIX "/data/icons/path"

View File

@ -1,10 +1,6 @@
#include "src/markup.c"
#include "greatest.h"
#include <stdbool.h>
#include <glib.h>
#include "src/markup.h"
TEST test_markup_strip(void)
{
char *ptr;

View File

@ -1,10 +1,9 @@
#include "src/notification.c"
#include "greatest.h"
#include "src/notification.h"
#include "src/option_parser.h"
#include "src/settings.h"
#include <glib.h>
TEST test_notification_is_duplicate_field(char **field,
struct notification *a,
struct notification *b)

View File

@ -1,10 +1,6 @@
#include "src/option_parser.c"
#include "greatest.h"
#include <stdbool.h>
#include <glib.h>
#include "src/option_parser.h"
TEST test_next_section(void)
{
const char *section = NULL;

View File

@ -1,7 +1,5 @@
#include "src/utils.c"
#include "greatest.h"
#include "src/utils.h"
#include <glib.h>
TEST test_string_replace_char(void)
{