-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathapp.bash
More file actions
87 lines (73 loc) · 1.45 KB
/
app.bash
File metadata and controls
87 lines (73 loc) · 1.45 KB
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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
#!/usr/bin/env bash
# source helpers if not loaded
[ $HELPERS_LOADED ] || . "$BATS_TEST_DIRNAME/helpers.bash"
APP="$TMPDIR/usr/local/bin/dex"
SKIP_NETWORK_TEST=${SKIP_NETWORK_TEST:-false}
export DEX_HOME="$TMPDIR/home/.dex"
export DEX_NETWORK=false
export DEX_NAMESPACE="dex/v1-tests"
APP_CMDS=(
conf
image
install
ls
repo
run
)
APP_VARS=(
DEX_BIN_DIR
DEX_BIN_PREFIX
DEX_HOME
DEX_NAMESPACE
DEX_NETWORK
DEX_REGISTRY
DEX_RUNTIME
)
app/var(){
local var="$1"
eval $($APP conf vars -- "$var" 2>/dev/null)
eval "[ -n \"\$$var\" ]"
}
#
# runtime fns
#
make/app(){
(
cd "$REPO_ROOT"
make DESTDIR="$TMPDIR" install
)
[ -x "$APP" ] || die "failed installing application binary"
}
make/sources(){
# stub our sources.list
mkdir -p $DEX_HOME
fixture/cp sources.list $DEX_HOME/sources.list
}
make/repo(){
local path="$1"
[ -d "$path/.git" ] && return
(
set -e
mkdir -p $path
cd $path
git init
echo "content" > file
git add file
git commit -m "initial commit"
)
}
make/test-repo(){
local REPO_DIR="$TMPDIR/test-repo"
make/repo "$REPO_DIR"
[ -d "$REPO_DIR/dex-images" ] || (
exec >/dev/null
cd $REPO_DIR
fixture/cp dex-images .
git add dex-images
git commit -m "adding dex-images"
)
[ -n "$($APP repo ls test-repo)" ] || \
$APP repo add --force test-repo "$REPO_DIR"
}
[ -e "$APP" ] || make/app &>/dev/null
[ -e "$DEX_HOME/sources.list" ] || make/sources &>/dev/null