Gentoo Archives: gentoo-commits

From: "Amadeusz Piotr Żołnowski" <aidecoe@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] repo/gentoo:master commit in: eclass/, eclass/tests/
Date: Sun, 29 May 2016 09:23:51
Message-Id: 1464513801.98ba2191992c67244e50da4e95d38fd426b817ee.aidecoe@gentoo
1 commit: 98ba2191992c67244e50da4e95d38fd426b817ee
2 Author: Amadeusz Żołnowski <aidecoe <AT> aidecoe <DOT> name>
3 AuthorDate: Thu May 26 19:59:11 2016 +0000
4 Commit: Amadeusz Piotr Żołnowski <aidecoe <AT> gentoo <DOT> org>
5 CommitDate: Sun May 29 09:23:21 2016 +0000
6 URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=98ba2191
7
8 rebar.eclass: Optionally provide alternate rebar config to alter
9
10 Some packages have separate configs for build and tests. Build config is
11 always named 'rebar.config' and there seem to be no standard name for
12 tests config.
13
14 eclass/rebar.eclass | 14 +++++++++++---
15 eclass/tests/rebar_fix_include_path.sh | 23 +++++++++++++++++++++++
16 eclass/tests/rebar_remove_deps.sh | 23 +++++++++++++++++++++++
17 3 files changed, 57 insertions(+), 3 deletions(-)
18
19 diff --git a/eclass/rebar.eclass b/eclass/rebar.eclass
20 index 9f3d9e2..c8a2cf4 100644
21 --- a/eclass/rebar.eclass
22 +++ b/eclass/rebar.eclass
23 @@ -93,17 +93,20 @@ erebar() {
24 }
25
26 # @FUNCTION: rebar_fix_include_path
27 -# @USAGE: <project_name>
28 +# @USAGE: <project_name> [<rebar_config>]
29 # @DESCRIPTION:
30 # Fix path in rebar.config to 'include' directory of dependant project/package,
31 # so it points to installation in system Erlang lib rather than relative 'deps'
32 # directory.
33 #
34 +# <rebar_config> is optional. Default is 'rebar.config'.
35 +#
36 # The function dies on failure.
37 rebar_fix_include_path() {
38 debug-print-function ${FUNCNAME} "${@}"
39
40 local pn="$1"
41 + local rebar_config="${2:-rebar.config}"
42 local erl_libs="${EPREFIX}$(get_erl_libs)"
43 local p
44
45 @@ -121,19 +124,24 @@ rebar_fix_include_path() {
46 next;
47 }
48 1
49 -' rebar.config || die "failed to fix include paths in rebar.config for '${pn}'"
50 +' "${rebar_config}" || die "failed to fix include paths in ${rebar_config} for '${pn}'"
51 }
52
53 # @FUNCTION: rebar_remove_deps
54 +# @USAGE: [<rebar_config>]
55 # @DESCRIPTION:
56 # Remove dependencies list from rebar.config and deceive build rules that any
57 # dependencies are already fetched and built. Otherwise rebar tries to fetch
58 # dependencies and compile them.
59 #
60 +# <rebar_config> is optional. Default is 'rebar.config'.
61 +#
62 # The function dies on failure.
63 rebar_remove_deps() {
64 debug-print-function ${FUNCNAME} "${@}"
65
66 + local rebar_config="${1:-rebar.config}"
67 +
68 mkdir -p "${S}/deps" && :>"${S}/deps/.got" && :>"${S}/deps/.built" || die
69 gawk -i inplace '
70 /^{[[:space:]]*deps[[:space:]]*,/, /}[[:space:]]*\.$/ {
71 @@ -143,7 +151,7 @@ rebar_remove_deps() {
72 next;
73 }
74 1
75 -' rebar.config || die "failed to remove deps from rebar.config"
76 +' "${rebar_config}" || die "failed to remove deps from ${rebar_config}"
77 }
78
79 # @FUNCTION: rebar_set_vsn
80
81 diff --git a/eclass/tests/rebar_fix_include_path.sh b/eclass/tests/rebar_fix_include_path.sh
82 index 9047f8d..c8ab178 100755
83 --- a/eclass/tests/rebar_fix_include_path.sh
84 +++ b/eclass/tests/rebar_fix_include_path.sh
85 @@ -77,6 +77,25 @@ test_typical_config() {
86 [[ ${unit_rc}${diff_rc} = 00 ]]
87 }
88
89 +test_typical_config_with_different_name() {
90 + local diff_rc
91 + local unit_rc
92 +
93 + # Prepare
94 + cd "${S}" || die
95 + cp typical.config other.config || die
96 +
97 + # Run unit
98 + (rebar_fix_include_path foo other.config)
99 + unit_rc=$?
100 +
101 + # Test result
102 + diff other.config typical.config.expected
103 + diff_rc=$?
104 +
105 + [[ ${unit_rc}${diff_rc} = 00 ]]
106 +}
107 +
108 test_multiple_versions() {
109 local diff_rc
110 local unit_rc
111 @@ -144,6 +163,10 @@ tbegin "rebar_fix_include_path deals with typical config"
112 test_typical_config
113 tend $?
114
115 +tbegin "rebar_fix_include_path deals with typical config with different name"
116 +test_typical_config_with_different_name
117 +tend $?
118 +
119 tbegin "rebar_fix_include_path fails on multiple versions of dependency"
120 test_multiple_versions
121 tend $?
122
123 diff --git a/eclass/tests/rebar_remove_deps.sh b/eclass/tests/rebar_remove_deps.sh
124 index 05207a7..32351bf 100755
125 --- a/eclass/tests/rebar_remove_deps.sh
126 +++ b/eclass/tests/rebar_remove_deps.sh
127 @@ -67,6 +67,25 @@ test_typical_config() {
128 [[ ${unit_rc}${diff_rc} = 00 ]]
129 }
130
131 +test_typical_config_with_different_name() {
132 + local diff_rc
133 + local unit_rc
134 +
135 + # Prepare
136 + cd "${S}" || die
137 + cp typical.config other.config || die
138 +
139 + # Run unit
140 + (rebar_remove_deps other.config)
141 + unit_rc=$?
142 +
143 + # Test result
144 + diff other.config rebar.config.expected
145 + diff_rc=$?
146 +
147 + [[ ${unit_rc}${diff_rc} = 00 ]]
148 +}
149 +
150 test_deps_in_one_line() {
151 local diff_rc
152 local unit_rc
153 @@ -92,6 +111,10 @@ tbegin "rebar_remove_deps deals with typical config"
154 test_typical_config
155 tend $?
156
157 +tbegin "rebar_remove_deps deals with typical config with different name"
158 +test_typical_config_with_different_name
159 +tend $?
160 +
161 tbegin "rebar_remove_deps deals with all deps in one line"
162 test_deps_in_one_line
163 tend $?