diff options
author | EuAndreh <eu@euandre.org> | 2020-10-23 08:41:58 -0300 |
---|---|---|
committer | EuAndreh <eu@euandre.org> | 2020-10-23 08:42:35 -0300 |
commit | 137a5e4a1631d69f6844c8dab0b5d629db01c11c (patch) | |
tree | 27804edbb12769e62f729c6305de6fc583f1ecc6 /scripts/assert-todos.sh | |
parent | Remove utils.nix (diff) | |
download | toph-137a5e4a1631d69f6844c8dab0b5d629db01c11c.tar.gz toph-137a5e4a1631d69f6844c8dab0b5d629db01c11c.tar.xz |
Add bash scripts for tests instead of Nix
Diffstat (limited to 'scripts/assert-todos.sh')
-rwxr-xr-x | scripts/assert-todos.sh | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/scripts/assert-todos.sh b/scripts/assert-todos.sh new file mode 100755 index 0000000..c3139d1 --- /dev/null +++ b/scripts/assert-todos.sh @@ -0,0 +1,43 @@ +#!/usr/bin/env bash +set -Eeuo pipefail +cd "$(dirname "${BASH_SOURCE[0]}")" +cd ../ + +# shellcheck disable=2046 +if grep -R FIXME $(git ls-files) | grep -v '^TODOs.org' | grep -v '^.git/' | grep -v '^scripts/assert-todos.sh'; then + echo "Found dangling FIXME markers on the project." + echo "You should write them down properly on TODOs.org." + exit 1 +fi + +contains-element() { + local e match="$1" + shift + for e; do [[ "$e" == "$match" ]] && return 0; done + return 1 +} + +KNOWN_IDS=() +has_error=0 +# shellcheck disable=2013 +for todo in $(sed -e '/^\* Tasks$/,/^\* Improvements$/!d' TODOs.org | grep -nE '^\*\* .*$' | cut -d: -f1); do + if grep -E '^\*\* (CANCELLED|DONE)' <(sed "${todo}q;d" TODOs.org) > /dev/null; then + ID_OFFSET=3 + else + ID_OFFSET=2 + fi + ID="$(sed "$((todo+ID_OFFSET))q;d" TODOs.org)" + if grep '^:CUSTOM_ID: .*$' <(echo "$ID") > /dev/null; then + if contains-element "$ID" "${KNOWN_IDS[@]}"; then + echo "Duplicated ID: $ID" + has_error=1 + else + KNOWN_IDS+=("$ID") + fi + else + echo "Missing ID for TODO in line $todo" + has_error=1 + fi +done + +exit "$has_error" |