* [gentoo-dev] [PATCH 1/2] rebar.eclass: Run unit tests
@ 2016-05-28 16:12 aidecoe
2016-05-28 16:12 ` [gentoo-dev] [PATCH 2/2] rebar.eclass: Optionally provide alternate rebar config to alter aidecoe
0 siblings, 1 reply; 2+ messages in thread
From: aidecoe @ 2016-05-28 16:12 UTC (permalink / raw
To: gentoo-dev; +Cc: Amadeusz Żołnowski
From: Amadeusz Żołnowski <aidecoe@aidecoe.name>
---
eclass/rebar.eclass | 11 ++++++++++-
1 file changed, 10 insertions(+), 1 deletion(-)
diff --git a/eclass/rebar.eclass b/eclass/rebar.eclass
index ca86e88..9f3d9e2 100644
--- a/eclass/rebar.eclass
+++ b/eclass/rebar.eclass
@@ -30,7 +30,7 @@ case "${EAPI:-0}" in
;;
esac
-EXPORT_FUNCTIONS src_prepare src_compile src_install
+EXPORT_FUNCTIONS src_prepare src_compile src_test src_install
RDEPEND="dev-lang/erlang"
DEPEND="${RDEPEND}
@@ -198,6 +198,15 @@ rebar_src_compile() {
erebar compile
}
+# @FUNCTION: rebar_src_test
+# @DESCRIPTION:
+# Run unit tests.
+rebar_src_test() {
+ debug-print-function ${FUNCNAME} "${@}"
+
+ erebar eunit
+}
+
# @FUNCTION: rebar_src_install
# @DESCRIPTION:
# Install BEAM files, include headers, executables and native libraries.
--
2.8.3
^ permalink raw reply related [flat|nested] 2+ messages in thread
* [gentoo-dev] [PATCH 2/2] rebar.eclass: Optionally provide alternate rebar config to alter
2016-05-28 16:12 [gentoo-dev] [PATCH 1/2] rebar.eclass: Run unit tests aidecoe
@ 2016-05-28 16:12 ` aidecoe
0 siblings, 0 replies; 2+ messages in thread
From: aidecoe @ 2016-05-28 16:12 UTC (permalink / raw
To: gentoo-dev; +Cc: Amadeusz Żołnowski
From: Amadeusz Żołnowski <aidecoe@aidecoe.name>
Some packages have separate configs for build and tests. Build config is
always named 'rebar.config' and there seem to be no standard name for
tests config.
---
eclass/rebar.eclass | 14 +++++++++++---
eclass/tests/rebar_fix_include_path.sh | 23 +++++++++++++++++++++++
eclass/tests/rebar_remove_deps.sh | 23 +++++++++++++++++++++++
3 files changed, 57 insertions(+), 3 deletions(-)
diff --git a/eclass/rebar.eclass b/eclass/rebar.eclass
index 9f3d9e2..c8a2cf4 100644
--- a/eclass/rebar.eclass
+++ b/eclass/rebar.eclass
@@ -93,17 +93,20 @@ erebar() {
}
# @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
@@ -121,19 +124,24 @@ rebar_fix_include_path() {
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:]]*\.$/ {
@@ -143,7 +151,7 @@ rebar_remove_deps() {
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
diff --git a/eclass/tests/rebar_fix_include_path.sh b/eclass/tests/rebar_fix_include_path.sh
index 9047f8d..c8ab178 100755
--- a/eclass/tests/rebar_fix_include_path.sh
+++ b/eclass/tests/rebar_fix_include_path.sh
@@ -77,6 +77,25 @@ test_typical_config() {
[[ ${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
@@ -144,6 +163,10 @@ tbegin "rebar_fix_include_path deals with typical config"
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 $?
diff --git a/eclass/tests/rebar_remove_deps.sh b/eclass/tests/rebar_remove_deps.sh
index 05207a7..32351bf 100755
--- a/eclass/tests/rebar_remove_deps.sh
+++ b/eclass/tests/rebar_remove_deps.sh
@@ -67,6 +67,25 @@ test_typical_config() {
[[ ${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
@@ -92,6 +111,10 @@ 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 $?
--
2.8.3
^ permalink raw reply related [flat|nested] 2+ messages in thread
end of thread, other threads:[~2016-05-28 16:13 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-05-28 16:12 [gentoo-dev] [PATCH 1/2] rebar.eclass: Run unit tests aidecoe
2016-05-28 16:12 ` [gentoo-dev] [PATCH 2/2] rebar.eclass: Optionally provide alternate rebar config to alter aidecoe
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox