From 8120fe7d5d3770d20380497a23eff103c342833e Mon Sep 17 00:00:00 2001 From: mmetc <92726601+mmetc@users.noreply.github.com> Date: Thu, 10 Mar 2022 13:59:10 +0100 Subject: [PATCH] fix for /usr/bin/wc on freebsd (#1338) * fix for /usr/bin/wc on freebsd * check for python3 in bats-test --- tests/README.md | 7 ++++++- tests/bats/70_plugins.bats | 2 ++ tests/run-tests | 4 ++++ 3 files changed, 12 insertions(+), 1 deletion(-) diff --git a/tests/README.md b/tests/README.md index 194f542de..1f00523e6 100644 --- a/tests/README.md +++ b/tests/README.md @@ -279,7 +279,12 @@ it with `run jq <(output)` you can only do it once, because the second time it will read the output of the `jq` command. But you can construct a list of all the values you want and check them all in a single step. -See `lib/setup_file.sh` for other tricks we employ. +Note that `<(output)` is substituted with the file name of a file descriptor, +so `mycmd <(output)` can become `mycmd /dev/fd/23`, `mycmd /tmp//sh-np.hpc7Zs` +or `mycmd /proc/self/fd/38` depending on the platform. To have it fed to +standard input, use `< <(output)`. + +See the `lib/*.sh` and `bats/*.bats` files for other tricks we employ. ## file operations diff --git a/tests/bats/70_plugins.bats b/tests/bats/70_plugins.bats index 7adeed10c..6ba989975 100644 --- a/tests/bats/70_plugins.bats +++ b/tests/bats/70_plugins.bats @@ -54,6 +54,8 @@ setup() { @test "$FILE expected 1 log line from http server" { run -0 wc -l <"${MOCK_OUT}" + # wc can pad with spaces on some platforms + run -0 tr -d ' ' < <(output) assert_output 1 } diff --git a/tests/run-tests b/tests/run-tests index d759fa210..0cd094623 100755 --- a/tests/run-tests +++ b/tests/run-tests @@ -15,6 +15,10 @@ TEST_DIR=$(CDPATH= cd -- "$(dirname -- "$0")" && pwd) check_requirements() { + if ! command -v python3 >/dev/null; then + die "missing required program 'python3'" + fi + if ! command -v nc >/dev/null; then die "missing required program 'nc' (package 'netcat-openbsd')" fi