-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTest
executable file
·40 lines (32 loc) · 1.21 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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#!/usr/bin/env bash
set -e -o pipefail
trap 'echo FAILED!; exit 1' 0
fail() { echo 1>&2 'FAILURE:' "$@"; exit 1; }
basedir=$(cd "$(dirname "$0")" && pwd -P)
cd "$basedir"
[[ $1 = -C ]] && { shift; git clean -fdX; }
. ./activate -q
PYTHONPATH=bin pytest -qq "$@" t/unit.py t/functional.py
# Simple form when you expect no messages to stdout
eval $(bin/ckssh.py bash-init)
CKSSH_SHELL_INTERFACE_TEST=''
# `ckcommand` will separate out the stuff to eval and eval it,
# leaving stdout and stderr working as normal.
ckcommand shell-interface-test >/dev/null 2>&1
[[ -n $CKSSH_SHELL_INTERFACE_TEST ]] \
|| fail 'CKSSH_SHELL_INTERFACE_TEST not set'
# Functional testing like this is starting to get painful; we need to
# find a better way to test this stuff (ideally with unit tests).
#unset SSH_AUTH_SOCK
_compartment=cjs@cynic.net
exitcode=0
actual=$(
HOME="$basedir/t/mock_home"
XDG_RUNTIME_DIR=/test-xdg-rtdir-nonexistent
SSH_AUTH_SOCK=/test-xdg-rtdir-nonexistent/ckssh/socket/$_compartment
ckset -n) || exitcode=$?
[[ $actual = $_compartment ]] || fail \
"ckset: expected $_compartment, actual '$actual'"
[[ $exitcode -eq 2 ]] || fail "ckset: expected \$?=2, actual \$?=$exitcode"
trap '' 0
echo OK