2008-09-14 01:00:42 -07:00
|
|
|
#ifdef MOO_ENABLE_UNIT_TESTS
|
|
|
|
|
2008-05-23 13:07:14 -07:00
|
|
|
#include <mooedit/mooedit-tests.h>
|
|
|
|
#include <moolua/moolua-tests.h>
|
|
|
|
#include <mooutils/mooutils-tests.h>
|
2008-05-15 21:51:55 -07:00
|
|
|
#include <gtk/gtk.h>
|
2008-08-28 20:52:21 -07:00
|
|
|
#include <stdio.h>
|
2008-09-14 01:00:42 -07:00
|
|
|
#include "mem-debug.h"
|
2008-01-18 23:34:21 -08:00
|
|
|
|
2008-05-05 08:13:42 -07:00
|
|
|
static void
|
|
|
|
add_tests (void)
|
2008-01-18 23:34:21 -08:00
|
|
|
{
|
2008-02-02 14:54:52 -08:00
|
|
|
moo_test_gobject ();
|
2008-01-20 01:11:24 -08:00
|
|
|
moo_test_mooaccel ();
|
2008-01-18 23:34:21 -08:00
|
|
|
moo_test_mooutils_fs ();
|
2008-02-20 16:45:20 -08:00
|
|
|
moo_test_moo_file_writer ();
|
2008-02-03 00:02:26 -08:00
|
|
|
moo_test_mooutils_misc ();
|
2008-01-18 23:34:21 -08:00
|
|
|
|
2008-01-19 02:58:44 -08:00
|
|
|
#ifdef __WIN32__
|
|
|
|
moo_test_mooutils_win32 ();
|
|
|
|
#endif
|
|
|
|
|
2008-01-26 22:04:00 -08:00
|
|
|
moo_test_lua ();
|
2008-01-28 22:51:59 -08:00
|
|
|
moo_test_mooedit_lua_api ();
|
2008-01-26 22:04:00 -08:00
|
|
|
|
2008-02-03 00:02:26 -08:00
|
|
|
moo_test_key_file ();
|
2008-02-10 10:56:31 -08:00
|
|
|
moo_test_editor ();
|
2008-05-05 08:13:42 -07:00
|
|
|
}
|
|
|
|
|
2008-09-14 01:00:42 -07:00
|
|
|
static int
|
|
|
|
unit_tests_main (int argc, char *argv[])
|
2008-05-05 08:13:42 -07: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 01:00:42 -07:00
|
|
|
init_mem_stuff ();
|
2008-05-05 08:13:42 -07:00
|
|
|
g_thread_init (NULL);
|
2008-09-14 01:00:42 -07:00
|
|
|
g_set_prgname ("run-tests");
|
2008-02-10 10:56:31 -08:00
|
|
|
|
|
|
|
#ifdef __WIN32__
|
|
|
|
data_dir = "test-data";
|
|
|
|
#else
|
|
|
|
data_dir = SRCDIR "/data";
|
|
|
|
#endif
|
|
|
|
|
2008-05-05 08:13:42 -07: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 (argc > 2)
|
|
|
|
{
|
|
|
|
g_printerr ("invalid arguments\n");
|
|
|
|
exit (EXIT_FAILURE);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (list_only)
|
|
|
|
opts |= MOO_TEST_LIST_ONLY;
|
2008-02-03 00:02:26 -08:00
|
|
|
|
2008-05-05 08:13:42 -07:00
|
|
|
add_tests ();
|
|
|
|
moo_test_run_tests (argv[1], data_dir, opts);
|
2008-09-15 01:59:22 -07:00
|
|
|
|
2008-01-30 23:16:57 -08:00
|
|
|
moo_test_cleanup ();
|
2008-02-10 10:56:31 -08:00
|
|
|
|
|
|
|
#ifdef __WIN32__
|
2008-02-20 16:45:20 -08:00
|
|
|
if (!g_getenv ("WINESERVER"))
|
2008-08-28 20:52:21 -07:00
|
|
|
{
|
|
|
|
printf ("Done, press Enter...");
|
|
|
|
fflush (stdout);
|
2008-02-20 16:45:20 -08:00
|
|
|
getchar ();
|
2008-08-28 20:52:21 -07:00
|
|
|
}
|
2008-02-10 10:56:31 -08:00
|
|
|
#endif
|
|
|
|
|
2008-01-30 23:16:57 -08:00
|
|
|
return moo_test_get_result () ? 0 : 1;
|
2008-01-18 23:34:21 -08:00
|
|
|
}
|
2008-09-14 01:00:42 -07:00
|
|
|
|
|
|
|
#endif /* MOO_ENABLE_UNIT_TESTS */
|