summaryrefslogtreecommitdiff
path: root/test/script/check-supported-tools-tables
diff options
context:
space:
mode:
authorw0rp <devw0rp@gmail.com>2019-02-11 22:07:42 +0000
committerw0rp <devw0rp@gmail.com>2019-02-11 22:07:52 +0000
commitdf9bee88f6d0e4c72658f5fc6ce8b4091602237f (patch)
tree334169170313dd66c5c9ab6a55b0183222433bc1 /test/script/check-supported-tools-tables
parentaca1edb47613a2f41f4b845455a2236b946da197 (diff)
downloadale-df9bee88f6d0e4c72658f5fc6ce8b4091602237f.zip
Rewrite the supported tools lists in new files
Diffstat (limited to 'test/script/check-supported-tools-tables')
-rwxr-xr-xtest/script/check-supported-tools-tables92
1 files changed, 41 insertions, 51 deletions
diff --git a/test/script/check-supported-tools-tables b/test/script/check-supported-tools-tables
index 220c7427..beb580d7 100755
--- a/test/script/check-supported-tools-tables
+++ b/test/script/check-supported-tools-tables
@@ -6,66 +6,56 @@ set -u
# This script compares the table of supported tools in both the README file
# and the doc/ale.txt file, so we can complain if they don't match up.
-# Find the start and end lines for the help section.
-ale_help_start_line="$( \
- grep -m1 -n '^[0-9][0-9]*\. *Supported Languages' doc/ale.txt \
- | sed 's/\([0-9]*\).*/\1/' \
-)"
-ale_help_section_size="$( \
- tail -n +"$ale_help_start_line" doc/ale.txt \
- | grep -m1 -n '================' \
- | sed 's/\([0-9]*\).*/\1/' \
-)"
-# -- shellcheck complains about expr, but it works better.
-# shellcheck disable=SC2003
-ale_help_end_line="$(expr "$ale_help_start_line" + "$ale_help_section_size")"
-
-# Find the start and end lines for the same section in the README.
-readme_start_line="$( \
- grep -m1 -n '^.*[0-9][0-9]*\. *Supported Languages' README.md \
- | sed 's/\([0-9]*\).*/\1/' \
-)"
-readme_section_size="$( \
- tail -n +"$readme_start_line" README.md \
- | grep -m1 -n '^##.*Usage' \
- | sed 's/\([0-9]*\).*/\1/' \
-)"
-# shellcheck disable=SC2003
-readme_end_line="$(expr "$readme_start_line" + "$readme_section_size")"
-
doc_file="$(mktemp -t doc.XXXXXXXX)"
+doc_sorted_file="$(mktemp -t doc-sorted.XXXXXXXX)"
readme_file="$(mktemp -t readme.XXXXXXXX)"
-sed -n "$ale_help_start_line,$ale_help_end_line"p doc/ale.txt \
- | grep '\* .*: ' \
- | sed 's/^*//' \
- | sed 's/[`!^]//g;s/([^)]*)//g' \
- | sed 's/ *\([,:]\)/\1/g' \
- | sed 's/ */ /g' \
- | sed 's/^ *//;s/ *$//' \
- | sed 's/^/ /' \
- > "$doc_file"
-
-sed -n "$readme_start_line,$readme_end_line"p README.md \
- | grep '| .* |' \
- | sed '/^| Language/d;/^| ---/d' \
- | sed 's/^|//' \
- | sed 's/ \{0,1\}|/:/' \
- | sed 's/[`!^|]//g;s/([^)]*)//g' \
- | sed 's/\[//g;s/\]//g' \
- | sed 's/see[^,]*//g' \
- | sed 's/ *\([,:]\)/\1/g' \
- | sed 's/ */ /g' \
- | sed 's/^ *//;s/ *$//' \
- | sed 's/^/ /' \
- | sed 's/ *-n flag//g' \
- > "$readme_file"
+while read -r; do
+ if [[ "$REPLY" =~ ^! ]]; then
+ language="${REPLY/!/}"
+ else
+ # shellcheck disable=SC2001
+ echo "$language - $REPLY"
+ fi
+done < <(
+ grep '^\*\|^ *\*' doc/ale-supported-languages-and-tools.txt \
+ | sed -e '1,2d' \
+ | sed 's/^\* */!/' \
+ | sed 's/^ *\* *\|!!\|\^\|(.*)\|`//g' \
+ | sed 's/ *$//'
+) > "$doc_file"
+
+while read -r; do
+ if [[ "$REPLY" =~ ^! ]]; then
+ language="${REPLY/!/}"
+ else
+ # shellcheck disable=SC2001
+ echo "$language - $REPLY"
+ fi
+done < <(
+ grep '^\*\|^ *\*' supported-tools.md \
+ | sed 's/^\* */!/' \
+ | sed 's/^ *\* *\|:floppy_disk:\|:warning:\|(.*)\|\[\|\].*\|-n flag//g' \
+ | sed 's/ *$//'
+) > "$readme_file"
exit_code=0
+# Sort the tools ignoring case, and complain when things are out of order.
+sort -f -k1,2 "$doc_file" -o "$doc_sorted_file"
+
+diff -U0 "$doc_sorted_file" "$doc_file" || exit_code=$?
+
+if ((exit_code)); then
+ echo
+ echo "The supported tools list isn't sorted properly"
+ echo
+fi
+
diff -U0 "$readme_file" "$doc_file" || exit_code=$?
rm "$doc_file"
+rm "$doc_sorted_file"
rm "$readme_file"
exit "$exit_code"