Cargo test give an error during a package build generated by rust2rpm

Hi,

I’m asking for help because I’ve tried to build rust-embed in version 8.3.0 which is a required dependency to build typer in version 1.4.1.
Unfortunately the rpmbuild process fail on cargo test step and I don’t really know why.

Here’s what I’ve done:

rpmdev-setuptree
cd ~/rpmbuild/SPECS
rpmdev-newspec rust-rust-embed-utils #dependency for rust-embed
rpmdev-newspec rust-rust-embed-impl #dependency for rust-embed
rpmdev-newspec rust-rust-embed
rust2rpm rust-embed-utils 8.3.0 # populate .spec file
rust2rpm rust-embed-impl 8.3.0 # populate .spec file
rust2rpm rust-embed 8.3.0 # populate .spec file
cd ../SOURCES
rust2rpm -s rust-embed-utils 8.3.0 # fetch crate souce code as gzip for crate.io api
rust2rpm -s rust-embed-impl 8.3.0  # fetch crate souce code as gzip for crate.io api
rust2rpm -s rust-embed 8.3.0 # fetch crate souce code as gzip for crate.io api
cd ..
rpmbuild -ba SPECS/rust-rust-embed-utils.spec # build succeed
rpmbuild -ba SPECS/rust-rust-embed-utils.spec # build succeed too
cd RPMS/noarch
sudo dnf in --allowerasing $(ls) # install rust-embed-utils and rust-embed-impl because they are required to build rust-embed
cd ../..
rpmbuild -ba SPECS/rust-rust-embed.spec # build failed!

When I attempt to build rust-embed the cargo test step fail.

2 -Ccodegen-units=1 -Cstrip=none -Cforce-frame-pointers=yes -Clink-arg=-specs=/usr/lib/rpm/redhat/redhat-package-notes --cap-lints=warn`
    Finished rpm [optimized + debuginfo] target(s) in 0.88s
     Running `/home/protocod/rpmbuild/BUILD/rust-embed-8.3.0/target/rpm/deps/rust_embed-0ec6fbdf77aefd9f`

running 0 tests

test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.00s

     Running `/home/protocod/rpmbuild/BUILD/rust-embed-8.3.0/target/rpm/deps/lib-963907810a9eb42a`

running 4 tests
test get_windows_style ... ok
test get_works ... ok
test iter_works ... ok
test trait_works_generic ... ok

test result: ok. 4 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.00s

     Running `/home/protocod/rpmbuild/BUILD/rust-embed-8.3.0/target/rpm/deps/metadata-a1e24d0ef60b0748`

running 3 tests
test hash_is_accurate ... ok
test last_modified_is_accurate ... FAILED
test create_is_accurate ... FAILED

failures:

---- last_modified_is_accurate stdout ----
thread 'last_modified_is_accurate' panicked at tests/metadata.rs:26:3:
assertion `left == right` failed
  left: Some(1712448000)
 right: Some(1153704088)

---- create_is_accurate stdout ----
thread 'create_is_accurate' panicked at tests/metadata.rs:36:3:
assertion `left == right` failed
  left: Some(1712448000)
 right: Some(1712524744)
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace


failures:
    create_is_accurate
    last_modified_is_accurate

test result: FAILED. 1 passed; 2 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.00s

error: test failed, to rerun pass `--test metadata`
     Running `/home/protocod/rpmbuild/BUILD/rust-embed-8.3.0/target/rpm/deps/path_traversal_attack-168fe9ad1c8eddca`

running 2 tests
test path_traversal_attack_symlink_fails ... ignored, see https://github.com/pyrossh/rust-embed/pull/235
test path_traversal_attack_fails ... ok

test result: ok. 1 passed; 0 failed; 1 ignored; 0 measured; 0 filtered out; finished in 0.00s

     Running `/home/protocod/rpmbuild/BUILD/rust-embed-8.3.0/target/rpm/deps/prefix-e24dc1231f15d8dd`

running 3 tests
test get_with_prefix ... ok
test get_without_prefix ... ok
test iter_values_have_prefix ... ok

test result: ok. 3 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.00s

   Doc-tests rust-embed
     Running `/usr/bin/rustdoc --edition=2018 --crate-type lib --crate-name rust_embed --test src/lib.rs --test-run-directory /home/protocod/rpmbuild/BUILD/rust-embed-8.3.0 -L dependency=/home/protocod/rpmbuild/BUILD/rust-embed-8.3.0/target/rpm/deps -L dependency=/home/protocod/rpmbuild/BUILD/rust-embed-8.3.0/target/rpm/deps --extern rust_embed=/home/protocod/rpmbuild/BUILD/rust-embed-8.3.0/target/rpm/deps/librust_embed-34e4368b91f78c0a.rlib --extern rust_embed_impl=/home/protocod/rpmbuild/BUILD/rust-embed-8.3.0/target/rpm/deps/librust_embed_impl-902388ab63fa7fed.so --extern rust_embed_utils=/home/protocod/rpmbuild/BUILD/rust-embed-8.3.0/target/rpm/deps/librust_embed_utils-5f3dd5c1ccf4ffea.rlib --extern sha2=/home/protocod/rpmbuild/BUILD/rust-embed-8.3.0/target/rpm/deps/libsha2-6ed206d3c7c52483.rlib --extern walkdir=/home/protocod/rpmbuild/BUILD/rust-embed-8.3.0/target/rpm/deps/libwalkdir-c97b9fbc46388f4a.rlib -C embed-bitcode=no --error-format human`

running 1 test
test src/lib.rs - RustEmbed (line 23) ... FAILED

failures:

---- src/lib.rs - RustEmbed (line 23) stdout ----
error[E0599]: no variant or associated item named `Dynamic` found for enum `Filenames` in the current scope
 --> src/lib.rs:27:10
  |
6 | #[derive(RustEmbed)]
  |          ^^^^^^^^^ variant or associated item not found in `Filenames`
  |
  = note: this error originates in the derive macro `RustEmbed` (in Nightly builds, run with -Z macro-backtrace for more info)

error: aborting due to 1 previous error

For more information about this error, try `rustc --explain E0599`.
Couldn't compile the test.

failures:
    src/lib.rs - RustEmbed (line 23)

test result: FAILED. 0 passed; 1 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.06s

error: doctest failed, to rerun pass `--doc`
error: 2 targets failed:
    `--test metadata`
    `--doc`
error: Bad exit status from /var/tmp/rpm-tmp.OEWD26 (%check)

RPM build errors:
    Bad exit status from /var/tmp/rpm-tmp.OEWD26 (%check)

It looks like it does’t take the good code for testing. I managed to clone the source code of rust-embed from github and I succeed to run a cargo test on the commit that matches the 8.3.0 release. So I guess it has something to do with the way cargo is managed by rpmbuild or something like that.

Sorry I’m a newbie concerning package managing, I discover rust2rpm and spec file at the same time.
Is there someone able to explain what I’m doing wrong ?

Thank you for reading.

Maximilien

You might want to ask on Matrix - https://matrix.to/#/#rust:fedoraproject.org - most Rust conversations happen there

Thank you, I’ll join the matrix instance soon.