summaryrefslogtreecommitdiff
path: root/test/script/check-toc
diff options
context:
space:
mode:
authorGustav Munkby <grddev@gmail.com>2017-10-22 10:42:36 +0200
committerGustav Munkby <grddev@gmail.com>2017-10-22 10:42:36 +0200
commited93cd14942e3b9fe3b56e9a2f54112a302ce4ef (patch)
treeea9ede3848cc32ca1adf2a11471341b55ff2c515 /test/script/check-toc
parent3878be99771d81571789f5595bf082c63ed61755 (diff)
downloadale-ed93cd14942e3b9fe3b56e9a2f54112a302ce4ef.zip
Update test scripts to work on OS X
There were a couple of issues - `paste` requires a file argument - `mktemp` requires a pattern argument - `sort` doesn't support `-h`, but `-n` is enough for sorting on numbers, and `-s` was introduced to perform a stable sort instead. The main issues were that BSD `sed` does not support: - Alternation (`\|`) - solved by splitting to multiple patterns - Bound shortcuts (`x\+`, `x\?`) - solved by replacing with `xx*` and `x\{0,1\}` respectively - Lower-casing (`\L`) - solved by piping through `tr` instead (this will lowercase everything and not only the integration names, but I assumed that wasn't too much of an issue, as a portable alternative for the selective downcasing would be much more involved).
Diffstat (limited to 'test/script/check-toc')
-rwxr-xr-xtest/script/check-toc11
1 files changed, 6 insertions, 5 deletions
diff --git a/test/script/check-toc b/test/script/check-toc
index c4512b08..426d5a1d 100755
--- a/test/script/check-toc
+++ b/test/script/check-toc
@@ -23,18 +23,19 @@ tagged_toc_file="$(mktemp -t ale.txt.XXXXXXXX)"
sorted_toc_file="$(mktemp -t sorted-ale.txt.XXXXXXXX)"
sed -n "$toc_start_line,$toc_end_line"p doc/ale.txt \
- | sed 's/^ \( *[^.]\+\)\.\+|\(.\+\)|/\1, \2/' \
+ | sed 's/^ \( *[^.][^.]*\)\.\.*|\(..*\)|/\1, \2/' \
> "$toc_file"
# Get all of the doc files in a natural sorted order.
-doc_files="$(/bin/ls -1v doc | grep ^ale- | sed 's/^/doc\//' | paste -sd ' ')"
+doc_files="$(/bin/ls -1v doc | grep ^ale- | sed 's/^/doc\//' | paste -sd ' ' -)"
# shellcheck disable=SC2086
grep -h 'ale-.*-options\|^[a-z].*\*ale-.*\*$' $doc_files \
| sed 's/^/ /' \
| sed 's/ALE Shell Integration/ALE sh Integration/' \
- | sed 's/ ALE \(.*\) Integration/\L\1/' \
- | sed 's/ *\*\(.\+\)\*$/, \1/' \
+ | sed 's/ ALE \(.*\) Integration/\1/' \
+ | sed 's/ *\*\(..*\)\*$/, \1/' \
+ | tr '[:upper:]' '[:lower:]' \
| sed 's/objective-c/objc/' \
| sed 's/c++/cpp/' \
> "$heading_file"
@@ -62,7 +63,7 @@ while read -r; do
done < "$toc_file"
# Sort the sections and sub-sections and remove the tags.
-sort -h "$tagged_toc_file" | sed 's/[0-9]\+ //' > "$sorted_toc_file"
+sort -sn "$tagged_toc_file" | sed 's/[0-9][0-9]* //' > "$sorted_toc_file"
echo 'Check for bad ToC sorting:'
echo