diff --git a/Makefile b/Makefile index c244718b..c8c00135 100644 --- a/Makefile +++ b/Makefile @@ -128,6 +128,7 @@ package: substitute-debian test: substitute-sources pytest test/unit -vv + pytest test/misc -vv make clean-cache autotest: @@ -184,17 +185,22 @@ general-help: @echo @echo "Commands:" @echo " install Install on the local computer without using package manager;" - @echo " uninstall Remove installed util from system;" - @echo " man Create man file." - @echo " Require argparse-manpage python library;" + @echo " uninstall Removes the installed utility from the system;" + @echo " reinstall Removes the installed utility from the system and then installs it again;" + @echo " man Create man file. Require argparse-manpage python library;" @echo " pre-commit Runs all pre-commit hooks;" @echo " test Runs unit tests with pytest framework;" @echo " autotest Runs auto tests." @echo " Required installed '$(UTIL_NAME)' util and provided ACCESS_TOKEN;" + @echo " substitute-sources Substitutes dynamic variables into source code files and generates final files;" + @echo " substitute-debian Substitutes dynamic variables into debian files and generates final files;" + @echo " substitute-docker Substitutes dynamic variables into docker files and generates final files;" @echo " package Build the debian package;" @echo " clean-cache Delete __pycache__ folders created by pytest framework;" @echo " clean Remove generated while installing and testing files in the source directory (contains clean-cache);" @echo " clean-all Remove all generated files such as created docker files, debian and sources (contains clean);" + @echo " todo-list Displays what is good to do in the source code;" + @echo " general-help Displays information about upper-level targets;" @echo " help Displays information about all available targets." @echo diff --git a/docker/docker.mk b/docker/docker.mk index c5317523..90f4b187 100644 --- a/docker/docker.mk +++ b/docker/docker.mk @@ -1,11 +1,13 @@ docker-help: @echo "Docker:" @echo " docker-run Runs docker container with installed util;" - @echo " docker-image Build docker image;" + @echo " docker-image Builds a docker image;" @echo " ALL=[1|0] REBUILD=[1|0]" + @echo " docker-base-image Builds a basic docker image from which to build other images;" + @echo " docker-test-image Builds a docker image for running tests and building package;" @echo " docker-test Runs unit tests with pytest framework in the docker container;" @echo " docker-autotest Runs autotests in docker container;" - @echo " docker-build-package Build the debian package in special docker image;" + @echo " docker-build-package Builds the debian package in special docker image;" @echo " docker-rmi ALL=[1|0] Delete created docker images;" @echo " docker-help Displays information about available docker targets." @echo diff --git a/setup.py b/setup.py index 5ee1f993..474d5e55 100644 --- a/setup.py +++ b/setup.py @@ -7,6 +7,7 @@ "Babel==2.15.0", "Cython~=3.0.8", "setuptools~=75.8.0", + "Jinja2~=3.1.2", ) INSTALL_REQUIREMENTS: tuple[str, ...] = ( "argcomplete~=2.0.0", diff --git a/test/conftest.py b/test/conftest.py deleted file mode 100644 index df9947c8..00000000 --- a/test/conftest.py +++ /dev/null @@ -1,11 +0,0 @@ -import logging - -import pytest -from pytest_mock import MockerFixture - -from codeplag.consts import UTIL_NAME - - -@pytest.fixture -def dummy_logger(mocker: MockerFixture): - return mocker.MagicMock(autospec=logging.Logger(UTIL_NAME)) diff --git a/test/misc/test_makefile.py b/test/misc/test_makefile.py new file mode 100644 index 00000000..4225bba7 --- /dev/null +++ b/test/misc/test_makefile.py @@ -0,0 +1,44 @@ +import re +import subprocess +from typing import Final + +import pytest + +TARGET_PATTERN = re.compile(r"^[a-zA-Z0-9-]*:\s*") +MAKEFILE_NAME: Final = "Makefile" + + +@pytest.fixture +def makefile_targets() -> set[str]: + result = subprocess.run( + ["make", "-qp"], + encoding="utf-8", + stdout=subprocess.PIPE, + stderr=subprocess.PIPE, + ) + targets = set() + for line in result.stdout.splitlines(): + if not TARGET_PATTERN.search(line): + continue + target_name = line.split(":")[0] + if target_name == MAKEFILE_NAME: + continue + targets.add(target_name) + assert targets, "No targets found, maybe error occurred." + return targets + + +def test_makefile_consist_help_msgs_for_all_targets(makefile_targets: set[str]): + make_help_stdout = subprocess.run( + ["make", "help"], + encoding="utf-8", + stdout=subprocess.PIPE, + stderr=subprocess.PIPE, + check=True, + ).stdout + targets_without_help = { + target for target in makefile_targets if target not in make_help_stdout + } + assert ( + not targets_without_help + ), f"Help message for the '{targets_without_help}' targets not found."