summaryrefslogtreecommitdiff
path: root/test/helper.sh
blob: 539e270150a025c9853b0d4f41cac2f161ace1f5 (plain)
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
for bin in lsrc mkrc rcup rcdn; do
  chmod +x "$TESTDIR/../bin"/$bin
done

export HOME="$PWD"
export PATH="$TESTDIR/../bin:$PATH"
export RCRC="$HOME/.rcrc"
export RCM_LIB="$TESTDIR/../share"

mkdir .dotfiles

assert() {
  local msg="$1"; shift

  test "$@" || echo "Failed assertion: $msg"

  return 0
}

refute() {
  local msg="$1"; shift

  test "$@" && echo "Failed assertion: $msg"

  return 0
}

assert_linked() {
  local from="$1" to="$2"
  local resolved="$(readlink -f "$from")"

  assert "$from should be a symlink" -h "$from"
  assert "$from should resolve to $to, resolved to $resolved" "$resolved" = "$to"
}