aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorXan Lopez <xan@igalia.com>2012-05-10 05:35:12 +0800
committerXan Lopez <xan@igalia.com>2012-05-10 05:35:12 +0800
commit6c611eade581a8668e48270b39dc757830ce23ad (patch)
tree85c9114827eea052dbc023ef4d31165a775b07e5
parentd30b9aed33f491a430a79b36409655d2d45afa8d (diff)
downloadgsoc2013-epiphany-6c611eade581a8668e48270b39dc757830ce23ad.tar
gsoc2013-epiphany-6c611eade581a8668e48270b39dc757830ce23ad.tar.gz
gsoc2013-epiphany-6c611eade581a8668e48270b39dc757830ce23ad.tar.bz2
gsoc2013-epiphany-6c611eade581a8668e48270b39dc757830ce23ad.tar.lz
gsoc2013-epiphany-6c611eade581a8668e48270b39dc757830ce23ad.tar.xz
gsoc2013-epiphany-6c611eade581a8668e48270b39dc757830ce23ad.tar.zst
gsoc2013-epiphany-6c611eade581a8668e48270b39dc757830ce23ad.zip
tests: test that trying to run an invalid migration step fails
-rw-r--r--lib/Makefile.am13
-rw-r--r--lib/ephy-profile-utils.c28
-rw-r--r--lib/ephy-profile-utils.h2
-rw-r--r--src/ephy-main.c2
-rw-r--r--tests/ephy-migration-test.c13
5 files changed, 46 insertions, 12 deletions
diff --git a/lib/Makefile.am b/lib/Makefile.am
index a8a2f0eca..5632810a0 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 05367be8e..3fd3c525c 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 6a01549c7..9ae095735 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 328e506ce..fa46b5838 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 8acfdb461..3051f2d59 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 ();
}