Commit | Line | Data |
---|---|---|
bcc7759d JR |
1 | import os |
2 | import logging | |
3 | import yaml | |
4 | ||
5 | import lttng_b_test.utils.project as Project | |
6 | ||
7 | ||
8 | _logger = logging.getLogger('project.factory') | |
9 | _conf_file = os.path.dirname(os.path.abspath(__file__)) + "/../run_configuration.yaml" | |
10 | _project_constructor = { | |
11 | 'babeltrace': Project.Babeltrace, | |
12 | 'lttng-modules': Project.Lttng_modules, | |
13 | 'lttng-tools': Project.Lttng_tools, | |
14 | 'lttng-ust': Project.Lttng_ust, | |
15 | } | |
16 | ||
17 | _markers = None | |
18 | with open(_conf_file, 'r') as stream: | |
19 | # This is voluntary static across call, no need to perform this | |
20 | # every time. | |
21 | _markers = yaml.load(stream) | |
22 | ||
23 | ||
24 | def get(label, tmpdir): | |
25 | if label not in _markers: | |
26 | # TODO: specialized exception, handle it caller-side so the caller | |
27 | # can decide to skip or fail test. | |
28 | raise Exception('Label is no present') | |
29 | marker = _markers[label] | |
30 | constructor = _project_constructor[marker['project']] | |
31 | path = marker['path'] | |
32 | sha1 = marker['sha1'] | |
33 | return constructor(label, path, sha1, tmpdir) |