[tracker/sam/functional-tests-quiet: 12/15] 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: 12/15] utils/sandbox: Add --index-tmpdir option
- Date: Sun, 1 Sep 2019 13:14:43 +0000 (UTC)
commit 4f5ee814c1076ac7cd48325d607f1907c67f1804
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 6e7d1da5a..1e07fe968 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
@@ -245,6 +246,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
@@ -295,8 +299,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()
@@ -313,3 +327,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]