* updated test cases; in particular, use g_test_verbose

This commit is contained in:
Dirk-Jan C. Binnema 2011-09-03 10:51:00 +03:00
parent 273ed47eb6
commit 1a2614ec98
3 changed files with 36 additions and 35 deletions

View File

@ -115,7 +115,7 @@ test_mu_index (void)
store = mu_store_new_read_only (xpath, NULL);
g_assert (store);
g_assert_cmpuint (mu_store_count (store), ==, 9);
g_assert_cmpuint (mu_store_count (store, NULL), ==, 9);
mu_store_unref (store);
g_free (muhome);

View File

@ -46,7 +46,8 @@ fill_database (const char *testdir)
" --quiet",
MU_PROGRAM, tmpdir, testdir);
/* g_printerr ("\n%s\n", cmdline); */
if (g_test_verbose())
g_printerr ("\n%s\n", cmdline);
g_assert (g_spawn_command_line_sync (cmdline, NULL, NULL,
NULL, NULL));
@ -99,15 +100,14 @@ run_and_count_matches (const char *xpath, const char *query)
mu_store_unref (store);
/* g_printerr ("\n=>'%s'\n", query); */
/* { /\* debug *\/ */
/* char *xs; */
/* g_print ("query : '%s'\n", query); */
/* xs = mu_query_as_string (mquery, query, NULL); */
/* g_print ("xquery: '%s'\n", xs); */
/* g_free (xs); */
/* } */
if (g_test_verbose()) {
char *xs;
g_printerr ("\n=>'%s'\n", query);
g_print ("query : '%s'\n", query);
xs = mu_query_as_string (mquery, query, NULL);
g_print ("xquery: '%s'\n", xs);
g_free (xs);
}
iter = mu_query_run (mquery, query, FALSE, MU_MSG_FIELD_ID_NONE,
FALSE, NULL);
@ -161,7 +161,6 @@ test_mu_query_01 (void)
{ "", 13 }
};
xpath = fill_database (MU_TESTMAILDIR);
g_assert (xpath != NULL);
@ -394,7 +393,6 @@ test_mu_query_dates_sydney (void)
int i;
const char *old_tz;
QResults queries[] = {
{ "date:20080731..20080804", 5},
/* { "date:20080804..20080731", 5}, */
@ -598,9 +596,10 @@ main (int argc, char *argv[])
g_test_add_func ("/mu-query/test-mu-query-tags_02",
test_mu_query_tags_02);
g_log_set_handler (NULL,
G_LOG_LEVEL_MASK | G_LOG_FLAG_FATAL| G_LOG_FLAG_RECURSION,
(GLogFunc)black_hole, NULL);
if (!g_test_verbose())
g_log_set_handler (NULL,
G_LOG_LEVEL_MASK | G_LOG_FLAG_FATAL| G_LOG_FLAG_RECURSION,
(GLogFunc)black_hole, NULL);
rv = g_test_run ();

View File

@ -44,11 +44,11 @@ test_mu_store_new_destroy (void)
g_assert (tmpdir);
err = NULL;
store = mu_store_new_writable (tmpdir, NULL, &err);
store = mu_store_new_writable (tmpdir, NULL, FALSE, &err);
g_assert (store);
g_assert (err == NULL);
g_assert_cmpuint (0,==,mu_store_count (store));
g_assert_cmpuint (0,==,mu_store_count (store, NULL));
mu_store_flush (store);
mu_store_unref (store);
@ -68,7 +68,7 @@ test_mu_store_version (void)
g_assert (tmpdir);
err = NULL;
store = mu_store_new_writable (tmpdir, NULL, &err);
store = mu_store_new_writable (tmpdir, NULL, FALSE, &err);
g_assert (store);
mu_store_unref (store);
store = mu_store_new_read_only (tmpdir, &err);
@ -76,7 +76,7 @@ test_mu_store_version (void)
g_assert (err == NULL);
g_assert_cmpuint (0,==,mu_store_count (store));
g_assert_cmpuint (0,==,mu_store_count (store, NULL));
g_assert_cmpstr (MU_STORE_SCHEMA_VERSION,==,
mu_store_version(store));
@ -95,10 +95,10 @@ test_mu_store_store_msg_and_count (void)
tmpdir = test_mu_common_get_random_tmpdir();
g_assert (tmpdir);
store = mu_store_new_writable (tmpdir, NULL, NULL);
store = mu_store_new_writable (tmpdir, NULL, FALSE, NULL);
g_assert (store);
g_assert_cmpuint (0,==,mu_store_count (store));
g_assert_cmpuint (0,==,mu_store_count (store, NULL));
/* add one */
msg = mu_msg_new_from_file (
@ -106,10 +106,10 @@ test_mu_store_store_msg_and_count (void)
NULL, NULL);
g_assert (msg);
g_assert_cmpuint (mu_store_store_msg (store, msg, TRUE), ==, TRUE);
g_assert_cmpuint (1,==,mu_store_count (store));
g_assert_cmpuint (1,==,mu_store_count (store, NULL));
g_assert_cmpuint (TRUE,==,mu_store_contains_message
(store,
MU_TESTMAILDIR "cur/1283599333.1840_11.cthulhu!2,"));
MU_TESTMAILDIR "cur/1283599333.1840_11.cthulhu!2,", NULL));
mu_msg_unref (msg);
/* add another one */
@ -117,10 +117,10 @@ test_mu_store_store_msg_and_count (void)
"bar/cur/mail3", NULL, NULL);
g_assert (msg);
g_assert_cmpuint (mu_store_store_msg (store, msg, TRUE), ==, TRUE);
g_assert_cmpuint (2,==,mu_store_count (store));
g_assert_cmpuint (2,==,mu_store_count (store, NULL));
g_assert_cmpuint (TRUE,==,
mu_store_contains_message (store, MU_TESTMAILDIR2
"bar/cur/mail3"));
"bar/cur/mail3", NULL));
mu_msg_unref (msg);
/* try to add the first one again. count should be 2 still */
@ -129,7 +129,7 @@ test_mu_store_store_msg_and_count (void)
NULL, NULL);
g_assert (msg);
g_assert_cmpuint (mu_store_store_msg (store, msg, TRUE), ==, TRUE);
g_assert_cmpuint (2,==,mu_store_count (store));
g_assert_cmpuint (2,==,mu_store_count (store, NULL));
mu_msg_unref (msg);
@ -148,10 +148,10 @@ test_mu_store_store_msg_remove_and_count (void)
tmpdir = test_mu_common_get_random_tmpdir();
g_assert (tmpdir);
store = mu_store_new_writable (tmpdir, NULL, NULL);
store = mu_store_new_writable (tmpdir, NULL, FALSE, NULL);
g_assert (store);
g_assert_cmpuint (0,==,mu_store_count (store));
g_assert_cmpuint (0,==,mu_store_count (store, NULL));
/* add one */
err = NULL;
@ -160,16 +160,16 @@ test_mu_store_store_msg_remove_and_count (void)
NULL, &err);
g_assert (msg);
g_assert_cmpuint (mu_store_store_msg (store, msg, TRUE), ==, TRUE);
g_assert_cmpuint (1,==,mu_store_count (store));
g_assert_cmpuint (1,==,mu_store_count (store, NULL));
mu_msg_unref (msg);
/* remove one */
mu_store_remove_path (store,
MU_TESTMAILDIR "cur/1283599333.1840_11.cthulhu!2,");
g_assert_cmpuint (0,==,mu_store_count (store));
g_assert_cmpuint (0,==,mu_store_count (store, NULL));
g_assert_cmpuint (FALSE,==,mu_store_contains_message
(store,
MU_TESTMAILDIR "cur/1283599333.1840_11.cthulhu!2,"));
MU_TESTMAILDIR "cur/1283599333.1840_11.cthulhu!2,", NULL));
mu_store_unref (store);
}
@ -189,9 +189,11 @@ main (int argc, char *argv[])
test_mu_store_store_msg_and_count);
g_test_add_func ("/mu-store/mu-store-store-remove-and-count",
test_mu_store_store_msg_remove_and_count);
g_log_set_handler (NULL,
G_LOG_LEVEL_MASK | G_LOG_FLAG_FATAL| G_LOG_FLAG_RECURSION,
(GLogFunc)black_hole, NULL);
if (!g_test_verbose())
g_log_set_handler (NULL,
G_LOG_LEVEL_MASK | G_LOG_FLAG_FATAL| G_LOG_FLAG_RECURSION,
(GLogFunc)black_hole, NULL);
return g_test_run ();
}