summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorEmmanuele Bassi <ebassi@gnome.org>2017-02-27 18:23:21 +0000
committerEmmanuele Bassi <ebassi@gnome.org>2017-03-06 15:46:57 +0000
commit6a98d05520f40411ffa95865cfd3d91926f36d2c (patch)
treef6881e1abd76a65518471dc2209d19513aea19f1 /test
parent24c8971b0b52c10b78b1345dc6a59a82d2698cd3 (diff)
Disable Metrics support when running tests
We currently use a private DBus session using dbusmock to intercept all calls to the EOS Metrics DBus API, and avoid sending bogus metrics when distchecking or running the test suite. The Metrics API now looks for an environment variable and short circuits if found, which means we don't need these contortions any more. This also allows us to drop the dbusmock Python module dependency. https://phabricator.endlessm.com/T15748
Diffstat (limited to 'test')
-rw-r--r--test/Makefile.am.inc11
-rwxr-xr-xtest/gtester-mock-event-recorder.sh35
-rwxr-xr-xtest/tap-test.sh6
-rwxr-xr-xtest/wait-for-service-helper.py26
4 files changed, 10 insertions, 68 deletions
diff --git a/test/Makefile.am.inc b/test/Makefile.am.inc
index ecde40a..0d74647 100644
--- a/test/Makefile.am.inc
+++ b/test/Makefile.am.inc
@@ -83,19 +83,15 @@ AM_JS_LOG_FLAGS = \
@JASMINE_REPORT_ARGUMENT@ \
--no-config \
$(NULL)
-LOG_COMPILER = $(top_srcdir)/test/gtester-mock-event-recorder.sh
-AM_LOG_FLAGS = -k --verbose
+LOG_DRIVER = env AM_TAP_AWK='$(AWK)' $(SHELL) $(top_srcdir)/tap-driver.sh
+LOG_COMPILER = $(top_srcdir)/test/tap-test.sh
EXTRA_DIST += \
+ test/tap-test.sh
test/run-with-dbus \
test/test-bus.conf \
$(NULL)
CLEANFILES += stderr.log
-dist_noinst_SCRIPTS = \
- test/gtester-mock-event-recorder.sh \
- test/wait-for-service-helper.py \
- $(NULL)
-
if ENABLE_WEBHELPER
AM_JS_LOG_FLAGS += --include-path=$(top_srcdir)/webhelper
endif ENABLE_WEBHELPER
@@ -105,6 +101,7 @@ endif ENABLE_WEBHELPER
# Set XDG_CONFIG_HOME so as to avoid cluttering the user's actual config
# directory with junk from the tests
TESTS_ENVIRONMENT = \
+ export EOS_DISABLE_METRICS=1; \
export GI_TYPELIB_PATH="$(top_builddir)$${GI_TYPELIB_PATH:+:$$GI_TYPELIB_PATH}"; \
export LD_LIBRARY_PATH="$(top_builddir)/.libs$${LD_LIBRARY_PATH:+:$$LD_LIBRARY_PATH}"; \
export XDG_CONFIG_HOME=`mktemp -d $${TMPDIR:-/tmp}/sdktestconfig.XXXXXXXX`; \
diff --git a/test/gtester-mock-event-recorder.sh b/test/gtester-mock-event-recorder.sh
deleted file mode 100755
index dedfccc..0000000
--- a/test/gtester-mock-event-recorder.sh
+++ /dev/null
@@ -1,35 +0,0 @@
-#!/bin/bash -e
-
-function finally() {
- kill $DBUS_SESSION_BUS_PID
-}
-
-# This brings up a new session bus and pretends that it is the system bus.
-# dbus-launch initializes DBUS_SESSION_BUS_PID.
-eval `dbus-launch`
-export DBUS_SYSTEM_BUS_ADDRESS=$DBUS_SESSION_BUS_ADDRESS
-export DBUS_SESSION_BUS_PID
-
-# Take down the mock DBus, no matter whether we exit successfully or
-# fail the tests; think of a bash trap as a "finally" clause.
-trap finally EXIT
-
-# Start the mock service and add its methods.
-python3 -m dbusmock --system \
- com.endlessm.Metrics \
- /com/endlessm/Metrics \
- com.endlessm.Metrics.EventRecorderServer &
-
-# Wait for the service to come up
-python3 `dirname $0`/wait-for-service-helper.py
-
-gdbus call --system \
- -d com.endlessm.Metrics \
- -o /com/endlessm/Metrics \
- -m org.freedesktop.DBus.Mock.AddMethods \
- com.endlessm.Metrics.EventRecorderServer \
- '[("RecordSingularEvent", "uayxbv", "", ""),
- ("RecordAggregateEvent", "uayxxbv", "", ""),
- ("RecordEventSequence", "uaya(xbv)", "", "")]'
-
-gtester "$@"
diff --git a/test/tap-test.sh b/test/tap-test.sh
new file mode 100755
index 0000000..3182639
--- /dev/null
+++ b/test/tap-test.sh
@@ -0,0 +1,6 @@
+#!/bin/sh
+
+# Runs a GTest binary with --tap
+# The first argument to this script is the name of the test binary
+
+$1 -k --tap
diff --git a/test/wait-for-service-helper.py b/test/wait-for-service-helper.py
deleted file mode 100755
index 97d0c00..0000000
--- a/test/wait-for-service-helper.py
+++ /dev/null
@@ -1,26 +0,0 @@
-# Copyright 2014, 2015, 2016 Endless Mobile, Inc.
-
-import sys
-from gi.repository import GLib, Gio
-
-DBUS_NAME = 'com.endlessm.Metrics'
-
-
-def on_name_appeared(connection, name, owner):
- print(DBUS_NAME, 'appeared')
- Gio.bus_unwatch_name(watcher_id)
- loop.quit()
-
-
-def on_timeout():
- print('Timed out')
- Gio.bus_unwatch_name(watcher_id)
- sys.exit(1)
-
-print('Watching for name', DBUS_NAME)
-watcher_id = Gio.bus_watch_name(Gio.BusType.SYSTEM, DBUS_NAME,
- Gio.BusNameWatcherFlags.NONE, on_name_appeared, None)
-GLib.timeout_add_seconds(5, on_timeout)
-
-loop = GLib.MainLoop()
-loop.run()