[epiphany] tests: test that trying to run an invalid migration step fails
- From: Xan Lopez <xan src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [epiphany] tests: test that trying to run an invalid migration step fails
- Date: Wed, 9 May 2012 21:39:04 +0000 (UTC)
commit 6c611eade581a8668e48270b39dc757830ce23ad
Author: Xan Lopez <xan igalia com>
Date: Wed May 9 23:35:12 2012 +0200
tests: test that trying to run an invalid migration step fails
lib/Makefile.am | 13 +++++++------
lib/ephy-profile-utils.c | 28 +++++++++++++++++++++++++---
lib/ephy-profile-utils.h | 2 +-
src/ephy-main.c | 2 +-
tests/ephy-migration-test.c | 13 ++++++++++++-
5 files changed, 46 insertions(+), 12 deletions(-)
---
diff --git a/lib/Makefile.am b/lib/Makefile.am
index a8a2f0e..5632810 100644
--- a/lib/Makefile.am
+++ b/lib/Makefile.am
@@ -82,12 +82,13 @@ nodist_libephymisc_la_SOURCES = \
$(BUILT_SOURCES)
libephymisc_la_CPPFLAGS = \
- -I$(top_builddir)/lib \
- -I$(top_builddir)/lib/egg \
- -I$(top_srcdir)/lib/egg \
- -DDATADIR="\"$(datadir)\"" \
- -DSHARE_DIR=\"$(pkgdatadir)\" \
- -DTOP_SRC_DATADIR=\"$(top_srcdir)/data\" \
+ -I$(top_builddir)/lib \
+ -I$(top_builddir)/lib/egg \
+ -I$(top_srcdir)/lib/egg \
+ -DDATADIR="\"$(datadir)\"" \
+ -DSHARE_DIR=\"$(pkgdatadir)\" \
+ -DTOP_SRC_DATADIR=\"$(top_srcdir)/data\" \
+ -DTOP_BUILD_DIR=\"$(top_builddir)\" \
-DEXTENSIONS_DIR=\""$(libdir)/epiphany/$(EPIPHANY_API_VERSION)/extensions"\" \
$(AM_CPPFLAGS)
diff --git a/lib/ephy-profile-utils.c b/lib/ephy-profile-utils.c
index 05367be..3fd3c52 100644
--- a/lib/ephy-profile-utils.c
+++ b/lib/ephy-profile-utils.c
@@ -188,21 +188,43 @@ _ephy_profile_utils_query_form_auth_data (const char *uri,
}
gboolean
-ephy_profile_utils_do_migration ()
+ephy_profile_utils_do_migration (int test_to_run, gboolean debug)
{
gboolean ret;
GError *error = NULL;
- char *argv[1] = { "ephy-profile-migrator" };
+ char *index = NULL, *path = NULL;
+ int status;
+ char *argv[3] = { "ephy_profile_migrator" };
char *envp[1] = { "EPHY_LOG_MODULES=ephy-profile" };
+ if (test_to_run != -1) {
+ index = g_strdup_printf ("%d", test_to_run);
+
+ argv[1] = "-d";
+ argv[2] = index;
+ argv[3] = NULL;
+ } else {
+ argv[1] = NULL;
+ }
+
+ if (debug) {
+ path = g_strdup_printf ("%s/lib/ephy-profile-migrator", TOP_BUILD_DIR);
+ argv[0] = path;
+ }
+
ret = g_spawn_sync (NULL, argv, envp, G_SPAWN_SEARCH_PATH,
NULL, NULL, NULL, NULL,
- NULL, &error);
+ &status, &error);
+ g_free (path);
+ g_free (index);
if (error) {
LOG ("Failed to run migrator: %s", error->message);
g_error_free (error);
}
+ if (status != 0)
+ ret = FALSE;
+
return ret;
}
diff --git a/lib/ephy-profile-utils.h b/lib/ephy-profile-utils.h
index 6a01549..9ae0957 100644
--- a/lib/ephy-profile-utils.h
+++ b/lib/ephy-profile-utils.h
@@ -32,7 +32,7 @@ int ephy_profile_utils_get_migration_version (void);
gboolean ephy_profile_utils_set_migration_version (int version);
-gboolean ephy_profile_utils_do_migration (void);
+gboolean ephy_profile_utils_do_migration (int test_to_run, gboolean debug);
void _ephy_profile_utils_store_form_auth_data (const char *uri,
const char *form_username,
diff --git a/src/ephy-main.c b/src/ephy-main.c
index 328e506..fa46b58 100644
--- a/src/ephy-main.c
+++ b/src/ephy-main.c
@@ -391,7 +391,7 @@ main (int argc,
/* TODO: we want to migrate each WebApp profile too. */
if (!private_instance && !application_mode)
- ephy_profile_utils_do_migration ();
+ ephy_profile_utils_do_migration (-1, FALSE);
/* Start our services */
flags = EPHY_FILE_HELPERS_ENSURE_EXISTS;
diff --git a/tests/ephy-migration-test.c b/tests/ephy-migration-test.c
index 8acfdb4..3051f2d 100644
--- a/tests/ephy-migration-test.c
+++ b/tests/ephy-migration-test.c
@@ -36,10 +36,19 @@ test_do_migration_simple (void)
{
gboolean ret;
- ret = ephy_profile_utils_do_migration ();
+ ret = ephy_profile_utils_do_migration (-1, TRUE);
g_assert (ret);
}
+static void
+test_do_migration_invalid (void)
+{
+ gboolean ret;
+
+ ret = ephy_profile_utils_do_migration (EPHY_PROFILE_MIGRATION_VERSION + 1, TRUE);
+ g_assert (ret == FALSE);
+}
+
int
main (int argc, char *argv[])
{
@@ -57,6 +66,8 @@ main (int argc, char *argv[])
g_test_add_func ("/lib/ephy-profile-utils/do_migration_simple",
test_do_migration_simple);
+ g_test_add_func ("/lib/ephy-profile-utils/do_migration_invalid",
+ test_do_migration_invalid);
return g_test_run ();
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]