-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy path__init__.py
138 lines (102 loc) · 3.15 KB
/
__init__.py
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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
#
# Pints functional testing module.
#
# This file is part of Pints Functional Testing.
# Copyright (c) 2017-2019, University of Oxford.
# For licensing information, see the LICENSE file distributed with the Pints
# functional testing software package.
#
import logging
import os
import re
import sys
import time
# Require at least Python 3.6 (for importlib.reload and f-strings)
if not sys.version_info >= (3, 6):
raise RuntimeError('Functional testing requires Python 3.6+')
# Set up logging
if 'PFUNK_DEBUG' in os.environ:
logging.basicConfig(level=logging.INFO)
else:
logging.basicConfig()
log = logging.getLogger(__name__)
log.info('Loading Pints Functional Testing.')
# The root of this repository
DIR_PFUNK = os.path.abspath(os.path.join(os.path.dirname(__file__), '..'))
# The pints repository (submodule)
DIR_PINTS_REPO = os.path.join(DIR_PFUNK, 'pints')
# Location of the Pints module
DIR_PINTS_MODULE = os.path.join(DIR_PINTS_REPO, 'pints')
# The website repository (submodule)
DIR_WEB_REPO = os.path.join(DIR_PFUNK, 'website')
# The path to write plots and badges to
DIR_PLOT = os.path.join(DIR_WEB_REPO, 'static', 'functional-testing')
# The path to write the report to
PATH_REPORT = os.path.join(
DIR_WEB_REPO, 'content', 'page', 'functional-testing.md')
# The path to the website sync script
PATH_WEB_SYNC_SCRIPT = os.path.join(DIR_WEB_REPO, 'z-deploy-funk.sh')
# Date formatting
DATE_FORMAT = '%Y-%m-%d-%H:%M:%S'
def date(when=None):
if when:
return time.strftime(DATE_FORMAT, when)
else:
return time.strftime(DATE_FORMAT)
# Test and plot name format (in regex form)
NAME_FORMAT = re.compile(r'^[a-zA-Z]\w*$')
# Default test results database path
# Used to store or retrieve test results, but can be overridden with the
# --database argument.
DEFAULT_RESULTS_DB = "./test_results.db"
# Python version
PYTHON_VERSION = sys.version.replace('\n', '')
# Pints version and pints/pfunk commits
# These are set using (repo).prepare_module
# Pints version string
PINTS_VERSION = None
# Commit hashes
PINTS_COMMIT = None
PFUNK_COMMIT = None
# Date commit was authored (patch or original commit was created)
PINTS_COMMIT_AUTHORED = None
PFUNK_COMMIT_AUTHORED = None
# Date commit was committed (the last time the commit was edited)
PINTS_COMMIT_COMMITTED = None
PFUNK_COMMIT_COMMITTED = None
# Commit message. We keep this because merges can change commit hashes, but the
# authored date and message will survive those. Of course, if you choose to
# interactively rebase and edit or squash the original commit, that's your
# choice.
PINTS_COMMIT_MESSAGE = None
PFUNK_COMMIT_MESSAGE = None
#
# Start importing sub modules
#
from . import ( # noqa
pfunkrepo,
pintsrepo,
website,
)
from ._io import ( # noqa
assert_not_deviated_from,
clean_filename,
find_next_test,
find_previous_test,
gather_statistics_per_commit,
generate_report,
unique_path,
)
from ._resultsdb import ( # noqa
ResultsDatabaseWriter,
find_test_results,
find_test_dates,
)
from ._util import ( # noqa
format_date,
weave,
)
from ._test import ( # noqa
FunctionalTest,
)
from .changepints import ChangePints