blob: d26749c337fbbd84555b6766747bfebfb311078d (
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
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
|
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
hostname() {
if [ -n "$HOSTNAME" ]; then
echo "$HOSTNAME"
else
command hostname | sed -e 's/\..*//'
fi
}
assert() {
local msg="$1"; shift
test "$@" || echo "Failed assertion: $msg"
return 0
}
refute() {
local msg="$1"; shift
test "$@" && echo "Failed assertion: $msg"
return 0
}
resolved_path() {
local original_path="$1"
local actual_path="$original_path"
local actual_basename="$(basename "$original_path")"
cd "$(dirname "$original_path")"
while [ -L "$actual_basename" ]; do
actual_path="$(readlink "$actual_basename")"
actual_basename="$(basename "$actual_path")"
cd "$(dirname "$actual_path")"
done
local current_directory="$(pwd -P)"
printf "%s/%s\n" "$current_directory" "$actual_basename"
}
assert_linked() {
local from="$1" to="$2"
local resolved="$(resolved_path "$from")"
assert "$from should be a symlink" -h "$from"
assert "$from should resolve to $to, resolved to $resolved" "$resolved" = "$to"
}
|