Commit 77846d51 authored by Sebastian Ramacher's avatar Sebastian Ramacher

Refactor

parent 226478f4
......@@ -23,7 +23,7 @@ if check.found()
is_parallel: false
)
datastructures = executable('test_datastructures', ['test_datastructures.c'],
datastructures = executable('test_datastructures', ['test_datastructures.c', 'tests.c'],
dependencies: build_dependencies + test_dependencies,
include_directories: include_directories,
c_args: defines + flags
......@@ -52,7 +52,7 @@ if check.found()
is_parallel: false
)
template = executable('test_template', ['test_template.c'],
template = executable('test_template', ['test_template.c', 'tests.c'],
dependencies: build_dependencies + test_dependencies,
include_directories: include_directories,
c_args: defines + flags
......@@ -61,7 +61,7 @@ if check.found()
timeout: 60*60
)
utils = executable('test_utils', ['test_utils.c'],
utils = executable('test_utils', ['test_utils.c', 'tests.c'],
dependencies: build_dependencies + test_dependencies,
include_directories: include_directories,
c_args: defines + flags
......
......@@ -65,16 +65,5 @@ static Suite* suite_config(void)
int main()
{
Suite* suite = NULL;
SRunner* suite_runner = NULL;
int number_failed = 0;
/* test config */
suite = suite_config();
suite_runner = srunner_create(suite);
srunner_run_all(suite_runner, CK_NORMAL);
number_failed += srunner_ntests_failed(suite_runner);
srunner_free(suite_runner);
return (number_failed == 0) ? EXIT_SUCCESS : EXIT_FAILURE;
return run_suite(suite_config());
}
......@@ -419,16 +419,5 @@ static Suite* suite_datastructures(void)
int main()
{
Suite* suite = NULL;
SRunner* suite_runner = NULL;
int number_failed = 0;
/* test datastructures */
suite = suite_datastructures();
suite_runner = srunner_create(suite);
srunner_run_all(suite_runner, CK_NORMAL);
number_failed += srunner_ntests_failed(suite_runner);
srunner_free(suite_runner);
return (number_failed == 0) ? EXIT_SUCCESS : EXIT_FAILURE;
return run_suite(suite_datastructures());
}
......@@ -36,16 +36,5 @@ static Suite* suite_session(void)
int main()
{
Suite* suite = NULL;
SRunner* suite_runner = NULL;
int number_failed = 0;
/* test session */
suite = suite_session();
suite_runner = srunner_create(suite);
srunner_run_all(suite_runner, CK_NORMAL);
number_failed += srunner_ntests_failed(suite_runner);
srunner_free(suite_runner);
return (number_failed == 0) ? EXIT_SUCCESS : EXIT_FAILURE;
return run_suite(suite_session());
}
......@@ -67,7 +67,7 @@ START_TEST(test_settings_callback) {
girara_session_destroy(session);
} END_TEST
Suite* suite_settings(void)
static Suite* suite_settings(void)
{
TCase* tcase = NULL;
Suite* suite = suite_create("Settings");
......@@ -89,16 +89,5 @@ Suite* suite_settings(void)
int main()
{
Suite* suite = NULL;
SRunner* suite_runner = NULL;
int number_failed = 0;
/* test settings */
suite = suite_settings();
suite_runner = srunner_create(suite);
srunner_run_all(suite_runner, CK_NORMAL);
number_failed += srunner_ntests_failed(suite_runner);
srunner_free(suite_runner);
return (number_failed == 0) ? EXIT_SUCCESS : EXIT_FAILURE;
return run_suite(suite_settings());
}
......@@ -159,16 +159,5 @@ static Suite* suite_template(void)
int main()
{
Suite* suite = NULL;
SRunner* suite_runner = NULL;
int number_failed = 0;
/* test template */
suite = suite_template();
suite_runner = srunner_create(suite);
srunner_run_all(suite_runner, CK_NORMAL);
number_failed += srunner_ntests_failed(suite_runner);
srunner_free(suite_runner);
return (number_failed == 0) ? EXIT_SUCCESS : EXIT_FAILURE;
return run_suite(suite_template());
}
......@@ -312,16 +312,5 @@ static Suite* suite_utils(void)
int main()
{
Suite* suite = NULL;
SRunner* suite_runner = NULL;
int number_failed = 0;
/* test utils */
suite = suite_utils();
suite_runner = srunner_create(suite);
srunner_run_all(suite_runner, CK_NORMAL);
number_failed += srunner_ntests_failed(suite_runner);
srunner_free(suite_runner);
return (number_failed == 0) ? EXIT_SUCCESS : EXIT_FAILURE;
return run_suite(suite_utils());
}
/* See LICENSE file for license and copyright information */
#include <gtk/gtk.h>
#include <stdlib.h>
#include "tests.h"
int run_suite(Suite* suite)
{
SRunner* suite_runner = srunner_create(suite);
srunner_run_all(suite_runner, CK_NORMAL);
const int number_failed = srunner_ntests_failed(suite_runner);
srunner_free(suite_runner);
return (number_failed == 0) ? EXIT_SUCCESS : EXIT_FAILURE;
}
void setup(void)
{
gtk_init(NULL, NULL);
......
......@@ -3,6 +3,9 @@
#ifndef GIRARA_TESTS_H
#define GIRARA_TESTS_H
#include <check.h>
int run_suite(Suite* suite);
void setup(void);
#endif
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