[folks] tracker: Move with-session-bus-tracker.sh into test-case.vala
- From: Philip Withnall <pwithnall src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [folks] tracker: Move with-session-bus-tracker.sh into test-case.vala
- Date: Sun, 16 Feb 2014 23:55:23 +0000 (UTC)
commit ecfe72ef925a9e561d9a6c94ba7bac12eede550e
Author: Philip Withnall <philip tecnocode co uk>
Date: Tue Nov 19 00:33:29 2013 +0000
tracker: Move with-session-bus-tracker.sh into test-case.vala
Eliminate the last bits of shell scripting from the test suites. Instead
of starting and stopping the Tracker services through tracker-control,
the Tracker services are now started through D-Bus activation, and die
when the mock D-Bus bus is destroyed.
tests/lib/eds/test-case.vala | 2 +-
tests/lib/telepathy/Makefile.am | 8 ++
tests/lib/test-case.vala | 6 +--
tests/lib/tracker/test-case.vala | 66 ++++++++++++-----
tests/tools/Makefile.am | 4 -
tests/tools/dbus-session.sh | 119 -------------------------------
tests/tools/tracker.sh | 34 ---------
tests/tools/with-session-bus-tracker.sh | 48 ------------
tests/tools/with-session-bus.sh | 42 -----------
tests/tracker/Makefile.am | 11 ---
10 files changed, 57 insertions(+), 283 deletions(-)
---
diff --git a/tests/lib/eds/test-case.vala b/tests/lib/eds/test-case.vala
index 4422aad..bc36d44 100644
--- a/tests/lib/eds/test-case.vala
+++ b/tests/lib/eds/test-case.vala
@@ -55,7 +55,7 @@ public class EdsTest.TestCase : Folks.TestCase
true);
}
- public override string? create_transient_dir ()
+ public override string create_transient_dir ()
{
var transient = base.create_transient_dir ();
diff --git a/tests/lib/telepathy/Makefile.am b/tests/lib/telepathy/Makefile.am
index 159073b..be716c0 100644
--- a/tests/lib/telepathy/Makefile.am
+++ b/tests/lib/telepathy/Makefile.am
@@ -21,6 +21,7 @@ libtpf_test_la_VALAFLAGS = \
--vapidir=$(abs_top_builddir)/tests/lib \
--vapidir=$(abs_top_srcdir)/tests/lib/key-file \
--vapidir=$(abs_top_builddir)/tests/lib/key-file \
+ --pkg build-conf \
--pkg folks-test \
--pkg kf-test \
--pkg tp-test-contactlist \
@@ -33,7 +34,14 @@ libtpf_test_la_SOURCES = \
libtpf_test_la_CPPFLAGS = \
$(AM_CPPFLAGS) \
+ -I$(top_srcdir) \
+ -I$(top_srcdir)/folks \
+ -include $(CONFIG_HEADER) \
-include $(top_srcdir)/folks/warnings.h \
+ -DABS_TOP_SRCDIR=\"${abs_top_srcdir}\" \
+ -DABS_TOP_BUILDDIR=\"${abs_top_builddir}\" \
+ -DPKGLIBEXECDIR=\"${pkglibexecdir}\" \
+ -DPACKAGE_DATADIR=\"${pkgdatadir}\" \
$(NULL)
libtpf_test_la_CFLAGS = \
diff --git a/tests/lib/test-case.vala b/tests/lib/test-case.vala
index 2b51245..febc251 100644
--- a/tests/lib/test-case.vala
+++ b/tests/lib/test-case.vala
@@ -123,12 +123,8 @@ public abstract class Folks.TestCase : Object
*
* Subclasses may override this method to do additional setup
* (create more subdirectories or set more environment variables).
- *
- * FIXME: Subclasses relying on being called by with-session-bus-*.sh
- * may override this method to return null, although we should really
- * stop doing that.
*/
- public virtual string? create_transient_dir ()
+ public virtual string create_transient_dir ()
{
unowned string tmp = Environment.get_tmp_dir ();
string transient = "%s/folks-test.XXXXXX".printf (tmp);
diff --git a/tests/lib/tracker/test-case.vala b/tests/lib/tracker/test-case.vala
index 3a1acd3..fd0df80 100644
--- a/tests/lib/tracker/test-case.vala
+++ b/tests/lib/tracker/test-case.vala
@@ -26,8 +26,8 @@
* Folks is configured to use the Tracker backend as primary store,
* and no other backends.
*
- * FIXME: For now, this relies on running under with-session-bus-tracker.sh
- * with FOLKS_BACKEND_PATH set.
+ * This uses tracker-control to start and stop Tracker services on a private
+ * D-Bus bus.
*/
public class TrackerTest.TestCase : Folks.TestCase
{
@@ -47,14 +47,6 @@ public class TrackerTest.TestCase : Folks.TestCase
*/
public TestCase (string name)
{
- /* This variable is set in the same place as the various variables we
- * care about for sandboxing purposes, like XDG_CONFIG_HOME and
- * DBUS_SESSION_BUS_ADDRESS. */
- if (Environment.get_variable ("FOLKS_TESTS_SANDBOXED_DBUS")
- != "tracker")
- error ("Tracker tests must be run in a private D-Bus session " +
- "with Tracker services");
-
base (name);
Environment.set_variable ("FOLKS_BACKENDS_ALLOWED", "tracker", true);
@@ -63,17 +55,53 @@ public class TrackerTest.TestCase : Folks.TestCase
this.tracker_backend = new TrackerTest.Backend ();
}
- public override string? create_transient_dir ()
- {
- /* Don't do anything. We're currently relying on
- * being wrapped in with-session-bus-tracker.sh. */
- return null;
- }
-
public override void private_bus_up ()
{
- /* Don't do anything. We're currently relying on
- * being wrapped in with-session-bus-tracker.sh. */
+ base.private_bus_up ();
+
+ /* Find out the libexec directory to use. */
+ int exit_status = -1;
+ string capture_stdout = null;
+
+ try
+ {
+ Process.spawn_sync (null /* cwd */,
+ { "pkg-config", "--variable=prefix", "tracker-miner-1.0" },
+ null /* envp */,
+ SpawnFlags.SEARCH_PATH /* flags */,
+ null /* child setup */,
+ out capture_stdout,
+ null /* do not capture stderr */,
+ out exit_status);
+
+ Process.check_exit_status (exit_status);
+ }
+ catch (GLib.Error e1)
+ {
+ error ("Error getting libexecdir from pkg-config: %s", e1.message);
+ }
+
+ /* FIXME: There really should be a libexec variable in the pkg-config
+ * file. */
+ var libexec = capture_stdout.strip () + "/libexec";
+
+ /* Create service files for the Tracker binaries. */
+ var service_file_name =
+ Path.build_filename (this.transient_dir, "dbus-1", "services",
+ "org.freedesktop.Tracker1.service");
+ var service_file = ("[D-BUS Service]\n" +
+ "Name=org.freedesktop.Tracker1\n" +
+ "Exec=%s/tracker-store\n").printf (libexec);
+
+ try
+ {
+ FileUtils.set_contents (service_file_name, service_file);
+ }
+ catch (FileError e2)
+ {
+ error ("Error creating D-Bus service file ā%sā: %s",
+ service_file_name, e2.message);
+ }
}
public override void tear_down ()
diff --git a/tests/tools/Makefile.am b/tests/tools/Makefile.am
index 11ab159..542e5a2 100644
--- a/tests/tools/Makefile.am
+++ b/tests/tools/Makefile.am
@@ -1,9 +1,5 @@
EXTRA_DIST = \
- with-session-bus.sh \
- dbus-session.sh \
manager-file.py \
- with-session-bus-tracker.sh \
- tracker.sh \
$(NULL)
-include $(top_srcdir)/git.mk
diff --git a/tests/tracker/Makefile.am b/tests/tracker/Makefile.am
index 0882260..c8d481f 100644
--- a/tests/tracker/Makefile.am
+++ b/tests/tracker/Makefile.am
@@ -36,8 +36,6 @@ LDADD = \
-L$(top_srcdir)/backends/tracker/lib \
$(NULL)
-RUN_WITH_PRIVATE_BUS = $(top_srcdir)/tests/tools/with-session-bus-tracker.sh
-
# in order from least to most complex
noinst_PROGRAMS = \
individual-retrieval \
@@ -100,10 +98,6 @@ noinst_PROGRAMS = \
set-null-avatar \
$(NULL)
-TESTS_ENVIRONMENT = \
- $(RUN_WITH_PRIVATE_BUS) \
- --session \
- --
TESTS = $(noinst_PROGRAMS)
individual_retrieval_SOURCES = \
@@ -338,11 +332,6 @@ set_null_avatar_SOURCES = \
set-null-avatar.vala \
$(NULL)
-CLEANFILES = \
- *.pid \
- *.address \
- $(NULL)
-
-include $(top_srcdir)/git.mk
-include $(top_srcdir)/check.mk
-include $(top_srcdir)/valgrind.mk
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]