Commit 8ddbb158 authored by Moritz Lipp's avatar Moritz Lipp

Implement test suite with check

parent 226dfae1
......@@ -4,7 +4,7 @@ include config.mk
include common.mk
PROJECT = zathura
SOURCE = $(shell find . -iname "*.c" -a ! -iname "database-*")
SOURCE = $(shell find . -iname "*.c" -a ! -iname "database-*" ! -path "*tests*")
OBJECTS = $(patsubst %.c, %.o, $(SOURCE))
DOBJECTS = $(patsubst %.c, %.do, $(SOURCE))
......@@ -70,6 +70,9 @@ valgrind: debug
gdb: debug
cgdb ${PROJECT}-debug
tests: ${OBJECTS}
$(QUIET)make -C tests
dist: clean
$(QUIET)mkdir -p ${PROJECT}-${VERSION}
$(QUIET)cp -R LICENSE Makefile config.mk README \
......
......@@ -8,6 +8,7 @@ Requirements
gtk2 (>= 2.18.6)
girara
sqlite3
check (for tests)
Please note that you need to have a working pkg-config installation and that the
Makefile is only compatible with GNU make. If you don't have a working
......
......@@ -143,7 +143,6 @@ config_load_default(zathura_t* zathura)
girara_inputbar_command_add(gsession, "write!", NULL, cmd_savef, NULL, "Save document (and force overwriting)");
girara_inputbar_command_add(gsession, "export", NULL, cmd_export, cc_export, "Save attachments");
girara_special_command_add(gsession, '/', cmd_search, true, FORWARD, NULL);
girara_special_command_add(gsession, '?', cmd_search, true, BACKWARD, NULL);
......
/* See LICENSE file for license and copyright information */
#include <stdio.h>
#include <glib/gstdio.h>
#include "zathura.h"
/* main function */
int main(int argc, char* argv[])
{
g_thread_init(NULL);
gdk_threads_init();
gtk_init(&argc, &argv);
zathura_t* zathura = zathura_init(argc, argv);
if (zathura == NULL) {
fprintf(stderr, "error: could not initialize zathura\n");
return -1;
}
gdk_threads_enter();
gtk_main();
gdk_threads_leave();
zathura_free(zathura);
return 0;
}
# See LICENSE file for license and copyright information
include ../config.mk
include ../common.mk
include config.mk
PROJECT = tests
SOURCE = tests.c $(wildcard test_*.c)
OBJECTS = ${SOURCE:.c=.o}
ZSOURCE = $(shell find ../ -iname "*.c" -a ! -iname "database-*" ! -iname "main.c" ! -path "*tests*")
ZOBJECTS = ${ZSOURCE:.c=.o}
ifeq (${DATABASE}, sqlite)
ZSOURCE += ../database-sqlite.c
else
ifeq (${DATABASE}, plain)
ZSOURCE += ../database-plain.c
endif
endif
all: options ${PROJECT} run
run:
$(QUIET)./${PROJECT}
options:
@echo ${PROJECT} build options:
@echo "CFLAGS = ${CFLAGS}"
@echo "LDFLAGS = ${LDFLAGS}"
@echo "DFLAGS = ${DFLAGS}"
@echo "CC = ${CC}"
%.o: %.c
$(ECHO) CC $<
@mkdir -p .depend
$(QUIET)${CC} -c -I.. ${CPPFLAGS} ${CFLAGS} -o $@ $< -MMD -MF .depend/$@.dep
${PROJECT}: ${OBJECTS}
$(ECHO) CC -o $@
$(QUIET)${CC} ${SFLAGS} ${LDFLAGS} -o $@ ${OBJECTS} ${ZOBJECTS} ${LIBS}
${OBJECTS}: ../config.mk
clean:
$(QUIET)rm -rf ${OBJECTS} ${PROJECT}
.PHONY: all options clean debug
-include $(wildcard .depend/*.dep)
# See LICENSE file for license and copyright information
CHECK_INC ?= $(shell pkg-config --cflags check)
CHECK_LIB ?= $(shell pkg-config --libs check)
LIBS += ${CHECK_LIB}
/* See LICENSE file for license and copyright information */
#include <check.h>
#include "../utils.h"
START_TEST(test_file_exists_null) {
fail_unless(file_exists(NULL) == false);
} END_TEST
START_TEST(test_file_get_extension_null) {
fail_unless(file_get_extension(NULL) == false);
} END_TEST
Suite* suite_utils()
{
TCase* tcase = NULL;
Suite* suite = suite_create("Utils");
/* file exists */
tcase = tcase_create("file_exists");
tcase_add_test(tcase, test_file_exists_null);
suite_add_tcase(suite, tcase);
/* file exists */
tcase = tcase_create("file_get_extension");
tcase_add_test(tcase, test_file_get_extension_null);
suite_add_tcase(suite, tcase);
return suite;
}
/* See LICENSE file for license and copyright information */
#include <check.h>
#include <girara/macros.h>
#define UNUSED(x) GIRARA_UNUSED(x)
Suite* suite_utils();
int main(int UNUSED(argc), char *UNUSED(argv[]))
{
Suite* suite = NULL;
SRunner* suite_runner = NULL;
/* test utils */
suite = suite_utils();
suite_runner = srunner_create(suite);
srunner_run_all(suite_runner, CK_NORMAL);
srunner_free(suite_runner);
return 0;
}
......@@ -613,26 +613,3 @@ page_view_set_mode(zathura_t* zathura, unsigned int pages_per_row)
gtk_widget_show_all(zathura->ui.page_view);
}
/* main function */
int main(int argc, char* argv[])
{
g_thread_init(NULL);
gdk_threads_init();
gtk_init(&argc, &argv);
zathura_t* zathura = zathura_init(argc, argv);
if (zathura == NULL) {
printf("error: could not initialize zathura\n");
return -1;
}
gdk_threads_enter();
gtk_main();
gdk_threads_leave();
zathura_free(zathura);
return 0;
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment