From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by finch.gentoo.org (Postfix) with ESMTPS id 1CF82138334 for ; Mon, 7 Jan 2019 04:02:03 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 5D1B7E0ADA; Mon, 7 Jan 2019 04:01:33 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id E58FEE0AD1 for ; Mon, 7 Jan 2019 04:01:32 +0000 (UTC) Received: from reaper.local.sysdump.net (ip72-194-88-79.oc.oc.cox.net [72.194.88.79]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: gyakovlev) by smtp.gentoo.org (Postfix) with ESMTPSA id 146FE335CA6; Mon, 7 Jan 2019 04:01:31 +0000 (UTC) From: Georgy Yakovlev To: gentoo-dev@lists.gentoo.org Cc: Georgy Yakovlev Subject: [gentoo-dev] [PATCH 2/2] cargo.eclass: add standard src_test Date: Sun, 6 Jan 2019 20:01:22 -0800 Message-Id: <20190107040122.6874-2-gyakovlev@gentoo.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190107040122.6874-1-gyakovlev@gentoo.org> References: <20190107040122.6874-1-gyakovlev@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 X-Auto-Response-Suppress: DR, RN, NRN, OOF, AutoReply MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Archives-Salt: 70c3d46e-24e1-4393-8ffa-0c46711f645c X-Archives-Hash: d4324409397ba49902d72cc37a1961a1 But not set IUSE=test by default Signed-off-by: Georgy Yakovlev This is pretty straightforward change, just adds standard src_test for cargo --- eclass/cargo.eclass | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/eclass/cargo.eclass b/eclass/cargo.eclass index ee17f2af9d9..c576c8e8066 100644 --- a/eclass/cargo.eclass +++ b/eclass/cargo.eclass @@ -1,142 +1,152 @@ # Copyright 1999-2019 Gentoo Authors # Distributed under the terms of the GNU General Public License v2 # @ECLASS: cargo.eclass # @MAINTAINER: # rust@gentoo.org # @AUTHOR: # Doug Goldstein # @SUPPORTED_EAPIS: 6 7 # @BLURB: common functions and variables for cargo builds if [[ -z ${_CARGO_ECLASS} ]]; then _CARGO_ECLASS=1 CARGO_DEPEND="" [[ ${CATEGORY}/${PN} != dev-util/cargo ]] && CARGO_DEPEND="virtual/cargo" case ${EAPI} in 6) DEPEND="${CARGO_DEPEND}";; 7) BDEPEND="${CARGO_DEPEND}";; *) die "EAPI=${EAPI:-0} is not supported" ;; esac inherit multiprocessing -EXPORT_FUNCTIONS src_unpack src_compile src_install +EXPORT_FUNCTIONS src_unpack src_compile src_install src_test IUSE="${IUSE} debug" ECARGO_HOME="${WORKDIR}/cargo_home" ECARGO_VENDOR="${ECARGO_HOME}/gentoo" # @FUNCTION: cargo_crate_uris # @DESCRIPTION: # Generates the URIs to put in SRC_URI to help fetch dependencies. cargo_crate_uris() { local crate for crate in "$@"; do local name version url pretag name="${crate%-*}" version="${crate##*-}" pretag="^[a-zA-Z]+" if [[ $version =~ $pretag ]]; then version="${name##*-}-${version}" name="${name%-*}" fi url="https://crates.io/api/v1/crates/${name}/${version}/download -> ${crate}.crate" echo "${url}" done } # @FUNCTION: cargo_src_unpack # @DESCRIPTION: # Unpacks the package and the cargo registry cargo_src_unpack() { debug-print-function ${FUNCNAME} "$@" mkdir -p "${ECARGO_VENDOR}" || die mkdir -p "${S}" || die local archive shasum pkg for archive in ${A}; do case "${archive}" in *.crate) ebegin "Loading ${archive} into Cargo registry" tar -xf "${DISTDIR}"/${archive} -C "${ECARGO_VENDOR}/" || die # generate sha256sum of the crate itself as cargo needs this shasum=$(sha256sum "${DISTDIR}"/${archive} | cut -d ' ' -f 1) pkg=$(basename ${archive} .crate) cat <<- EOF > ${ECARGO_VENDOR}/${pkg}/.cargo-checksum.json { "package": "${shasum}", "files": {} } EOF # if this is our target package we need it in ${WORKDIR} too # to make ${S} (and handle any revisions too) if [[ ${P} == ${pkg}* ]]; then tar -xf "${DISTDIR}"/${archive} -C "${WORKDIR}" || die fi eend $? ;; cargo-snapshot*) ebegin "Unpacking ${archive}" mkdir -p "${S}"/target/snapshot tar -xzf "${DISTDIR}"/${archive} -C "${S}"/target/snapshot --strip-components 2 || die # cargo's makefile needs this otherwise it will try to # download it touch "${S}"/target/snapshot/bin/cargo || die eend $? ;; *) unpack ${archive} ;; esac done cargo_gen_config } # @FUNCTION: cargo_gen_config # @DESCRIPTION: # Generate the $CARGO_HOME/config necessary to use our local registry cargo_gen_config() { debug-print-function ${FUNCNAME} "$@" cat <<- EOF > "${ECARGO_HOME}/config" [source.gentoo] directory = "${ECARGO_VENDOR}" [source.crates-io] replace-with = "gentoo" local-registry = "/nonexistant" EOF } # @FUNCTION: cargo_src_compile # @DESCRIPTION: # Build the package using cargo build cargo_src_compile() { debug-print-function ${FUNCNAME} "$@" export CARGO_HOME="${ECARGO_HOME}" cargo build -j $(makeopts_jobs) $(usex debug "" --release) "${@}" \ || die "cargo build failed" } # @FUNCTION: cargo_src_install # @DESCRIPTION: # Installs the binaries generated by cargo cargo_src_install() { debug-print-function ${FUNCNAME} "$@" cargo install -j $(makeopts_jobs) --root="${D}/usr" $(usex debug --debug "") "${@}" \ || die "cargo install failed" rm -f "${D}/usr/.crates.toml" [ -d "${S}/man" ] && doman "${S}/man" || return 0 } +# @FUNCTION: cargo_src_test +# @DESCRIPTION: +# Test the package using cargo test +cargo_src_test() { + debug-print-function ${FUNCNAME} "$@" + + cargo test -j $(makeopts_jobs) $(usex debug "" --release) "${@}" \ + || die "cargo test failed" +} + fi -- 2.20.1