-
Notifications
You must be signed in to change notification settings - Fork 33
/
Copy pathshpec.sh
77 lines (62 loc) · 2.12 KB
/
shpec.sh
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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
#!/usr/bin/env shpec
# See Also: https://github.com/rylnd/shpec
_has_pty_session_man() { [ ${#_pty_session_impl} -gt 0 ]; }
_restore_on_exit=
# List of file paths in the form: <backup>|<original>:...
# The backup paths are moved to the original path.
_on_exit() {
IFS=:
for file in ${_restore_on_exit}
do [ ${#file} -gt 0 ] && mv -f "${file%|*}" "${file#*|}"
done
for file in ${_delete_on_exit}
do [ ${#file} -gt 0 ] && rm -rf "${file}"
done
}
_pty_session_init() {
_pty_session_impl=
if abduco -v | grep -q 'abduco.*Marc André Tanner'
then
export ABDUCO_SOCKET_DIR="${_tmpdir}"
export _pty_session_impl=abduco
export _pty_session="abduco -n moe_shpec"
else
echo "Failed to find a pty session manager. Many tests won't be run without one."
fi
}
_tmpdir="$(mktemp -d \"$(printf \"${PWD}\" | cksum | cut -d ' ' -f 1).XXXXXX\")"
# List of file paths to delete in the form: <path>:...
_delete_on_exit="${_tmpdir}"
trap _on_exit 0 # EXIT
_pty_session_init
describe "moe is an editor"
describe "invocation options"
it "can display it's version"
assert equal `moe -v | grep -oPq "^moe v\d+\.\d+\.\d+$";echo $?` 0
end
it "can display command line options"
# TODO: Expand this test to include verifying the option list is formatted and localized correctly.
assert egrep "`moe --help`" " *moe \[file\] +Edit file.*"
end
_has_pty_session_man && {
it "can load a config file from ~/.config/moe/moerc.toml"
configDir=~/.config/moe
config=${configDir}/moerc.toml
if [ ! -d "${configDir}" ]
then
mkdir -p ~/.config/moe
_delete_on_exit="${_delete_on_exit}:${configDir}"
fi
if [ -e "${config}" ]
then
mv "${config}" "${config}.orig"
_restore_on_exit="${_restore_on_exit}:${config}.orig|${config}"
else
_delete_on_exit="${_delete_on_exit}:${config}"
fi
cp -f example/moerc.toml "${configDir}/"
${_pty_session} moe
end
}
end
end