* some more timezone fixes for the unit tests

This commit is contained in:
Dirk-Jan C. Binnema
2011-07-21 00:58:40 +03:00
parent 651493d47e
commit f0833ca315
4 changed files with 26 additions and 17 deletions

View File

@ -85,10 +85,13 @@ test_mu_cfind_bbdb (void)
const char* frm; const char* frm;
struct tm *tmtoday; struct tm *tmtoday;
time_t now; time_t now;
const char *old_tz;
muhome = fill_contacts_cache (); muhome = fill_contacts_cache ();
g_assert (muhome != NULL); g_assert (muhome != NULL);
old_tz = set_tz ("Europe/Helsinki");
cmdline = g_strdup_printf ("%s cfind --muhome=%s --format=bbdb " cmdline = g_strdup_printf ("%s cfind --muhome=%s --format=bbdb "
"'testmu\\.xxx?'", "'testmu\\.xxx?'",
MU_PROGRAM, muhome); MU_PROGRAM, muhome);
@ -120,6 +123,8 @@ test_mu_cfind_bbdb (void)
g_free (output); g_free (output);
g_free (erroutput); g_free (erroutput);
g_free (expected); g_free (expected);
set_tz (old_tz);
} }

View File

@ -41,6 +41,23 @@ test_mu_common_get_random_tmpdir (void)
} }
const char*
set_tz (const char* tz)
{
static const char* oldtz;
oldtz = getenv ("TZ");
if (tz)
setenv ("TZ", tz, 1);
else
unsetenv ("TZ");
tzset ();
return oldtz;
}
void void
black_hole (void) black_hole (void)
{ {

View File

@ -33,6 +33,8 @@ char* test_mu_common_get_random_tmpdir (void);
void black_hole (void); void black_hole (void);
const char* set_tz (const char* tz);
G_END_DECLS G_END_DECLS
#endif /*__TEST_MU_COMMON_H__*/ #endif /*__TEST_MU_COMMON_H__*/

View File

@ -338,21 +338,6 @@ test_mu_query_wildcards (void)
} }
static const char*
set_tz (const char* tz)
{
static const char* oldtz;
oldtz = getenv ("TZ");
if (tz)
setenv ("TZ", tz, 1);
else
unsetenv ("TZ");
tzset ();
return oldtz;
}
static void static void
test_mu_query_dates_helsinki (void) test_mu_query_dates_helsinki (void)