1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
|
#
# Copyright (C) 2010, Nokia <jean-luc.lamadon@nokia.com>
# Copyright (C) 2019, Sam Thursfield <sam@afuera.me.uk>
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
# 02110-1301, USA.
#
import json
import logging
import os
import sys
if 'TRACKER_FUNCTIONAL_TEST_CONFIG' not in os.environ:
raise RuntimeError("The TRACKER_FUNCTIONAL_TEST_CONFIG environment "
"variable must be set to point to the location of "
"the generated configuration.json file.")
with open(os.environ['TRACKER_FUNCTIONAL_TEST_CONFIG']) as f:
config = json.load(f)
TOP_SRCDIR = os.path.dirname(os.path.dirname(
os.path.dirname(os.path.dirname(os.path.dirname(__file__)))))
TOP_BUILDDIR = os.environ['TRACKER_FUNCTIONAL_TEST_BUILD_DIR']
TEST_ONTOLOGIES_DIR = config['TEST_ONTOLOGIES_DIR']
TRACKER_STORE_PATH = config['TRACKER_STORE_PATH']
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)
|