crowdsec/test/bats/reformat
mmetc a19748ae35
Rename directory "tests" to "test" (#2094)
If you use a ./test/local directory, you need to create it again:
$ make clean bats-build bats-fixture
2023-03-03 15:54:49 +01:00

17 lines
524 B
Bash
Executable file

#!/usr/bin/env bash
# from https://github.com/bats-core/bats-core/issues/192#issuecomment-528315083
# thanks Sean Leather
# Rewrite the Bats scripts in-place to look more like Bash scripts to shfmt
perl -pi -e 's/^(\@test.*) \{$/$1\n{/' ./*.bats
tmpfile=$(mktemp)
for file in *bats; do
shfmt -i 4 -ln bash -s "${file}" > "${tmpfile}"
mv "${tmpfile}" "${file}"
done
rm -f "${tmpfile}"
# Undo the changes to the Bats scripts in-place so that they work with Bats
perl -pi -e 's/^\{\R//; s/(\@test.*$)/$1 {/' ./*.bats