From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80]) by finch.gentoo.org (Postfix) with ESMTP id 7F9E513828B for ; Sat, 28 May 2016 16:13:52 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id D204A142C6; Sat, 28 May 2016 16:13:19 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id A48D5142B9 for ; Sat, 28 May 2016 16:13:18 +0000 (UTC) Received: from localhost (cpc92302-cmbg19-2-0-cust189.5-4.cable.virginm.net [82.1.208.190]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) (Authenticated sender: aidecoe) by smtp.gentoo.org (Postfix) with ESMTPSA id 93916340B29; Sat, 28 May 2016 16:13:17 +0000 (UTC) From: aidecoe@gentoo.org To: gentoo-dev@lists.gentoo.org Cc: =?UTF-8?q?Amadeusz=20=C5=BBo=C5=82nowski?= Subject: [gentoo-dev] [PATCH 2/2] rebar.eclass: Optionally provide alternate rebar config to alter Date: Sat, 28 May 2016 17:12:58 +0100 Message-Id: <20160528161258.8966-2-aidecoe@gentoo.org> X-Mailer: git-send-email 2.8.3 In-Reply-To: <20160528161258.8966-1-aidecoe@gentoo.org> References: <20160528161258.8966-1-aidecoe@gentoo.org> Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-dev@lists.gentoo.org Reply-to: gentoo-dev@lists.gentoo.org MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Archives-Salt: 5d115128-0828-43dc-96f8-90292d6f6afe X-Archives-Hash: d369b4a3f6494572a0432dbcc544e108 From: Amadeusz Żołnowski 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: +# @USAGE: [] # @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. # +# 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: [] # @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. # +# 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