Hi,
Am Freitag, dem 31.05.2024 um 10:47 +0100 schrieb Michael Tremer:
Hello,
On 20 May 2024, at 10:05, Jonatan Schlag jonatan.schlag@ipfire.org wrote:
This allows use to write test with less effort as we can reuse functions
Signed-off-by: Jonatan Schlag jonatan.schlag@ipfire.org
tests/lib.sh | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 tests/lib.sh
diff --git a/tests/lib.sh b/tests/lib.sh new file mode 100644 index 000000000..7749d5158 --- /dev/null +++ b/tests/lib.sh @@ -0,0 +1,20 @@ +#!/usr/bin/bash
+LIB_DIR="$(dirname "$(readlink -f "${BASH_SOURCE[0]}")")"
???
I don’t think this is very intuitive.
Ok, what am I supposed to do about it? I need the path where this file is located, and I cannot hard-code it. Should I add a comment?
Jonatan
+. ${LIB_DIR}/lib_color.sh
+test_that() {
- if ! "$@" ; then
- echo -e "${CLR_RED_BG} Test failed: ${*} ${CLR_RESET}"
- return 1
- else
- echo -e "${CLR_GREEN_BG} Test succeded: ${*} ${CLR_RESET}"
- return 0
- fi
+}
We have had so many discussions about how to name functions. “That” is quite generic in my opinion.
Why not “test_command” or something like that?
+var_has_value() {
- [[ "${!1}" == "${2}" ]]
+}
2.39.2