From 22ac094680937014db0f075726fa0fc1f952ebd9 Mon Sep 17 00:00:00 2001 From: Thomas von Dein Date: Fri, 21 Nov 2025 21:58:49 +0100 Subject: [PATCH] enhance tests --- .woodpecker/build.yaml | 23 +++++++++++++++++++---- .woodpecker/test.sh | 19 +++++++++++++++++++ Makefile | 22 ++++++++++++++++++++++ 3 files changed, 60 insertions(+), 4 deletions(-) create mode 100755 .woodpecker/test.sh create mode 100644 Makefile diff --git a/.woodpecker/build.yaml b/.woodpecker/build.yaml index 5e7c56f..fc97e48 100644 --- a/.woodpecker/build.yaml +++ b/.woodpecker/build.yaml @@ -44,9 +44,17 @@ steps: # check modified key - build/dbtool -d test.db -s -k test | grep modified # use splitting with regex - - printf "today:100\nyesterday:500\n" | build/dbtool -d test.db -i -f -t '^([^:]*):([^:]*)' + - printf today:100 | build/dbtool -d test.db -i -f -t '^([^:]*):([^:]*)' # check if it works - - cat /etc/passwd | build/dbtool -d test.db -s -k today | grep 100 + - build/dbtool -d test.db -s -k today | grep 100 + # use splitting with regex reverse + - echo today:cold | build/dbtool -d test.db -R -i -f -t '^([^:]*):([^:]*)' + # check if it works + - build/dbtool -d test.db -s -k cold | grep today + # check encryption + - build/dbtool -d test.db -i -k borg -v sevenofnine -p -P foobar + - build/dbtool -d test.db -s -k borg -p -P foobar | grep sevenofnine + build-gdbm: @@ -90,7 +98,14 @@ steps: # check modified key - build/dbtool -d test.db -s -k test | grep modified # use splitting with regex - - printf "today:100\nyesterday:500\n" | build/dbtool -d test.db -i -f -t '^([^:]*):([^:]*)' + - echo today:100 | build/dbtool -d test.db -i -f -t '^([^:]*):([^:]*)' # check if it works - - cat /etc/passwd | build/dbtool -d test.db -s -k today | grep 100 + - build/dbtool -d test.db -s -k today | grep 100 + # use splitting with regex reverse + - echo today:cold | build/dbtool -d test.db -R -i -f -t '^([^:]*):([^:]*)' + # check if it works + - build/dbtool -d test.db -s -k cold | grep today + # check encryption + - build/dbtool -d test.db -i -k borg -v sevenofnine -p -P foobar + - build/dbtool -d test.db -s -k borg -p -P foobar | grep sevenofnine diff --git a/.woodpecker/test.sh b/.woodpecker/test.sh new file mode 100755 index 0000000..d19eba1 --- /dev/null +++ b/.woodpecker/test.sh @@ -0,0 +1,19 @@ +#!/bin/bash + +yq '.steps.test-gdbm.commands' < .woodpecker/build.yaml \ + | grep -- - | grep -v apk | sed 's/^\- //' \ + | while read COMMAND; do + echo "$COMMAND" | bash -e > debug.log 2>&1 + if test $? -ne 0; then + echo "fail - $COMMAND" + if test -s debug.log; then + cat debug.log + else + echo exit 1 + fi + else + echo "ok - $COMMAND" + fi +done + +rm -f debug.log diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..efa6fd1 --- /dev/null +++ b/Makefile @@ -0,0 +1,22 @@ +# +# convenience wrapper around meson and ninja. Forgive me, I'm old : + +.PHONY: all static install test clean debug +all: + meson setup --reconfigure build + ninja -C build + +install: all + sudo ninja -C install + +clean: + rm -rf build dbtool*core* dbtool.1 test.db + +test: + @.woodpecker/test.sh + +debug: all + rm -f test.db + build/dbtool -d test.db -i -k borg -v sevenofnine -p -P foobar + build/dbtool -d test.db -s -k borg -p -P foobar +