[tracker-miners/sam/functional-tests-shared: 3/3] functional-tests: Remove obsolete options



commit 029c0abdbb1e2d959ab7756ba9814169616b480a
Author: Sam Thursfield <sam afuera me uk>
Date:   Wed Aug 7 20:54:54 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 | 21 +++++++++-----
 tests/functional-tests/common/utils/helpers.py     | 32 ++++++----------------
 tests/functional-tests/common/utils/options.py     | 28 -------------------
 tests/functional-tests/common/utils/system.py      |  7 +----
 4 files changed, 23 insertions(+), 65 deletions(-)
---
diff --git a/tests/functional-tests/common/utils/configuration.py 
b/tests/functional-tests/common/utils/configuration.py
index 28a006e10..2ee408ead 100644
--- a/tests/functional-tests/common/utils/configuration.py
+++ b/tests/functional-tests/common/utils/configuration.py
@@ -27,8 +27,6 @@ import os
 import tempfile
 import sys
 
-from . import options
-
 
 if 'TRACKER_FUNCTIONAL_TEST_CONFIG' not in os.environ:
     raise RuntimeError("The TRACKER_FUNCTIONAL_TEST_CONFIG environment "
@@ -94,10 +92,6 @@ TRACKER_WRITEBACK_PATH = os.path.normpath(expandvars(config['TRACKER_WRITEBACK_P
 DATADIR = os.path.normpath(expandvars(config['RAW_DATAROOT_DIR']))
 
 
-def generated_ttl_dir():
-    return os.path.join(TOP_BUILD_DIR, 'tests', 'functional-tests', 'ttl')
-
-
 # This path is used for test data for tests which expect filesystem monitoring
 # to work. For this reason we must avoid it being on a tmpfs filesystem. Note
 # that this MUST NOT be a hidden directory, as Tracker is hardcoded to ignore
@@ -140,5 +134,18 @@ def remove_monitored_test_dir(path):
             pass
 
 
-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 21c0a0394..18d6a9fc8 100644
--- a/tests/functional-tests/common/utils/helpers.py
+++ b/tests/functional-tests/common/utils/helpers.py
@@ -30,7 +30,6 @@ import re
 
 from common.utils import configuration as cfg
 from common.utils import mainloop
-from common.utils import options
 
 log = logging.getLogger(__name__)
 
@@ -92,10 +91,6 @@ class Helper:
 
         kws = {}
 
-        if not options.is_verbose():
-            FNULL = open('/dev/null', 'w')
-            kws = {'stdout': FNULL, 'stderr': subprocess.PIPE}
-
         command = [path] + flags
         log.debug("Starting %s", ' '.join(command))
         try:
@@ -127,11 +122,7 @@ 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)
@@ -152,17 +143,14 @@ class Helper:
             self._bus_name_appeared, self._bus_name_vanished)
         self.loop.run_checked()
 
-        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()
-            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()
+        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
 
@@ -205,10 +193,6 @@ class Helper:
     def kill(self):
         global _process_list
 
-        if options.is_manual_start():
-            log.debug("kill(): ignoring, because process was started manually.")
-            return
-
         self.process.kill()
 
         # Name owner changed callback should take us out from this loop
diff --git a/tests/functional-tests/common/utils/system.py b/tests/functional-tests/common/utils/system.py
index b9f36b119..e6c190b2e 100644
--- a/tests/functional-tests/common/utils/system.py
+++ b/tests/functional-tests/common/utils/system.py
@@ -1,16 +1,11 @@
 #!/usr/bin/env python3
 import logging
 import os
-import subprocess
 import shutil
 import tempfile
 
-from gi.repository import GObject
 from gi.repository import GLib
-import time
 
-from common.utils import configuration as cfg
-from common.utils import options
 from common.utils.dconf import DConfClient
 from common.utils import helpers
 
@@ -102,7 +97,7 @@ class TrackerSystemAbstraction (object):
             os.environ["TRACKER_DB_ONTOLOGIES_DIR"] = ontodir
         try:
             self.store.start()
-        except GLib.Error:
+        except GLib.Error as e:
             raise UnableToBootException("Unable to boot the store \n(" + str(e) + ")")
 
     def tracker_store_prepare_journal_replay(self):


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