medit/moo/medit-app/run-tests.h

89 lines
1.9 KiB
C
Raw Normal View History

#include <mooedit/mooedit-tests.h>
#include <moolua/moolua-tests.h>
#include <mooutils/mooutils-tests.h>
#include <gtk/gtk.h>
2008-08-28 22:52:21 -05:00
#include <stdio.h>
2008-09-14 03:00:42 -05:00
#include "mem-debug.h"
2008-01-19 01:34:21 -06:00
2008-05-05 10:13:42 -05:00
static void
add_tests (void)
2008-01-19 01:34:21 -06:00
{
2008-02-02 16:54:52 -06:00
moo_test_gobject ();
2008-01-20 03:11:24 -06:00
moo_test_mooaccel ();
2008-01-19 01:34:21 -06:00
moo_test_mooutils_fs ();
2008-02-20 18:45:20 -06:00
moo_test_moo_file_writer ();
2008-02-03 02:02:26 -06:00
moo_test_mooutils_misc ();
2008-01-19 01:34:21 -06:00
2008-01-19 04:58:44 -06:00
#ifdef __WIN32__
moo_test_mooutils_win32 ();
#endif
2008-01-27 00:04:00 -06:00
moo_test_lua ();
2010-09-27 01:30:32 -07:00
// moo_test_key_file ();
2008-02-10 12:56:31 -06:00
moo_test_editor ();
2008-05-05 10:13:42 -05:00
}
2008-09-14 03:00:42 -05:00
static int
unit_tests_main (int argc, char *argv[])
2008-05-05 10:13:42 -05:00
{
const char *data_dir;
GOptionContext *ctx;
GOptionGroup *grp;
GError *error = NULL;
MooTestOptions opts = 0;
gboolean list_only = FALSE;
GOptionEntry options[] = {
{ "list", 0, 0, G_OPTION_ARG_NONE, &list_only, "List available tests", NULL },
{ NULL, 0, 0, 0, NULL, NULL, NULL }
};
2008-09-14 03:00:42 -05:00
init_mem_stuff ();
2008-05-05 10:13:42 -05:00
g_thread_init (NULL);
2008-09-14 03:00:42 -05:00
g_set_prgname ("run-tests");
2008-02-10 12:56:31 -06:00
2010-09-27 01:25:15 -07:00
data_dir = MOO_UNIT_TEST_DATA_DIR;
2008-02-10 12:56:31 -06:00
2008-05-05 10:13:42 -05:00
grp = g_option_group_new ("run-tests", "run-tests", "run-tests", NULL, NULL);
g_option_group_add_entries (grp, options);
ctx = g_option_context_new ("[TEST_SUITE]");
g_option_context_set_main_group (ctx, grp);
g_option_context_add_group (ctx, gtk_get_option_group (TRUE));
if (!g_option_context_parse (ctx, &argc, &argv, &error))
{
g_printerr ("%s\n", error->message);
exit (EXIT_FAILURE);
}
#if !GLIB_CHECK_VERSION(2,8,0)
g_set_prgname ("run-tests");
#endif
2008-05-05 10:13:42 -05:00
if (argc > 2)
{
g_printerr ("invalid arguments\n");
exit (EXIT_FAILURE);
}
if (list_only)
opts |= MOO_TEST_LIST_ONLY;
2008-02-03 02:02:26 -06:00
2008-05-05 10:13:42 -05:00
add_tests ();
moo_test_run_tests (argv[1], data_dir, opts);
2008-09-15 03:59:22 -05:00
2008-01-31 01:16:57 -06:00
moo_test_cleanup ();
2008-02-10 12:56:31 -06:00
#ifdef __WIN32__
2010-07-13 04:52:45 -07:00
if (!g_getenv ("WINESERVER") && !list_only)
2008-08-28 22:52:21 -05:00
{
printf ("Done, press Enter...");
fflush (stdout);
2008-02-20 18:45:20 -06:00
getchar ();
2008-08-28 22:52:21 -05:00
}
2008-02-10 12:56:31 -06:00
#endif
2008-01-31 01:16:57 -06:00
return moo_test_get_result () ? 0 : 1;
2008-01-19 01:34:21 -06:00
}