From cc652185049dc6a8f65a322d3977db3a7a8ebba3 Mon Sep 17 00:00:00 2001 From: Dirk Alders Date: Wed, 6 Aug 2025 20:11:18 +0200 Subject: [PATCH] Initial setup of unttest collection --- .gitmodules | 48 +++++++++++++++++++ .vscode/settings.json | 14 ++++++ Makefile | 95 +++++++++++++++++++++++++++++++++++++ __make.d__/unittest.mk | 13 +++++ __scripts__/fstools | 1 + __scripts__/report | 1 + __scripts__/unittest | 1 + __scripts__/unittest_status | 18 +++++++ caching | 1 + fstools | 1 + geo | 1 + helpers | 1 + keyboard | 1 + media | 1 + mqtt | 1 + report | 1 + socket_protocol | 1 + state_machine | 1 + stringtools | 1 + task | 1 + tcp_socket | 1 + 21 files changed, 204 insertions(+) create mode 100644 .gitmodules create mode 100644 .vscode/settings.json create mode 100644 Makefile create mode 100644 __make.d__/unittest.mk create mode 160000 __scripts__/fstools create mode 160000 __scripts__/report create mode 160000 __scripts__/unittest create mode 100755 __scripts__/unittest_status create mode 160000 caching create mode 160000 fstools create mode 160000 geo create mode 160000 helpers create mode 160000 keyboard create mode 160000 media create mode 160000 mqtt create mode 160000 report create mode 160000 socket_protocol create mode 160000 state_machine create mode 160000 stringtools create mode 160000 task create mode 160000 tcp_socket diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 0000000..2879ba7 --- /dev/null +++ b/.gitmodules @@ -0,0 +1,48 @@ +[submodule "caching"] + path = caching + url = https://git.mount-mockery.de/unittest/caching.git +[submodule "fstools"] + path = fstools + url = https://git.mount-mockery.de/unittest/fstools.git +[submodule "geo"] + path = geo + url = https://git.mount-mockery.de/unittest/geo.git +[submodule "helpers"] + path = helpers + url = https://git.mount-mockery.de/unittest/helpers.git +[submodule "keyboard"] + path = keyboard + url = https://git.mount-mockery.de/unittest/keyboard.git +[submodule "media"] + path = media + url = https://git.mount-mockery.de/unittest/media.git +[submodule "mqtt"] + path = mqtt + url = https://git.mount-mockery.de/unittest/mqtt.git +[submodule "report"] + path = report + url = https://git.mount-mockery.de/unittest/report.git +[submodule "socket_protocol"] + path = socket_protocol + url = https://git.mount-mockery.de/unittest/socket_protocol.git +[submodule "state_machine"] + path = state_machine + url = https://git.mount-mockery.de/unittest/state_machine.git +[submodule "stringtools"] + path = stringtools + url = https://git.mount-mockery.de/unittest/stringtools.git +[submodule "task"] + path = task + url = https://git.mount-mockery.de/unittest/task.git +[submodule "tcp_socket"] + path = tcp_socket + url = https://git.mount-mockery.de/unittest/tcp_socket.git +[submodule "__scripts__/unittest"] + path = __scripts__/unittest + url = https://git.mount-mockery.de/pylib/unittest.git +[submodule "__scripts__/fstools"] + path = __scripts__/fstools + url = https://git.mount-mockery.de/pylib/fstools.git +[submodule "__scripts__/report"] + path = __scripts__/report + url = https://git.mount-mockery.de/pylib/report.git diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..d241413 --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,14 @@ +{ + "python.defaultInterpreterPath": "python3", + "autopep8.args": ["--max-line-length=150"], + "[python]": { + "python.formatting.provider": "none", + "editor.defaultFormatter": "ms-python.autopep8", + "editor.formatOnSave": true + }, + "editor.fontSize": 14, + "emmet.includeLanguages": { "django-html": "html" }, + "python.testing.pytestArgs": ["-v", "--cov", "--cov-report=xml", "__test__"], + "python.testing.unittestEnabled": false, + "python.testing.pytestEnabled": true +} diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..7597ae4 --- /dev/null +++ b/Makefile @@ -0,0 +1,95 @@ +# git helper Makefile: Version 1.7 (2025-08-05) +default: help + +.ONESHELL: +SHELL = /usr/bin/bash +.SILENT: + +-include __make.d__/*.mk + +GIT_FLAG = ./.git +VENV_FLAG = ./.venv_required +VENV_FOLDER = ./venv + +localhelp: + +help: + echo "Possible common options are:" + echo " - init - Initialise the repository and all folders below with a Makefile" + echo " - giti - Get the git status of all submodules including their submodules" + echo " - update_submodules - Set all submodules to remote master" + echo " - venv_flag - Set the venev flag for the base folder. A venv will be generated" + echo " - clean - clean up" + echo " - deepclean - clean up this and all Makefiles below" + $(MAKE) localhelp + echo "You are able to create files make.d/*.mk and add local rules there. " + echo " - localinit: print_head - Will be executed as last step in the init process." + echo " - localhelp: print_head - Will be executed in th middle of the help text generation" + echo " - localclean:print_head - Will be executed before the clean rule" + +localinit: + +init: print_head + # Init git repo + if [[ -e $(GIT_FLAG) ]]; then + git submodule init + git submodule update + fi + # Init submodules + for subdir in $$(find . -maxdepth 2 -mindepth 2 -name Makefile | sort); do + $(MAKE) --no-print-directory -C $$(dirname $$subdir) init + done + # Create venv if needed + if [[ -e $(VENV_FLAG) ]]; then + if [[ ! -e $(VENV_FOLDER) ]]; then + mkvenv + fi + fi + # Start local init + $(MAKE) localinit + +update_submodules: + git submodule foreach "git fetch && git checkout master && git pull && git submodule init && git submodule update" + +giti_this: print_head + giti + echo " Submodules:" + git submodule --quiet foreach "echo -n ' ' && giti" + +giti: + git submodule --quiet foreach [ -e Makefile ] || make --no-print-directory giti_this + +localclean: + +clean: localclean + if [[ ! -e $(VENV_FLAG) ]]; then + if [[ -d $(VENV_FOLDER) ]]; then + rm -rf $(VENV_FOLDER) + fi + fi + +cleanall: clean + for subdir in $$(find . -maxdepth 2 -mindepth 2 -name Makefile | sort); do + $(MAKE) --no-print-directory -C $$(dirname $$subdir) cleanall + done + + +venv_flag: + if [[ ! -e $(VENV_FLAG) ]]; then + touch $(VENV_FLAG) + if [[ -e $(GIT_FLAG) ]]; then + git add $(VENV_FLAG) + fi + fi + +print_head: + DIRNAME=$$(basename $$(pwd)) + DIRLENGTH=$${#DIRNAME} + echo -ne "\n\n\033[1;34m╔═" + for i in $$(seq 1 $$DIRLENGTH); do echo -n "═"; done + echo -e "═╗" + echo -e "║ $$DIRNAME ║" + echo -ne "╚═" + for i in $$(seq 1 $$DIRLENGTH); do echo -n "═"; done + echo -e "═╝\033[00m" + diff --git a/__make.d__/unittest.mk b/__make.d__/unittest.mk new file mode 100644 index 0000000..faa993e --- /dev/null +++ b/__make.d__/unittest.mk @@ -0,0 +1,13 @@ +MAKEFLAGS += --no-print-directory + +.ONESHELL: +SHELL = /usr/bin/bash +.SILENT: + +localhelp: + echo "Possible unittest options are:" + echo " - status - Prints a table for the status of each unittest" + +status: + __scripts__/unittest_status + diff --git a/__scripts__/fstools b/__scripts__/fstools new file mode 160000 index 0000000..9237f6f --- /dev/null +++ b/__scripts__/fstools @@ -0,0 +1 @@ +Subproject commit 9237f6f7f77eed79b8163077c1b4d87189193fbe diff --git a/__scripts__/report b/__scripts__/report new file mode 160000 index 0000000..5995368 --- /dev/null +++ b/__scripts__/report @@ -0,0 +1 @@ +Subproject commit 5995368f07f7f680136860af55510dbb61e7503b diff --git a/__scripts__/unittest b/__scripts__/unittest new file mode 160000 index 0000000..631e7c6 --- /dev/null +++ b/__scripts__/unittest @@ -0,0 +1 @@ +Subproject commit 631e7c60bfb822a7a50f63855633aa24436353ce diff --git a/__scripts__/unittest_status b/__scripts__/unittest_status new file mode 100755 index 0000000..f14d193 --- /dev/null +++ b/__scripts__/unittest_status @@ -0,0 +1,18 @@ +#! /usr/bin/env python3 +# + +import os +import sys +MY_PATH = os.path.abspath('.') +sys.path.insert(0, os.path.join(MY_PATH, 'report', 'pylibs')) + +import unittest +import fstools + + +module_pathes = fstools.dirlist(MY_PATH, rekursive=False) +module_pathes.sort() +sys.stdout.write(unittest.module_status.module_status_head()) +for module_path in module_pathes: + if not os.path.basename(module_path) in ['.git', '__make.d__', '__scripts__']: + sys.stdout.write(unittest.module_status.module_status_line(module_path)) diff --git a/caching b/caching new file mode 160000 index 0000000..148a75a --- /dev/null +++ b/caching @@ -0,0 +1 @@ +Subproject commit 148a75af68f69e164b98a737ba135ed9b295af51 diff --git a/fstools b/fstools new file mode 160000 index 0000000..86f6904 --- /dev/null +++ b/fstools @@ -0,0 +1 @@ +Subproject commit 86f69041a5eb76c6d6716b07e40580978be7a509 diff --git a/geo b/geo new file mode 160000 index 0000000..caf8e03 --- /dev/null +++ b/geo @@ -0,0 +1 @@ +Subproject commit caf8e0370e4adce570776801bc160eeb030d5b69 diff --git a/helpers b/helpers new file mode 160000 index 0000000..c47a2d4 --- /dev/null +++ b/helpers @@ -0,0 +1 @@ +Subproject commit c47a2d4d8f90df707f21f6449609c587dac4d9c8 diff --git a/keyboard b/keyboard new file mode 160000 index 0000000..6b12d88 --- /dev/null +++ b/keyboard @@ -0,0 +1 @@ +Subproject commit 6b12d889a9d52bf61404fab6814495e853b8783d diff --git a/media b/media new file mode 160000 index 0000000..d5d9529 --- /dev/null +++ b/media @@ -0,0 +1 @@ +Subproject commit d5d9529a78f3de1da67ea7f1e63997f7d78bc53f diff --git a/mqtt b/mqtt new file mode 160000 index 0000000..05ed33f --- /dev/null +++ b/mqtt @@ -0,0 +1 @@ +Subproject commit 05ed33f75e7c6ecc8dc970931ec4f80329f30811 diff --git a/report b/report new file mode 160000 index 0000000..fe6c1fd --- /dev/null +++ b/report @@ -0,0 +1 @@ +Subproject commit fe6c1fdbed9ee8ab9851fb9bd05d142d6376d166 diff --git a/socket_protocol b/socket_protocol new file mode 160000 index 0000000..d1ef6ba --- /dev/null +++ b/socket_protocol @@ -0,0 +1 @@ +Subproject commit d1ef6bac9a5ee53c460ab0430d1a1d4275ad1b4f diff --git a/state_machine b/state_machine new file mode 160000 index 0000000..0d4a97a --- /dev/null +++ b/state_machine @@ -0,0 +1 @@ +Subproject commit 0d4a97a99555f8b34560fab9f1c4aff347df2d86 diff --git a/stringtools b/stringtools new file mode 160000 index 0000000..6c3d466 --- /dev/null +++ b/stringtools @@ -0,0 +1 @@ +Subproject commit 6c3d466a0608db3f4d2f4bfa2a11bd7afc492e7f diff --git a/task b/task new file mode 160000 index 0000000..f3f04fd --- /dev/null +++ b/task @@ -0,0 +1 @@ +Subproject commit f3f04fd285484fe4f876714cfbf5f927f2792173 diff --git a/tcp_socket b/tcp_socket new file mode 160000 index 0000000..9930a42 --- /dev/null +++ b/tcp_socket @@ -0,0 +1 @@ +Subproject commit 9930a42f45c0f1211a996c282abb80c0d4e37ad5