forked from plaintextaccounting/plaintextaccounting
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest
executable file
·25 lines (24 loc) · 1.01 KB
/
test
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
#!/usr/bin/env bash
# Old, needs updating after move from wiki/
# Run the commands in pages' examples and see if they succeed.
# Usage:
# 1. extract a page's example files to a subdirectory named like the page (without the .md)
# 2. run this script with zero or more page arguments (with or without the .md).
# Eg: ./test # runs all tests found
# Note current limitations:
# - all and only lines in pages beginning with "$ " are considered commands
# - only extracted files are tested, not what's actually in the pages
# - only commands' exit status is tested, not their output
echo "Testing exit status (not output) and extracted files (not page content)"
PAGES="${*:-*.md}"
for PAGE in $PAGES; do
DIR=$(basename "$PAGE" .md)
PAGE=$DIR.md
echo "$PAGE:"
cd "$DIR" 2>/dev/null || continue && \
grep '^\$' ../"$PAGE" | cut -c3- | \
while IFS= read -r c; do
printf " %-50s \t" "$c"
$c >/dev/null 2>&1 && printf "\e[32m[command succeeded]\e[0m\n" || printf "\e[31m[command ERRORED]\e[0m\n"
done
done