From 75f11f3f4fe97c685f2ac6e5f573b4edde9bfbd9 Mon Sep 17 00:00:00 2001 From: yubiuser Date: Mon, 26 Aug 2024 20:30:49 +0200 Subject: [PATCH] Prettify BATS output Signed-off-by: yubiuser --- .github/Dockerfile | 9 +++++++++ test/run.sh | 2 +- test/test_suite.bats | 4 ++++ 3 files changed, 14 insertions(+), 1 deletion(-) diff --git a/.github/Dockerfile b/.github/Dockerfile index e8b05edb..0cf7f2df 100644 --- a/.github/Dockerfile +++ b/.github/Dockerfile @@ -13,6 +13,15 @@ ENV GIT_TAG=${GIT_TAG} ARG BUILD_OPTS="" ENV BUILD_OPTS=${BUILD_OPTS} +# Add ncurses used for pretty output in bats tests +RUN apk add --no-cache ncurses +ENV TERM=xterm + +# Monkeypatch BATS to remove duplicate output of starting and finished test +# BATS uses ANSI escape codes to overwrite the line after the test has finished +# This is not supported by Github Actions as it does not provide a TTY to the docker build container +RUN sed -i '/buffer_with_truncation /d' /bats-core/libexec/bats-core/bats-format-pretty + # Build FTL # Remove possible old build files RUN rm -rf cmake && \ diff --git a/test/run.sh b/test/run.sh index 5d490a82..626a5dc7 100755 --- a/test/run.sh +++ b/test/run.sh @@ -106,7 +106,7 @@ echo -n "Contained dnsmasq version (DNS): " dig TXT CHAOS version.bind @127.0.0.1 +short # Run tests -$BATS "test/test_suite.bats" +$BATS -p "test/test_suite.bats" RET=$? curl_to_tricorder() { diff --git a/test/test_suite.bats b/test/test_suite.bats index 2860776f..b610d1e1 100644 --- a/test/test_suite.bats +++ b/test/test_suite.bats @@ -1,5 +1,9 @@ #!./test/libs/bats/bin/bats +@test 'fail()' { + fail 'this test always fails' +} + @test "Compare template and test TOML config files" { # We skip the first 5 lines of the files as they contain the version and # timestamp of the file creation/modification