initial commit
[lnf] / test / test
1 #!/bin/bash
2 # some basic sanity / verification
3 # assumes we have trash-put in path
4 # I don't recommend actually running this unless you have a reason to,
5 # since it creates & deletes files, and being a test, it is not as thoroughly
6 # inspected for bugs
7
8 err() {
9 echo error
10 }
11 # target linkname
12 case1() {
13 touch b
14 lnf a b
15 [[ -L b ]] || err
16 }
17
18 # target directory
19 case2() {
20 mkdir b
21 lnf a b
22 [[ -L b/a ]] || err
23 }
24
25 # target
26 case3() {
27 mkdir a
28 touch a/b
29 lnf ../a
30 [[ -L a ]] || err
31 }
32
33 # target target directory
34 case4() {
35 mkdir a
36 touch a/b
37 touch a/c
38 lnf b c d a
39 [[ -L a/b && -L a/c && -L a/d ]] || err
40 }
41
42 cleanup() {
43 rm -rf *
44 }
45
46
47 docases() {
48 case1
49 cleanup
50 case2
51 cleanup
52 case3
53 cleanup
54 case4
55 cleanup
56 }
57
58 source ${0%/*}/../lnf-function
59 # might want to undo this if things go wrong
60 # set -x
61 set -eE;
62 trap 'echo "${BASH_COMMAND:+BASH_COMMAND=\"$BASH_COMMAND\" }
63 ${FUNCNAME:+FUNCNAME=\"$FUNCNAME\" }${LINENO:+LINENO=\"$LINENO\" }\$?=$?"' ERR
64 cd $(mktemp -d)
65 docases
66 trash-put() {
67 rm -rf "$@"
68 }
69 docases
70
71 echo success