aboutsummaryrefslogtreecommitdiff
path: root/t/test.sh
blob: bc2d06db9f7fd48afbde4602a5528ddac575d387 (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
#!/bin/bash

set -e

source g.sh
cd /

# Setup the test file system.
mkdir -p a/b/c
mkdir -p a/d

g -v                                >> /output.txt 2>&1
g --version                         >> /output.txt 2>&1
g -h                                >> /output.txt 2>&1
g --help                            >> /output.txt 2>&1

# Let's add some shortcuts.
g add root
g add b a/b
g add c a/b/c

# Errors on the `add` command.
set +e
g add add                           >> /output.txt 2>&1
g add lala lala lala                >> /output.txt 2>&1
set -e

# Removing shortcuts.
g rm c
g rm d

# Errors on the `rm` command.
set +e
g rm                                >> /output.txt 2>&1
g rm lala lala                      >> /output.txt 2>&1
set -e

# The list command.
g list --keys | xargs -n1 | sort | xargs   >> /output.txt 2>&1
g list | awk '{ print $1 }' | sort | xargs >> /output.txt 2>&1

# Bare g command.
cd /
g b
basename $(pwd)                     >> /output.txt 2>&1
g root
basename $(pwd)                     >> /output.txt 2>&1
g root/a/b/c
basename $(pwd)                     >> /output.txt 2>&1

# Unknown shortcut.
set +e
g unknown                           >> /output.txt 2>&1
set -e

# Final diff
diff /expected.txt /output.txt