| 1 | for bin in lsrc mkrc rcup rcdn; do |
| 2 | chmod +x "$TESTDIR/../bin"/$bin |
| 3 | done |
| 4 | |
| 5 | export HOME="$PWD" |
| 6 | export PATH="$TESTDIR/../bin:$PATH" |
| 7 | export RCRC="$HOME/.rcrc" |
| 8 | export RCM_LIB="$TESTDIR/../share" |
| 9 | |
| 10 | mkdir .dotfiles |
| 11 | |
| 12 | hostname() { |
| 13 | if [ -n "$HOSTNAME" ]; then |
| 14 | echo "$HOSTNAME" |
| 15 | else |
| 16 | command hostname | sed -e 's/\..*//' |
| 17 | fi |
| 18 | } |
| 19 | |
| 20 | assert() { |
| 21 | local msg="$1"; shift |
| 22 | |
| 23 | test "$@" || echo "Failed assertion: $msg" |
| 24 | |
| 25 | return 0 |
| 26 | } |
| 27 | |
| 28 | refute() { |
| 29 | local msg="$1"; shift |
| 30 | |
| 31 | test "$@" && echo "Failed assertion: $msg" |
| 32 | |
| 33 | return 0 |
| 34 | } |
| 35 | |
| 36 | resolved_path() { |
| 37 | local original_path="$1" |
| 38 | perl -e \ |
| 39 | "use Cwd realpath; print realpath(\"$original_path\") . \"\\n\";" |
| 40 | } |
| 41 | |
| 42 | assert_linked() { |
| 43 | local from="$1" to="$2" |
| 44 | local resolved="$(resolved_path "$from")" |
| 45 | |
| 46 | assert "$from should be a symlink" -h "$from" |
| 47 | assert "$from should resolve to $to, resolved to $resolved" "$resolved" = "$to" |
| 48 | } |