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