Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

random doc tests are failing #345

Closed
Luro02 opened this issue Feb 13, 2020 · 4 comments
Closed

random doc tests are failing #345

Luro02 opened this issue Feb 13, 2020 · 4 comments
Labels

Comments

@Luro02
Copy link

Luro02 commented Feb 13, 2020

In my PR (sile/hls_m3u8#44) tests, that work with cargo test are failing randomly.

I ran cargo tarpaulin multiple times and noticed that the number of failed tests changes between each run.

first run (84 passed; 41 failed)
test src/tags/media_playlist/discontinuity_sequence.rs - tags::media_playlist::discontinuity_sequence::ExtXDiscontinuitySequence::seq_num (line 28) ... FAILED
test src/tags/media_playlist/discontinuity_sequence.rs - tags::media_playlist::discontinuity_sequence::ExtXDiscontinuitySequence::set_seq_num (line 28) ... FAILED
test src/tags/media_segment/map.rs - tags::media_segment::map::ExtXMap::range (line 43) ... FAILED
test src/tags/media_segment/map.rs - tags::media_segment::map::ExtXMap::range (line 43) ... FAILED
test src/tags/media_segment/map.rs - tags::media_segment::map::ExtXMap::set_uri (line 27) ... FAILED
test src/tags/media_segment/map.rs - tags::media_segment::map::ExtXMap::uri (line 27) ... FAILED
test src/tags/shared/start.rs - tags::shared::start::ExtXStart::is_precise (line 24) ... FAILED
test src/tags/shared/start.rs - tags::shared::start::ExtXStart::is_precise (line 24) ... FAILED
test src/types/byte_range.rs - types::byte_range::ByteRange::start (line 34) ... FAILED
test src/types/byte_range.rs - types::byte_range::ByteRange::set_start (line 34) ... FAILED
test src/types/byte_range.rs - types::byte_range::ByteRange::length (line 20) ... FAILED
test src/types/byte_range.rs - types::byte_range::ByteRange::length (line 20) ... FAILED
test src/types/decryption_key.rs - types::decryption_key::DecryptionKey::iv (line 76) ... FAILED
test src/types/decryption_key.rs - types::decryption_key::DecryptionKey::key_format (line 103) ... FAILED
test src/types/decryption_key.rs - types::decryption_key::DecryptionKey::key_format (line 103) ... FAILED
test src/types/decryption_key.rs - types::decryption_key::DecryptionKey::key_format_versions (line 124) ... FAILED
test src/types/decryption_key.rs - types::decryption_key::DecryptionKey::key_format_versions (line 124) ... FAILED
test src/types/decryption_key.rs - types::decryption_key::DecryptionKey::method (line 27) ... FAILED
test src/types/decryption_key.rs - types::decryption_key::DecryptionKey::uri (line 50) ... FAILED
test src/types/decryption_key.rs - types::decryption_key::DecryptionKey::method (line 27) ... FAILED
test src/types/decryption_key.rs - types::decryption_key::DecryptionKey::set_uri (line 50) ... FAILED
test src/types/decryption_key.rs - types::decryption_key::DecryptionKey::set_key_format (line 103) ... FAILED
test src/types/decryption_key.rs - types::decryption_key::DecryptionKeyBuilder::key_format_versions (line 124) ... FAILED
test src/types/decryption_key.rs - types::decryption_key::DecryptionKey::uri (line 50) ... FAILED
test src/types/decryption_key.rs - types::decryption_key::DecryptionKeyBuilder::uri (line 50) ... FAILED
test src/types/decryption_key.rs - types::decryption_key::DecryptionKeyBuilder::key_format (line 103) ... FAILED
test src/types/decryption_key.rs - types::decryption_key::DecryptionKeyBuilder::method (line 27) ... FAILED
test src/types/stream_data.rs - types::stream_data::StreamData::codecs (line 110) ... FAILED
test src/types/stream_data.rs - types::stream_data::StreamData::bandwidth (line 38) ... FAILED
test src/types/stream_data.rs - types::stream_data::StreamData::average_bandwidth (line 76) ... FAILED
test src/types/stream_data.rs - types::stream_data::StreamData::hdcp_level (line 160) ... FAILED
test src/types/stream_data.rs - types::stream_data::StreamData::video (line 188) ... FAILED
test src/types/stream_data.rs - types::stream_data::StreamData::resolution (line 134) ... FAILED
test src/types/stream_data.rs - types::stream_data::StreamData::resolution (line 134) ... FAILED
test src/types/stream_data.rs - types::stream_data::StreamData::set_video (line 188) ... FAILED
test src/types/stream_data.rs - types::stream_data::StreamData::video (line 188) ... FAILED
test src/types/stream_data.rs - types::stream_data::StreamDataBuilder::hdcp_level (line 160) ... FAILED
test src/types/stream_data.rs - types::stream_data::StreamDataBuilder::bandwidth (line 38) ... FAILED
test src/types/stream_data.rs - types::stream_data::StreamDataBuilder::codecs (line 110) ... FAILED
test src/types/stream_data.rs - types::stream_data::StreamDataBuilder::average_bandwidth (line 76) ... FAILED
test src/types/stream_data.rs - types::stream_data::StreamDataBuilder::video (line 188) ... FAILED
test result: FAILED. 84 passed; 41 failed; 0 ignored; 0 measured; 0 filtered out
second run (86 passed; 39 failed)
test src/tags/media_playlist/discontinuity_sequence.rs - tags::media_playlist::discontinuity_sequence::ExtXDiscontinuitySequence::seq_num (line 28) ... FAILED
test src/tags/media_playlist/discontinuity_sequence.rs - tags::media_playlist::discontinuity_sequence::ExtXDiscontinuitySequence::seq_num (line 28) ... FAILED
test src/tags/shared/start.rs - tags::shared::start::ExtXStart::is_precise (line 24) ... FAILED
test src/tags/media_segment/map.rs - tags::media_segment::map::ExtXMap::range (line 43) ... FAILED
test src/tags/media_segment/map.rs - tags::media_segment::map::ExtXMap::set_range (line 43) ... FAILED
test src/tags/shared/start.rs - tags::shared::start::ExtXStart::is_precise (line 24) ... FAILED
test src/tags/shared/start.rs - tags::shared::start::ExtXStart::set_is_precise (line 24) ... FAILED
test src/tags/media_segment/map.rs - tags::media_segment::map::ExtXMap::set_uri (line 27) ... FAILED
test src/tags/media_segment/map.rs - tags::media_segment::map::ExtXMap::uri (line 27) ... FAILED
test src/types/byte_range.rs - types::byte_range::ByteRange::length (line 20) ... FAILED
test src/types/byte_range.rs - types::byte_range::ByteRange::length (line 20) ... FAILED
test src/types/byte_range.rs - types::byte_range::ByteRange::start (line 34) ... FAILED
test src/types/byte_range.rs - types::byte_range::ByteRange::set_start (line 34) ... FAILED
test src/types/decryption_key.rs - types::decryption_key::DecryptionKey::iv (line 76) ... FAILED
test src/types/decryption_key.rs - types::decryption_key::DecryptionKey::method (line 27) ... FAILED
test src/types/decryption_key.rs - types::decryption_key::DecryptionKey::key_format (line 103) ... FAILED
test src/types/decryption_key.rs - types::decryption_key::DecryptionKey::iv (line 76) ... FAILED
test src/types/decryption_key.rs - types::decryption_key::DecryptionKey::key_format (line 103) ... FAILED
test src/types/decryption_key.rs - types::decryption_key::DecryptionKey::uri (line 50) ... FAILED
test src/types/decryption_key.rs - types::decryption_key::DecryptionKey::key_format_versions (line 124) ... FAILED
test src/types/decryption_key.rs - types::decryption_key::DecryptionKey::key_format_versions (line 124) ... FAILED
test src/types/decryption_key.rs - types::decryption_key::DecryptionKey::uri (line 50) ... FAILED
test src/types/decryption_key.rs - types::decryption_key::DecryptionKeyBuilder::key_format (line 103) ... FAILED
test src/types/decryption_key.rs - types::decryption_key::DecryptionKeyBuilder::iv (line 76) ... FAILED
test src/types/decryption_key.rs - types::decryption_key::DecryptionKeyBuilder::key_format_versions (line 124) ... FAILED
test src/types/decryption_key.rs - types::decryption_key::DecryptionKeyBuilder::uri (line 50) ... FAILED
test src/types/stream_data.rs - types::stream_data::StreamData::average_bandwidth (line 76) ... FAILED
test src/types/stream_data.rs - types::stream_data::StreamData::average_bandwidth (line 76) ... FAILED
test src/types/stream_data.rs - types::stream_data::StreamData::codecs (line 110) ... FAILED
test src/types/stream_data.rs - types::stream_data::StreamData::hdcp_level (line 160) ... FAILED
test src/types/stream_data.rs - types::stream_data::StreamData::resolution (line 134) ... FAILED
test src/types/stream_data.rs - types::stream_data::StreamData::resolution (line 134) ... FAILED
test src/types/stream_data.rs - types::stream_data::StreamData::video (line 188) ... FAILED
test src/types/stream_data.rs - types::stream_data::StreamData::video (line 188) ... FAILED
test src/types/stream_data.rs - types::stream_data::StreamDataBuilder::resolution (line 134) ... FAILED
test src/types/stream_data.rs - types::stream_data::StreamDataBuilder::bandwidth (line 38) ... FAILED
test src/types/stream_data.rs - types::stream_data::StreamDataBuilder::codecs (line 110) ... FAILED
test src/types/stream_data.rs - types::stream_data::StreamDataBuilder::hdcp_level (line 160) ... FAILED
test src/types/stream_data.rs - types::stream_data::StreamDataBuilder::video (line 188) ... FAILED
test result: FAILED. 86 passed; 39 failed; 0 ignored; 0 measured; 0 filtered out
third run (82 passed; 43 failed)
test src/tags/media_playlist/discontinuity_sequence.rs - tags::media_playlist::discontinuity_sequence::ExtXDiscontinuitySequence::seq_num (line 28) ... FAILED
test src/tags/media_playlist/discontinuity_sequence.rs - tags::media_playlist::discontinuity_sequence::ExtXDiscontinuitySequence::seq_num (line 28) ... FAILED
test src/tags/media_segment/map.rs - tags::media_segment::map::ExtXMap::set_range (line 43) ... FAILED
test src/tags/media_segment/map.rs - tags::media_segment::map::ExtXMap::range (line 43) ... FAILED
test src/tags/media_segment/map.rs - tags::media_segment::map::ExtXMap::set_uri (line 27) ... FAILED
test src/tags/media_segment/map.rs - tags::media_segment::map::ExtXMap::uri (line 27) ... FAILED
test src/tags/shared/start.rs - tags::shared::start::ExtXStart::is_precise (line 24) ... FAILED
test src/tags/shared/start.rs - tags::shared::start::ExtXStart::is_precise (line 24) ... FAILED
test src/types/byte_range.rs - types::byte_range::ByteRange::length (line 20) ... FAILED
test src/types/byte_range.rs - types::byte_range::ByteRange::length (line 20) ... FAILED
test src/types/byte_range.rs - types::byte_range::ByteRange::set_start (line 34) ... FAILED
test src/types/byte_range.rs - types::byte_range::ByteRange::start (line 34) ... FAILED
test src/types/decryption_key.rs - types::decryption_key::DecryptionKey::key_format_versions (line 124) ... FAILED
test src/types/decryption_key.rs - types::decryption_key::DecryptionKey::key_format (line 103) ... FAILED
test src/types/decryption_key.rs - types::decryption_key::DecryptionKey::key_format (line 103) ... FAILED
test src/types/decryption_key.rs - types::decryption_key::DecryptionKey::uri (line 50) ... FAILED
test src/types/decryption_key.rs - types::decryption_key::DecryptionKeyBuilder::iv (line 76) ... FAILED
test src/types/decryption_key.rs - types::decryption_key::DecryptionKey::method (line 27) ... FAILED
test src/types/decryption_key.rs - types::decryption_key::DecryptionKey::set_uri (line 50) ... FAILED
test src/types/decryption_key.rs - types::decryption_key::DecryptionKeyBuilder::key_format (line 103) ... FAILED
test src/types/decryption_key.rs - types::decryption_key::DecryptionKey::method (line 27) ... FAILED
test src/types/decryption_key.rs - types::decryption_key::DecryptionKeyBuilder::method (line 27) ... FAILED
test src/types/decryption_key.rs - types::decryption_key::DecryptionKeyBuilder::uri (line 50) ... FAILED
test src/types/decryption_key.rs - types::decryption_key::DecryptionKeyBuilder::key_format_versions (line 124) ... FAILED
test src/types/decryption_key.rs - types::decryption_key::DecryptionKeyBuilder::method (line 27) ... FAILED
test src/types/decryption_key.rs - types::decryption_key::DecryptionKey::uri (line 50) ... FAILED
test src/types/stream_data.rs - types::stream_data::StreamData::bandwidth (line 38) ... FAILED
test src/types/stream_data.rs - types::stream_data::StreamData::average_bandwidth (line 76) ... FAILED
test src/types/stream_data.rs - types::stream_data::StreamData::codecs (line 110) ... FAILED
test src/types/stream_data.rs - types::stream_data::StreamData::codecs (line 110) ... FAILED
test src/types/stream_data.rs - types::stream_data::StreamData::resolution (line 134) ... FAILED
test src/types/stream_data.rs - types::stream_data::StreamData::hdcp_level (line 160) ... FAILED
test src/types/stream_data.rs - types::stream_data::StreamData::set_codecs (line 110) ... FAILED
test src/types/stream_data.rs - types::stream_data::StreamData::resolution (line 134) ... FAILED
test src/types/stream_data.rs - types::stream_data::StreamData::hdcp_level (line 160) ... FAILED
test src/types/stream_data.rs - types::stream_data::StreamData::video (line 188) ... FAILED
test src/types/stream_data.rs - types::stream_data::StreamData::set_video (line 188) ... FAILED
test src/types/stream_data.rs - types::stream_data::StreamDataBuilder::average_bandwidth (line 76) ... FAILED
test src/types/stream_data.rs - types::stream_data::StreamDataBuilder::codecs (line 110) ... FAILED
test src/types/stream_data.rs - types::stream_data::StreamDataBuilder::bandwidth (line 38) ... FAILED
test src/types/stream_data.rs - types::stream_data::StreamDataBuilder::video (line 188) ... FAILED
test src/types/stream_data.rs - types::stream_data::StreamDataBuilder::resolution (line 134) ... FAILED
test src/types/stream_data.rs - types::stream_data::StreamDataBuilder::hdcp_level (line 160) ... FAILED
test result: FAILED. 82 passed; 43 failed; 0 ignored; 0 measured; 0 filtered out

I produced the above with cargo tarpaulin --run-types Doctests | grep FAILED >> third_run.txt

The full output with --debug including stdout and stderr is over 100k lines, so I just pasted the "important" lines here https://pastebin.com/m7rY2ZmE

This does happen in CI too https://travis-ci.org/sile/hls_m3u8/jobs/648390858#L614

@xd009642 xd009642 added the bug label Feb 19, 2020
@Luro02
Copy link
Author

Luro02 commented Feb 23, 2020

After a bit of tinkering I came up with this code, which reproduces the issue:

use std::env;
use std::path::Path;

use cargo::core::{compiler::CompileMode, Shell, Workspace};
use cargo::ops::{self, CompileOptions, FilterRule, LibRule};
use cargo::util::Config;

fn setup_environment() {
    env::set_var(
        "RUSTDOCFLAGS",
        concat!(
            " --persist-doctests target/doctests",
            " -Z unstable-options"
        ),
    );
}

fn main() {
    cargo::core::enable_nightly_features();
    setup_environment();

    let manifest = Path::new("/media/hdd/home/projects/hls_m3u8_test/Cargo.toml");
    let cwd = manifest.parent().unwrap().to_path_buf();
    let home = cargo::util::homedir(&cwd).unwrap();

    let mut config = Config::new(Shell::new(), cwd, home);
    config
        .configure(0u32, None, &None, false, false, false, &None, &[])
        .unwrap();

    let workspace = Workspace::new(&manifest, &config).unwrap();
    let mut compile_options = CompileOptions::new(&config, CompileMode::Doctest).unwrap();

    compile_options.filter = ops::CompileFilter::new(
        LibRule::Default,   // compile the library, so the unit tests can be run filtered
        FilterRule::All, // compile the binaries, so the unit tests in binaries can be run filtered
        FilterRule::All, // compile the tests, so the integration tests can be run filtered
        FilterRule::none(), // specify --examples to unit test binaries filtered
        FilterRule::none(), // specify --benches to unit test benchmarks filtered
    ); // also, specify --doc to run doc tests filtered

    let test_options = ops::TestOptions {
        compile_opts: compile_options,
        no_run: false,
        no_fail_fast: false,
    };

    dbg!(ops::run_tests(&workspace, &test_options, &[]).unwrap());
}

removing the --persist-doctests target/doctests flag will make the tests compile like normal.

@Luro02
Copy link
Author

Luro02 commented Feb 23, 2020

closing this as it does seem to be an issue related to cargo :)

I can reproduce the issue with RUSTDOCFLAGS="--persist-doctests target/doctests -Z unstable-options" cargo test --doc

@Luro02 Luro02 closed this as completed Feb 23, 2020
@xd009642
Copy link
Owner

Have you raised an issue on the compiler or cargo? I wouldn't want this to disappear into the ether 😄

@Luro02
Copy link
Author

Luro02 commented Feb 23, 2020

I am working on it :)

Edit: done

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants