[tracker/sam/functional-tests-shared: 2/8] functional-tests: Remove obsolete options



commit 61ae52a0ab76ebaf8a88d5c65647bf107ef5b500
Author: Sam Thursfield <sam afuera me uk>
Date:   Wed Aug 7 17:15:33 2019 +0200

    functional-tests: Remove obsolete options
    
    The old 'verbose' option isn't needed. The tests should be silent by
    default, and noisy when TRACKER_VERBOSITY > 1 or TRACKER_TESTS_VERBOSE
    is set.
    
    The old 'manual start' option is also removed. If you need to attach a
    debugger to one of the Tracker daemons during a test, my advice is to
    modify the code to add a `g_sleep(10000)` call early in startup, start
    the test in question, and then manually attach `gdb`.

 .../functional-tests/common/utils/configuration.py | 17 +++++++--
 tests/functional-tests/common/utils/helpers.py     | 40 +++++++---------------
 tests/functional-tests/common/utils/options.py     | 28 ---------------
 3 files changed, 26 insertions(+), 59 deletions(-)
---
diff --git a/tests/functional-tests/common/utils/configuration.py 
b/tests/functional-tests/common/utils/configuration.py
index aa25ab3fe..58f580a7e 100644
--- a/tests/functional-tests/common/utils/configuration.py
+++ b/tests/functional-tests/common/utils/configuration.py
@@ -24,8 +24,6 @@ import logging
 import os
 import sys
 
-from . import options
-
 
 if 'TRACKER_FUNCTIONAL_TEST_CONFIG' not in os.environ:
     raise RuntimeError("The TRACKER_FUNCTIONAL_TEST_CONFIG environment "
@@ -95,5 +93,18 @@ TRACKER_STORE_PATH = os.path.normpath(expandvars(config['TRACKER_STORE_PATH']))
 disableJournal = (len(config['disableJournal']) == 0)
 
 
-if options.get_environment_boolean('TRACKER_TESTS_VERBOSE'):
+def get_environment_boolean(variable):
+    '''Parse a yes/no boolean passed through the environment.'''
+
+    value = os.environ.get(variable, 'no').lower()
+    if value in ['no', '0', 'false']:
+        return False
+    elif value in ['yes', '1', 'true']:
+        return True
+    else:
+        raise RuntimeError('Unexpected value for %s: %s' %
+                           (variable, value))
+
+
+if get_environment_boolean('TRACKER_TESTS_VERBOSE'):
     logging.basicConfig(stream=sys.stderr, level=logging.DEBUG)
diff --git a/tests/functional-tests/common/utils/helpers.py b/tests/functional-tests/common/utils/helpers.py
index b19d72c08..f8c5742eb 100644
--- a/tests/functional-tests/common/utils/helpers.py
+++ b/tests/functional-tests/common/utils/helpers.py
@@ -29,7 +29,6 @@ import subprocess
 import time
 
 from common.utils import configuration as cfg
-from common.utils import options as options
 
 
 class NoMetadataException (Exception):
@@ -42,7 +41,7 @@ log = logging.getLogger(__name__)
 
 class Helper:
     """
-    Abstract helper for Tracker processes. Launches the process manually
+    Abstract helper for Tracker processes. Launches the process
     and waits for it to appear on the session bus.
 
     The helper will fail if the process is already running. Use
@@ -86,10 +85,6 @@ class Helper:
 
         kws = {}
 
-        if not options.is_verbose():
-            FNULL = open('/dev/null', 'w')
-            kws.update({'stdout': FNULL, 'stderr': subprocess.PIPE})
-
         if env:
             kws['env'] = env
 
@@ -124,12 +119,8 @@ class Helper:
             return True    # continue
         else:
             self.process_watch_timeout = 0
-            if options.is_verbose():
-                error = ""
-            else:
-                error = self.process.stderr.read()
-            raise RuntimeError("%s exited with status: %i\n%s" %
-                               (self.PROCESS_NAME, status, error))
+            raise RuntimeError("%s exited with status: %i" %
+                               (self.PROCESS_NAME, status))
 
     def _timeout_on_idle_cb(self):
         log.debug("[%s] Timeout waiting... asumming idle.", self.PROCESS_NAME)
@@ -150,19 +141,16 @@ class Helper:
             self._bus_name_appeared, self._bus_name_vanished)
         self.loop.run()
 
-        if options.is_manual_start():
-            print("Start %s manually" % self.PROCESS_NAME)
-        else:
-            if self.available:
-                # It's running, but we didn't start it...
-                raise Exception("Unable to start test instance of %s: "
-                                "already running " % self.PROCESS_NAME)
+        if self.available:
+            # It's running, but we didn't start it...
+            raise Exception("Unable to start test instance of %s: "
+                            "already running " % self.PROCESS_NAME)
 
-            self.process = self._start_process(env=env)
-            log.debug('[%s] Started process %i',
-                self.PROCESS_NAME, self.process.pid)
-            self.process_watch_timeout = GLib.timeout_add(
-                200, self._process_watch_cb)
+        self.process = self._start_process(env=env)
+        log.debug('[%s] Started process %i',
+            self.PROCESS_NAME, self.process.pid)
+        self.process_watch_timeout = GLib.timeout_add(
+            200, self._process_watch_cb)
 
         self.abort_if_process_exits_with_status_0 = True
 
@@ -201,10 +189,6 @@ class Helper:
         self.process = None
 
     def kill(self):
-        if options.is_manual_start():
-            log.debug("kill(): ignoring, because process was started manually.")
-            return
-
         if self.process_watch_timeout != 0:
             GLib.source_remove(self.process_watch_timeout)
             self.process_watch_timeout = 0


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]