Newer
Older
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
from pathlib import Path
import pytest
from git import Repo
from .utils import TEST_MODULE_NAME
CONFIG = """
TOP:=$(CURDIR)
include $(REQUIRE_CONFIG)/CONFIG
include $(REQUIRE_CONFIG)/RULES_SITEMODS
"""
MODULE_MAKEFILE = """
where_am_I := $(dir $(abspath $(lastword $(MAKEFILE_LIST))))
include $(E3_REQUIRE_TOOLS)/driver.makefile
TEMPLATES += {templates}
SOURCES += {sources}
DBDS += {dbds}
HEADERS += {headers}
"""
@pytest.fixture
def wrapper(tmpdir, request):
"""
Sets up a wrapper with the minimal necessary configuration in order to build a module
Note that a number of necessary variables are expected to be present in the environment
"""
wrapper_dir = Path(tmpdir / "wrapper")
test_dir = wrapper_dir / TEST_MODULE_NAME
test_dir.mkdir(parents=True)
# TODO: This should not be necessary, but it is for patching.
Repo.init(wrapper_dir)
with open(wrapper_dir / "Makefile", "w") as f:
f.write(CONFIG)
with open(wrapper_dir / f"{TEST_MODULE_NAME}.Makefile", "w") as f:
f.write(MODULE_MAKEFILE.format(**request.param))
with open(wrapper_dir / TEST_MODULE_NAME / "test.dbd", "w") as f:
f.write("")
yield wrapper_dir