Skip to content

Commit

Permalink
more portable usage check
Browse files Browse the repository at this point in the history
  • Loading branch information
zachjs committed Apr 16, 2024
1 parent abc6bd3 commit 30e2a9d
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 8 deletions.
10 changes: 10 additions & 0 deletions test/help/check_usage.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import subprocess

with open("../../README.md", "r") as file:
text_readme = file.read()

text_help = subprocess.check_output(["../../bin/sv2v", "--help"]).decode()
text_usage = "```\n" + "\n".join(text_help.split("\n")[2:-5]) + "\n```"

if text_usage not in text_readme:
raise RuntimeError(f"'{text_usage}' not found in '{text_readme}'")
9 changes: 1 addition & 8 deletions test/help/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,7 @@ test_help() {
assertTrue "getting help should succeed" $result
assertNotNull "stdout should not be empty" "$stdout"
assertNull "stderr should be empty" "$stderr"
lines=`echo "$stdout" | wc -l`
usage=`echo "$stdout" | tail -n +3 | head -n $(expr $lines - 5)`
usage="\`\`\`
$usage
\`\`\`"
if [[ ! $(<../../README.md) = *"$usage"* ]]; then
fail "Did not find matching usage in README!"
fi
python3 check_usage.py
}

source ../lib/functions.sh
Expand Down

0 comments on commit 30e2a9d

Please sign in to comment.