[tracker/sam/sandbox-for-tests: 4/4] tracker-sandbox: Allow specifying directories to index on commandline
- From: Sam Thursfield <sthursfield src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [tracker/sam/sandbox-for-tests: 4/4] tracker-sandbox: Allow specifying directories to index on commandline
- Date: Sat, 2 May 2020 23:50:54 +0000 (UTC)
commit 88d32efecc2a96d57ec8642d526bd4929e72c709
Author: Sam Thursfield <sam afuera me uk>
Date: Sun May 3 00:31:04 2020 +0200
tracker-sandbox: Allow specifying directories to index on commandline
In particular, a new --index-recursive-tmpdir flag is designed for use
by app test suites. They can run the set with a temporary directory
already set up for indexing, and when they create content in this
TRACKER_INDEXED_TMPDIR directory it'll automatically be indexed by
the miner-fs and can be used in their tests.
utils/trackertestutils/__main__.py | 25 +++++++++++++++++++++++--
1 file changed, 23 insertions(+), 2 deletions(-)
---
diff --git a/utils/trackertestutils/__main__.py b/utils/trackertestutils/__main__.py
index cbd80462d..974d99c37 100644
--- a/utils/trackertestutils/__main__.py
+++ b/utils/trackertestutils/__main__.py
@@ -189,6 +189,11 @@ def argument_parser():
parser.add_argument('--store-tmpdir', action='store_true',
help="create index in a temporary directory and "
"delete it on exit (useful for automated testing)")
+ parser.add_argument('--index-recursive-directories', nargs='+',
+ help="override the default locations Tracker should index")
+ parser.add_argument('--index-recursive-tmpdir', action='store_true',
+ help="create a temporary directory and configure Tracker "
+ "to only index that location (useful for automated testing)")
parser.add_argument('--wait-for-miner', type=str, action='append',
help="wait for one or more daemons to start, and "
"return to idle for at least 1 second, before "
@@ -345,17 +350,31 @@ def main():
if args.store_location != default_store_location and args.store_tmpdir:
raise RuntimeError("The --store-tmpdir flag is enabled, but --store= was also passed.")
if args.store_tmpdir:
- store_location = store_tmpdir = tempfile.mkdtemp(prefix='tracker-sandbox')
+ store_location = store_tmpdir = tempfile.mkdtemp(prefix='tracker-sandbox-store')
else:
store_location = args.store_location
+ index_recursive_directories = None
+ index_recursive_tmpdir = None
+
+ if args.index_recursive_directories and args.index_recursive_tmpdir:
+ raise RuntimeError("The --index-recursive-tmpdir flag is enabled, but "
+ "--index-recursive-directories= was also passed.")
+ if args.index_recursive_tmpdir:
+ # This tmpdir goes in cwd because paths under /tmp are ignored for indexing
+ index_recursive_tmpdir = tempfile.mkdtemp(prefix='tracker-indexed-tmpdir', dir=os.getcwd())
+ index_recursive_directories = [index_recursive_tmpdir]
+ os.environ['TRACKER_INDEXED_TMPDIR'] = index_recursive_tmpdir
+ else:
+ index_recursive_directories = args.index_recursive_directories
+
interactive = not (args.command)
# Set up environment variables and foo needed to get started.
sandbox = create_sandbox(store_location, args.prefix,
dbus_config=args.dbus_config,
interactive=interactive)
- config_set(sandbox)
+ config_set(sandbox, index_recursive_directories)
link_to_mime_data()
@@ -399,6 +418,8 @@ def main():
sandbox.stop()
if store_tmpdir:
shutil.rmtree(store_tmpdir, ignore_errors=True)
+ if index_recursive_tmpdir:
+ shutil.rmtree(index_recursive_tmpdir, ignore_errors=True)
# Entry point/start
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]