}
# @FUNCTION: rebar_fix_include_path
-# @USAGE: <project_name>
+# @USAGE: <project_name> [<rebar_config>]
# @DESCRIPTION:
# Fix path in rebar.config to 'include' directory of dependant project/package,
# so it points to installation in system Erlang lib rather than relative 'deps'
# directory.
#
+# <rebar_config> is optional. Default is 'rebar.config'.
+#
# The function dies on failure.
rebar_fix_include_path() {
debug-print-function ${FUNCNAME} "${@}"
local pn="$1"
+ local rebar_config="${2:-rebar.config}"
local erl_libs="${EPREFIX}$(get_erl_libs)"
local p
next;
}
1
-' rebar.config || die "failed to fix include paths in rebar.config for '${pn}'"
+' "${rebar_config}" || die "failed to fix include paths in ${rebar_config} for '${pn}'"
}
# @FUNCTION: rebar_remove_deps
+# @USAGE: [<rebar_config>]
# @DESCRIPTION:
# Remove dependencies list from rebar.config and deceive build rules that any
# dependencies are already fetched and built. Otherwise rebar tries to fetch
# dependencies and compile them.
#
+# <rebar_config> is optional. Default is 'rebar.config'.
+#
# The function dies on failure.
rebar_remove_deps() {
debug-print-function ${FUNCNAME} "${@}"
+ local rebar_config="${1:-rebar.config}"
+
mkdir -p "${S}/deps" && :>"${S}/deps/.got" && :>"${S}/deps/.built" || die
gawk -i inplace '
/^{[[:space:]]*deps[[:space:]]*,/, /}[[:space:]]*\.$/ {
next;
}
1
-' rebar.config || die "failed to remove deps from rebar.config"
+' "${rebar_config}" || die "failed to remove deps from ${rebar_config}"
}
# @FUNCTION: rebar_set_vsn
[[ ${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_fix_include_path foo other.config)
+ unit_rc=$?
+
+ # Test result
+ diff other.config typical.config.expected
+ diff_rc=$?
+
+ [[ ${unit_rc}${diff_rc} = 00 ]]
+}
+
test_multiple_versions() {
local diff_rc
local unit_rc
test_typical_config
tend $?
+tbegin "rebar_fix_include_path deals with typical config with different name"
+test_typical_config_with_different_name
+tend $?
+
tbegin "rebar_fix_include_path fails on multiple versions of dependency"
test_multiple_versions
tend $?
[[ ${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
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 $?