[tracker/sam/functional-tests-quiet: 16/22] utils/sandbox: Add --index-tmpdir option
- From: Sam Thursfield <sthursfield src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [tracker/sam/functional-tests-quiet: 16/22] utils/sandbox: Add --index-tmpdir option
- Date: Tue, 10 Sep 2019 08:40:49 +0000 (UTC)
commit d8a05f9d750d54f21ebba2bf634309d054835393
Author: Sam Thursfield <sam afuera me uk>
Date: Sat Aug 31 04:28:17 2019 +0300
utils/sandbox: Add --index-tmpdir option
This makes the tracker-sandbox utility more useful as a test harness.
utils/sandbox/tracker-sandbox.py | 20 ++++++++++++++++++--
1 file changed, 18 insertions(+), 2 deletions(-)
---
diff --git a/utils/sandbox/tracker-sandbox.py b/utils/sandbox/tracker-sandbox.py
index 687e2c48c..db24679f3 100755
--- a/utils/sandbox/tracker-sandbox.py
+++ b/utils/sandbox/tracker-sandbox.py
@@ -29,10 +29,11 @@ import locale
import logging
import os
import shlex
+import shutil
import signal
import subprocess
import sys
-import threading
+import tempfile
from gi.repository import GLib
@@ -248,6 +249,9 @@ def argument_parser():
parser.add_argument('-i', '--index', metavar='DIR', type=str,
default=default_index_location, dest='index_location',
help=f"directory to the index (default={default_index_location})")
+ parser.add_argument('--index-tmpdir', action='store_true',
+ help="create index in a temporary directory and "
+ "delete it on exit (useful for automated testing)")
parser.add_argument('command', type=str, nargs='*', help="Command to run inside the shell")
return parser
@@ -298,8 +302,18 @@ if __name__ == "__main__":
verbosity = verbosity_as_int(args.verbosity)
+ index_location = None
+ index_tmpdir = None
+
+ if args.index_location != default_index_location and args.index_tmpdir:
+ raise RuntimeError("The --index-tmpdir flag is enabled, but --index= was also passed.")
+ if args.index_tmpdir:
+ index_location = index_tmpdir = tempfile.mkdtemp(prefix='tracker-sandbox')
+ else:
+ index_location = args.index_location
+
# Set up environment variables and foo needed to get started.
- dbus = environment_set(args.index_location, args.prefix, verbosity, dbus_config=args.dbus_config)
+ dbus = environment_set(index_location, args.prefix, verbosity, dbus_config=args.dbus_config)
config_set()
link_to_mime_data()
@@ -316,3 +330,5 @@ if __name__ == "__main__":
os.system(shell)
finally:
environment_unset(dbus)
+ if index_tmpdir:
+ shutil.rmtree(index_tmpdir, ignore_errors=True)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]