Download raw body.
initial gotd-secrets.conf implementation
On Mon, Sep 09, 2024 at 12:37:08PM +0200, Omar Polo wrote:
> > There are some typos and the new test output could be tweaked to
> > match existing tests. But those aren't blocking problems.
>
> do you mean asserting the error messages too?
I mean something like this:
$ pwd
/home/stsp/src/got/regress/secrets
$ make
==== test_empty ====
test_empty ok
==== test_comments ====
test_comments ok
==== test_quotes ====
test_quotes ok
==== test_unclosed ====
test_unclosed ok
==== test_invalid_escape ====
test_invalid_escape ok
==== test_syntax ====
test_syntax ok
diff /home/stsp/src/got
commit - 6e1b28b643862111cb5b8b916fef8249b1b36c97
path + /home/stsp/src/got
blob - a7171f20953ee46932809c2cdb7deac376f5d7ee
file + regress/secrets/Makefile
--- regress/secrets/Makefile
+++ regress/secrets/Makefile
@@ -7,27 +7,52 @@ SRCS = secrets-parser.c error.c hash.c log.c secrets.
CPPFLAGS += -I${.CURDIR}/../../include -I${.CURDIR}/../../lib
CPPFLAGS += -I${.CURDIR}/../../gotd
-REGRESS_TARGETS = empty comments quotes unclosed invalid-escape syntax
+REGRESS_TARGETS = test_empty test_comments test_quotes test_unclosed \
+ test_invalid_escape test_syntax
-empty:
- ./secrets /dev/null | diff -u /dev/null -
+test_empty:
+ @echo -n '$@ '
+ @(./secrets /dev/null | diff -u /dev/null -) && echo ok
-comments:
- ./secrets ${.CURDIR}/01.conf | diff -u ${.CURDIR}/01.exp -
+test_comments:
+ @echo -n '$@ '
+ @(./secrets ${.CURDIR}/01.conf | diff -u ${.CURDIR}/01.exp -) && echo ok
-quotes:
- ./secrets ${.CURDIR}/02.conf | diff -u ${.CURDIR}/02.exp -
+test_quotes:
+ @echo -n '$@ '
+ @(./secrets ${.CURDIR}/02.conf | diff -u ${.CURDIR}/02.exp -) && echo ok
-unclosed:
- ! ./secrets ${.CURDIR}/03.conf
- @echo "expected failure; it's OK"
+test_unclosed:
+ @echo -n '$@ '
+ @./secrets ${.CURDIR}/03.conf 2> ${.CURDIR}/stderr || true
+ @echo 'secrets: ${.CURDIR}/03.conf:1 no closing quote' > ${.CURDIR}/stderr.expected
+ @echo 'secrets: failed to parse ${.CURDIR}/03.conf: configuration file syntax error' >> ${.CURDIR}/stderr.expected
+ @if ! cmp -s ${.CURDIR}/stderr.expected ${.CURDIR}/stderr; then \
+ diff -u ${.CURDIR}/stderr.expected ${.CURDIR}/stderr; \
+ else \
+ echo ok; \
+ fi
-invalid-escape:
- ! ./secrets ${.CURDIR}/04.conf
- @echo "expected failure; it's OK"
+test_invalid_escape:
+ @echo -n '$@ '
+ @./secrets ${.CURDIR}/04.conf 2> ${.CURDIR}/stderr || true
+ @echo 'secrets: ${.CURDIR}/04.conf:1 unterminated escape at end of line' > ${.CURDIR}/stderr.expected
+ @echo 'secrets: failed to parse ${.CURDIR}/04.conf: configuration file syntax error' >> ${.CURDIR}/stderr.expected
+ @if ! cmp -s ${.CURDIR}/stderr.expected ${.CURDIR}/stderr; then \
+ diff -u ${.CURDIR}/stderr.expected ${.CURDIR}/stderr; \
+ else \
+ echo ok; \
+ fi
-syntax:
- ! ./secrets ${.CURDIR}/05.conf
- @echo "expected failure; it's OK"
+test_syntax:
+ @echo -n '$@ '
+ @./secrets ${.CURDIR}/05.conf 2> ${.CURDIR}/stderr || true
+ @echo 'secrets: ${.CURDIR}/05.conf:1 unterminated escape at end of line' > ${.CURDIR}/stderr.expected
+ @echo 'secrets: failed to parse ${.CURDIR}/05.conf: configuration file syntax error' >> ${.CURDIR}/stderr.expected
+ @if ! cmp -s ${.CURDIR}/stderr.expected ${.CURDIR}/stderr; then \
+ diff -u ${.CURDIR}/stderr.expected ${.CURDIR}/stderr; \
+ else \
+ echo ok; \
+ fi
.include <bsd.regress.mk>
initial gotd-secrets.conf implementation