realidealseal <[email protected]> writes: > From: idealseal <[email protected]> > > Add an array 'skip_tests' that can be declared to skip multiple tests. > All test names will be converted to the right command line flag for cargo > test.
Can we do CARGO_SKIP_TESTS instead please? lowercase usually means local var and it also means the var is namespaced to the eclass then. I like the idea! > > Signed-off-by: idealseal <[email protected]> > --- > eclass/cargo.eclass | 46 ++++++++++++++++++++++++++++++++++++++++++++- > 1 file changed, 45 insertions(+), 1 deletion(-) > > diff --git a/eclass/cargo.eclass b/eclass/cargo.eclass > index 76d3b9a61a64..05744a26141f 100644 > --- a/eclass/cargo.eclass > +++ b/eclass/cargo.eclass > @@ -201,6 +201,22 @@ ECARGO_VENDOR="${ECARGO_HOME}/gentoo" > # } > # @CODE > > +# @ECLASS_VARIABLE: skip_tests > +# @DEFAULT_UNSET > +# @DESCRIPTION: > +# Optional array of test names to be skipped > +# Should be defined before calling cargo_src_test. > +# > +# @CODE > +# src_test() { > +# local skip_tests=( > +# tests::filesystem > +# tests::network > +# ) > +# cargo_src_test --no-fail-fast > +# } > +# @CODE > + > # @ECLASS_VARIABLE: ECARGO_HOME > # @OUTPUT_VARIABLE > # @DESCRIPTION: > @@ -836,7 +852,35 @@ cargo_src_test() { > > _cargo_check_initialized > > - set -- "${CARGO}" test $(usex debug "" --release) ${ECARGO_ARGS[@]} "$@" > + # This is the same as myfeatures in cargo_src_configure: > + # Prefix all test names with '--skip'. > + [[ -z ${skip_tests} ]] && declare -a skip_tests=() > + local skip_teststype=$(declare -p skip_tests 2>&-) > + if [[ "${skip_teststype}" != "declare -a skip_tests="* ]]; then > + die "skip_tests must be declared as array" > + fi > + > + skip_tests=( ${skip_tests[@]/#/--skip } ) > + > + # The skip flags must be passed to the test harness, after a '--' > + # on the command line. > + # To avoid breakage if the caller of cargo_src_test also passes '--', > + # we split the caller args and group the skip args together with the > + # caller args. > + local args=( $@ ) > + > + sep="${#args}" > + for i in "${!args[@]}"; do > + [[ "${args[i]}" == "--" ]] && sep="$i"; > + done > + > + cargo_test_args=( ${args[@]:0:sep} ) > + test_harness_args=( -- ${skip_tests[@]} ${args[@]:sep} ) > + > + set -- "${CARGO}" test $(usex debug "" --release) \ > + ${ECARGO_ARGS[@]} \ > + ${cargo_test_args[@]} \ > + ${test_harness_args[@]} > einfo "${@}" > cargo_env "${@}" || die "cargo test failed" > }
signature.asc
Description: PGP signature
