forked from gentoo/gentoo
-
Notifications
You must be signed in to change notification settings - Fork 0
/
rebar_remove_deps.sh
executable file
·122 lines (85 loc) · 2.49 KB
/
rebar_remove_deps.sh
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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
#!/bin/bash
# Copyright 1999-2016 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Id$
source tests-common.sh
EAPI=6
inherit rebar
EPREFIX="${tmpdir}/fakeroot"
S="${WORKDIR}/${P}"
setup() {
mkdir -p "${S}" || die
cat <<EOF >"${S}/rebar.config.expected" || die
%%% Comment
{port_specs, [{"priv/lib/esip_drv.so", ["c_src/esip_codec.c"]}]}.
{deps, []}.
{clean_files, ["c_src/esip_codec.gcda", "c_src/esip_codec.gcno"]}.
EOF
cat <<EOF >"${S}/typical.config" || die
%%% Comment
{port_specs, [{"priv/lib/esip_drv.so", ["c_src/esip_codec.c"]}]}.
{deps, [{stun, ".*", {git, "https://github.com/processone/stun", {tag, "1.0.3"}}},
{fast_tls, ".*", {git, "https://github.com/processone/fast_tls", {tag, "1.0.3"}}},
{p1_utils, ".*", {git, "https://github.com/processone/p1_utils", {tag, "1.0.3"}}}]}.
{clean_files, ["c_src/esip_codec.gcda", "c_src/esip_codec.gcno"]}.
EOF
cat <<EOF >"${S}/deps_one_line.config" || die
%%% Comment
{port_specs, [{"priv/lib/esip_drv.so", ["c_src/esip_codec.c"]}]}.
{deps, [{stun, ".*", {git, "https://github.com/processone/stun", {tag, "1.0.3"}}}, {fast_tls, ".*", {git, "https://github.com/processone/fast_tls", {tag, "1.0.3"}}}, {p1_utils, ".*", {git, "https://github.com/processone/p1_utils", {tag, "1.0.3"}}}]}.
{clean_files, ["c_src/esip_codec.gcda", "c_src/esip_codec.gcno"]}.
EOF
}
test_typical_config() {
local diff_rc
local unit_rc
# Prepare
cd "${S}" || die
cp typical.config rebar.config || die
# Run unit
(rebar_remove_deps)
unit_rc=$?
# Test result
diff rebar.config rebar.config.expected
diff_rc=$?
[[ ${unit_rc}${diff_rc} = 00 ]]
}
test_typical_config_with_different_name() {
local diff_rc
local unit_rc
# Prepare
cd "${S}" || die
cp typical.config other.config || die
# Run unit
(rebar_remove_deps other.config)
unit_rc=$?
# Test result
diff other.config rebar.config.expected
diff_rc=$?
[[ ${unit_rc}${diff_rc} = 00 ]]
}
test_deps_in_one_line() {
local diff_rc
local unit_rc
# Prepare
cd "${S}" || die
cp deps_one_line.config rebar.config || die
# Run unit
(rebar_remove_deps)
unit_rc=$?
# Test result
diff rebar.config rebar.config.expected
diff_rc=$?
[[ ${unit_rc}${diff_rc} = 00 ]]
}
setup
tbegin "rebar_remove_deps deals with typical config"
test_typical_config
tend $?
tbegin "rebar_remove_deps deals with typical config with different name"
test_typical_config_with_different_name
tend $?
tbegin "rebar_remove_deps deals with all deps in one line"
test_deps_in_one_line
tend $?
texit