diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 9718cd2b06ba850e4b9a13edf4c07c426166b568..a54104a0bec649991e26645314caf525b55afd5d 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -54,7 +54,6 @@ build require: paths: - epics - configure/*.local - needs: [] test require: stage: test @@ -63,4 +62,4 @@ test require: script: - make test needs: - - build require \ No newline at end of file + - build require diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 375a48d3a05bf4f81ade915c27196f6f27cd71b5..bb60d25257a6cfd559bdbfb6f52c1040d9c49dd5 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,6 +1,6 @@ repos: - repo: https://github.com/ambv/black - rev: 20.8b1 + rev: 21.6b0 hooks: - id: black - repo: https://github.com/pre-commit/pre-commit-hooks @@ -8,12 +8,12 @@ repos: hooks: - id: flake8 - repo: https://github.com/pre-commit/pre-commit-hooks - rev: v2.3.0 + rev: v4.0.1 hooks: - id: end-of-file-fixer - id: trailing-whitespace - repo: https://github.com/timothycrosley/isort - rev: 5.2.1 + rev: 5.9.1 hooks: - id: isort args: ["--profile", "black"] diff --git a/tests/conftest.py b/tests/conftest.py index 48dab5a56367f7d1a8ea2f12004e8f73f8c452f0..dcca4b34b0b1481675d44e9720ebdd63f9bae739 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -5,14 +5,26 @@ from git import Repo from .utils import TEST_MODULE_NAME -CONFIG = """ + +@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) + + CONFIG = """ TOP:=$(CURDIR) include $(REQUIRE_CONFIG)/CONFIG include $(REQUIRE_CONFIG)/RULES_SITEMODS """ -MODULE_MAKEFILE = """ + MODULE_MAKEFILE = """ where_am_I := $(dir $(abspath $(lastword $(MAKEFILE_LIST)))) include $(E3_REQUIRE_TOOLS)/driver.makefile @@ -22,24 +34,15 @@ 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) + + make_vars = {"templates": "", "sources": "", "dbds": "", "headers": ""} + make_vars.update(**request.param) with open(wrapper_dir / f"{TEST_MODULE_NAME}.Makefile", "w") as f: - f.write(MODULE_MAKEFILE.format(**request.param)) + f.write(MODULE_MAKEFILE.format(**make_vars)) with open(wrapper_dir / TEST_MODULE_NAME / "test.dbd", "w") as f: - f.write("") + pass yield wrapper_dir diff --git a/tests/test_build.py b/tests/test_build.py index 717c148b9970c01c17165c5280a4e906b48626c2..cab6b2dfece42af1f79c3caa2551716d970fb8ed 100644 --- a/tests/test_build.py +++ b/tests/test_build.py @@ -35,7 +35,7 @@ def create_patch_file(path, desc): @pytest.mark.parametrize( "wrapper", - [{"templates": "database.db", "sources": "", "dbds": "", "headers": ""}], + [{"templates": "database.db"}], indirect=True, ) def test_patch(wrapper): @@ -76,7 +76,7 @@ def test_patch(wrapper): @pytest.mark.parametrize( "wrapper", - [{"templates": "", "sources": "", "dbds": "nonexistent.dbd", "headers": ""}], + [{"dbds": "nonexistent.dbd"}], indirect=True, ) def test_missing_dbd_file(wrapper): @@ -91,7 +91,7 @@ def test_missing_dbd_file(wrapper): @pytest.mark.parametrize( "wrapper", - [{"templates": "", "sources": "nonexistent.c", "dbds": "", "headers": ""}], + [{"sources": "nonexistent.c"}], indirect=True, ) def test_missing_source_file(wrapper):