add cargo-test
It's same as we would be running in %check. Signed-off-by: Igor Gnatenko <ignatenkobrain@fedoraproject.org>
This commit is contained in:
parent
71b502f36a
commit
f3539c402d
1 changed files with 32 additions and 0 deletions
32
cargo-test/runtest.sh
Executable file
32
cargo-test/runtest.sh
Executable file
|
|
@ -0,0 +1,32 @@
|
|||
#!/bin/bash -euf
|
||||
|
||||
dnf -y --best install rust-packaging
|
||||
dnf -y --best --nogpgcheck --repo="test-$pkg" install "$pkg-devel"
|
||||
|
||||
provides=$(rpm -qP "$pkg-devel")
|
||||
|
||||
while read -r prv; do
|
||||
if [[ "$prv" =~ ^crate\(([^/]+)\)\ \=\ ([0-9]\.[0-9]\.[0-9]) ]]; then
|
||||
crate="${BASH_REMATCH[1]}"
|
||||
version="${BASH_REMATCH[2]}"
|
||||
fi
|
||||
done <<< "$provides"
|
||||
|
||||
echo "$crate ($version)"
|
||||
|
||||
cargo_registry=$(rpm --eval "%{cargo_registry}")
|
||||
crate_dir="$cargo_registry/$crate-$version"
|
||||
crate_toml="$crate_dir/Cargo.toml"
|
||||
|
||||
# XXX: ideally we should just install -tests subpackage
|
||||
# which would require all necessary deps
|
||||
eval $(rpm --eval "%{__cargo_inspector}") --test-requires "$crate_toml" | \
|
||||
sed -r -e "s/(.*)/'\1'/" | xargs sudo dnf -y install
|
||||
|
||||
# XXX: sed is needed due to https://github.com/rpm-software-management/rpm/issues/472
|
||||
rpm -D "_with_check 1" --eval "%cargo_prep" | \
|
||||
sed -r -e "s/%if (.+)/if [ \1 ]; then/;s/%endif/fi/" -e "s/<< EOF/<< 'EOF'/" > prep.sh
|
||||
# XXX: We can't run eval directly, so source it
|
||||
source prep.sh
|
||||
|
||||
exec cargo test --manifest-path "$crate_toml" "$@"
|
||||
Loading…
Add table
Add a link
Reference in a new issue