From 5a663073140e0f643674e6578b96d7aa71743a52 Mon Sep 17 00:00:00 2001 From: MrKevinWeiss Date: Fri, 22 Oct 2021 17:14:57 +0200 Subject: [PATCH] sys/turo: Allow default selection of json --- sys/Makefile.dep | 4 ---- sys/test_utils/Makefile.dep | 6 ++--- sys/test_utils/result_output/Kconfig | 13 +++++------ sys/test_utils/result_output/Makefile.dep | 27 +++++++++++++++++++++++ 4 files changed, 36 insertions(+), 14 deletions(-) create mode 100644 sys/test_utils/result_output/Makefile.dep diff --git a/sys/Makefile.dep b/sys/Makefile.dep index 613062cc50..70077f33f5 100644 --- a/sys/Makefile.dep +++ b/sys/Makefile.dep @@ -742,10 +742,6 @@ ifneq (,$(filter suit_%,$(USEMODULE))) USEMODULE += suit endif -ifneq (,$(filter test_utils_result_output_%,$(USEMODULE))) - USEMODULE += test_utils_result_output -endif - # include ztimer dependencies ifneq (,$(filter ztimer% %ztimer,$(USEMODULE))) include $(RIOTBASE)/sys/ztimer/Makefile.dep diff --git a/sys/test_utils/Makefile.dep b/sys/test_utils/Makefile.dep index f7cff929f4..ac95f8211e 100644 --- a/sys/test_utils/Makefile.dep +++ b/sys/test_utils/Makefile.dep @@ -1,9 +1,9 @@ +ifneq (,$(filter test_utils_result_output,$(USEMODULE))) + include $(RIOTBASE)/sys/test_utils/result_output/Makefile.dep +endif ifneq (,$(filter test_utils_interactive_sync,$(USEMODULE))) USEMODULE += stdin endif -ifneq (,$(filter test_utils_result_output_%,$(USEMODULE))) - USEMODULE += fmt -endif ifneq (,$(filter benchmark_udp,$(USEMODULE))) USEMODULE += netutils USEMODULE += sema_inv diff --git a/sys/test_utils/result_output/Kconfig b/sys/test_utils/result_output/Kconfig index 2cfb0a0c05..24069ade4c 100644 --- a/sys/test_utils/result_output/Kconfig +++ b/sys/test_utils/result_output/Kconfig @@ -5,11 +5,14 @@ # directory for more details. # +menuconfig MODULE_TEST_UTILS_RESULT_OUTPUT + bool "Use result output abstraction" + depends on TEST_KCONFIG + +if MODULE_TEST_UTILS_RESULT_OUTPUT choice bool "Test utils result output" - depends on TEST_KCONFIG - optional default MODULE_TEST_UTILS_RESULT_OUTPUT_JSON help A common API that can format result output depending on the module @@ -18,7 +21,6 @@ choice config MODULE_TEST_UTILS_RESULT_OUTPUT_TXT bool "Text" select MODULE_FMT - select MODULE_TEST_UTILS_RESULT_OUTPUT help Output results in plain text. Intended for developer friendly console output. @@ -26,19 +28,16 @@ config MODULE_TEST_UTILS_RESULT_OUTPUT_TXT config MODULE_TEST_UTILS_RESULT_OUTPUT_JSON bool "JSON" select MODULE_FMT - select MODULE_TEST_UTILS_RESULT_OUTPUT help Output results json formatted results. This allows generic json parsers to be used. Trailing commas may be present. config MODULE_TEST_UTILS_RESULT_OUTPUT_CHECK bool "Check" - select MODULE_TEST_UTILS_RESULT_OUTPUT help Asserts that the structure of the result output are correct. No output is given. endchoice -config MODULE_TEST_UTILS_RESULT_OUTPUT - bool +endif # MODULE_TEST_UTILS_RESULT_OUTPUT diff --git a/sys/test_utils/result_output/Makefile.dep b/sys/test_utils/result_output/Makefile.dep new file mode 100644 index 0000000000..c02452577c --- /dev/null +++ b/sys/test_utils/result_output/Makefile.dep @@ -0,0 +1,27 @@ +TURO_OUTPUT_FORMAT := \ +test_utils_result_output_check \ +test_utils_result_output_json \ +test_utils_result_output_txt + +USED_TURO_OUTPUT_FORMAT := $(filter test_utils_result_output_%,$(USEMODULE)) + +ifeq (0,$(words $(USED_TURO_OUTPUT_FORMAT))) + USEMODULE += test_utils_result_output_json +else ifeq (1,$(words $(USED_TURO_OUTPUT_FORMAT))) + ifeq (,$(filter $(USED_TURO_OUTPUT_FORMAT), $(TURO_OUTPUT_FORMAT))) + $(info Currently using: $(USED_TURO_OUTPUT_FORMAT)) + $(error Please use one of: $(TURO_OUTPUT_FORMAT)) + endif +else + $(info Only one test_utils_result_output format can be used at a time.) + $(info Currently selecting: $(USED_TURO_OUTPUT_FORMAT)) + $(error Please use one of: $(TURO_OUTPUT_FORMAT)) +endif + +TURO_OUTPUT_FORMAT_USES_FMT := \ +test_utils_result_output_json \ +test_utils_result_output_txt + +ifneq (,$(filter $(TURO_OUTPUT_FORMAT_USES_FMT),$(USEMODULE))) + USEMODULE += fmt +endif