aboutsummaryrefslogtreecommitdiffhomepage
path: root/tests/test_util.fish
diff options
context:
space:
mode:
authorGravatar Kevin Ballard <kevin@sb.org>2014-09-23 16:29:36 -0700
committerGravatar Kevin Ballard <kevin@sb.org>2014-09-23 22:39:23 -0700
commit5f82f721d2bcdf13b04eefc52358c5c6746e4041 (patch)
tree99ede3a24b3c44a4c9ff057891048c95a6e53b52 /tests/test_util.fish
parent8d03baa4e01e13e5eb0b9c4e826d9e07020400e4 (diff)
Rejigger test suite
Split test_interactive off from test_fishscript and add a new target test_high_level that tests both. Add some Makefile magic so the tests can be run serially without using sub-make, which gets rid of a little noise from the make output. Rewrite interactive tests to look better.
Diffstat (limited to 'tests/test_util.fish')
-rw-r--r--tests/test_util.fish58
1 files changed, 58 insertions, 0 deletions
diff --git a/tests/test_util.fish b/tests/test_util.fish
new file mode 100644
index 00000000..b81e17f6
--- /dev/null
+++ b/tests/test_util.fish
@@ -0,0 +1,58 @@
+# Utilities for the test runners
+
+function die
+ echo $argv[1] >&2
+ exit 1
+end
+
+if not tty 0>&1 >/dev/null
+ function set_color
+ # do nothing
+ return 0
+ end
+end
+
+function say
+ set -l color_flags
+ while set -q argv[1]
+ switch $argv[1]
+ case -b -o -u
+ set color_flags $color_flags $argv[1]
+ case --
+ set -e argv[1]
+ break
+ case -\*
+ case \*
+ break
+ end
+ set -e argv[1]
+ end
+
+ if not set -q argv[1]
+ echo 'usage: say [flags] color [string...]' >&2
+ return 1
+ end
+
+ if set_color $color_flags $argv[1]
+ set -e argv[1]
+ echo $argv
+ set -l stat $status
+ set_color reset
+ or return $stat
+ end
+end
+
+function colordiff -d 'Colored diff output for unified diffs'
+ diff $argv | while read -l line
+ switch $line
+ case '+*'
+ say green $line
+ case '-*'
+ say red $line
+ case '@*'
+ say cyan $line
+ case '*'
+ echo $line
+ end
+ end
+end