pchampin / sophia_rs

Sophia: a Rust toolkit for RDF and Linked Data
Other
210 stars 23 forks source link

Generated tests of namespace! macro #103

Closed nwagner84 closed 3 years ago

nwagner84 commented 3 years ago

Hi,

I've observed some strange behaviour executing generated tests created by the namespace! macro. I have the following code to create a skos namespace:

#[macro_use]
extern crate sophia_api;

pub mod skos {
    namespace!(
        "http://www.w3.org/2004/02/skos/core#",
        Concept,
        prefLabel,
        altLabel,
        hiddenLabel
    );
}

The code works fine in production, but the tests are failing completely randomly:

cargo test
    Finished test [unoptimized + debuginfo] target(s) in 0.01s
     Running target/debug/deps/skos_test-55fef88c12ab2b53

running 5 tests
test skos::test_valid_iri::Concept ... ok
test skos::test_valid_iri::hiddenLabel ... ok
test skos::test_valid_iri::prefLabel ... ok
thread 'main' panicked at 'called `Option::unwrap()` on a `None` value', library/test/src/lib.rs:356:75
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
thread 'skos::test_valid_iri::altLabel' panicked at 'called `Result::unwrap()` on an `Err` value: "SendError(..)"', library/test/src/lib.rs:592:30
error: test failed, to rerun pass '--lib'

Same code, no changes:

cargo test
    Finished test [unoptimized + debuginfo] target(s) in 0.01s
     Running target/debug/deps/skos_test-55fef88c12ab2b53

running 5 tests
test skos::test_valid_iri::altLabel ... ok
test skos::test_valid_iri::prefLabel ... ok
test skos::test_valid_iri::Concept ... ok
thread 'main' panicked at 'called `Option::unwrap()` on a `None` value', library/test/src/lib.rs:356:75
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
error: test failed, to rerun pass '--lib'

The namespace! macro was imported via sophia_api.

Any ideas why the tests are failing?

nwagner84 commented 3 years ago

It seems to be a bug in the nightly-version of rust. After updating to the latest nightly-build every works as expected (same on stable version).

pchampin commented 3 years ago

Thanks for the update. I was about to ask what version of rust you were using ;)

I have a similar problem currently in the CI: the stable and nightly version are passing the tests correctly, but the beta version is panicking with a similar message to yours... :-/