Blame cargo-test/runtest.sh

f3539c4
#!/bin/bash -euf
f3539c4
f3539c4
dnf -y --best install rust-packaging
f3539c4
dnf -y --best --nogpgcheck --repo="test-$pkg" install "$pkg-devel"
f3539c4
f3539c4
provides=$(rpm -qP "$pkg-devel")
f3539c4
f3539c4
while read -r prv; do
f3539c4
  if [[ "$prv" =~ ^crate\(([^/]+)\)\ \=\ ([0-9]\.[0-9]\.[0-9]) ]]; then
f3539c4
    crate="${BASH_REMATCH[1]}"
f3539c4
    version="${BASH_REMATCH[2]}"
f3539c4
  fi
f3539c4
done <<< "$provides"
f3539c4
f3539c4
echo "$crate ($version)"
f3539c4
f3539c4
cargo_registry=$(rpm --eval "%{cargo_registry}")
f3539c4
crate_dir="$cargo_registry/$crate-$version"
f3539c4
crate_toml="$crate_dir/Cargo.toml"
f3539c4
f3539c4
# XXX: ideally we should just install -tests subpackage
f3539c4
# which would require all necessary deps
707af2f
$(rpm --eval "%{__cargo_inspector}") --test-requires "$crate_toml" | \
f3539c4
  sed -r -e "s/(.*)/'\1'/" | xargs sudo dnf -y install
f3539c4
f3539c4
# XXX: sed is needed due to https://github.com/rpm-software-management/rpm/issues/472
f3539c4
rpm -D "_with_check 1" --eval "%cargo_prep" | \
f3539c4
  sed -r -e "s/%if (.+)/if [ \1 ]; then/;s/%endif/fi/" -e "s/<< EOF/<< 'EOF'/" > prep.sh
f3539c4
# XXX: We can't run eval directly, so source it
f3539c4
source prep.sh
f3539c4
ef0342d
exec $(rpm --eval "%cargo_test") --manifest-path "$crate_toml" "$@"