Skip to content

Instantly share code, notes, and snippets.

@jmervine
Last active December 27, 2015 12:39
Show Gist options
  • Save jmervine/7327793 to your computer and use it in GitHub Desktop.
Save jmervine/7327793 to your computer and use it in GitHub Desktop.
Addtional shunt (http://github.com/odb/shunt) assertions.
# Extra assertions for shunt (github.com/odb/shunt)
# assert_stderr "cmd" "msg"
function assert_stderr {
local cmd=$1
local msg="[assert_stderr] $3"
err="$( { $cmd; } 2>&1 >/dev/null )"
[ "$err" = "$str" ]
process "$?" "$msg" "" "contains stderr '$err'"
}
# refute_stderr "cmd" "msg"
function refute_stderr {
local cmd=$1
local str=$2
local msg="[refute_stderr] $3"
err="$( { $cmd; } 2>&1 >/dev/null )"
[ "$err" = "" ]
process "$?" "$msg" "" "no stderr"
}
function assert_link {
local file=$1
local msg="[assert_link] $2"
_="$( { test -L $file; } 2>&1 )"
process "$?" "$msg" "" "link '$file' does not exist"
}
function refute_link {
local file=$1
local msg="[refute_link] $2"
_="$( { test -L $file; } 2>&1 )"
[ "$?" -ne "0" ]
process "$?" "$msg" "" "link '$file' exists"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment