fn check_produced()

in src/producer.rs [602:679]


    fn check_produced(
        directory: PathBuf,
        receiver: &JobReceiver,
        expected: Vec<(ItemFormat, bool, &str, bool)>,
    ) {
        let mut vec: Vec<Option<WorkItem>> = Vec::new();

        while let Ok(elem) = receiver.try_recv() {
            vec.push(elem);
        }

        for elem in &expected {
            assert!(
                vec.iter().any(|x| {
                    if !x.is_some() {
                        return false;
                    }

                    let x = x.as_ref().unwrap();

                    if x.format != elem.0 {
                        return false;
                    }

                    match x.item {
                        ItemType::Content(_) => !elem.1,
                        ItemType::Path((_, ref p)) => elem.1 && p.ends_with(elem.2),
                        ItemType::Paths(ref paths) => paths.iter().any(|p| p.ends_with(elem.2)),
                        ItemType::Buffers(ref b) => b.stem.replace('\\', "/").ends_with(elem.2),
                    }
                }),
                "Missing {:?}",
                elem
            );
        }

        for v in &vec {
            let v = v.as_ref().unwrap();
            assert!(
                expected.iter().any(|x| {
                    if v.format != x.0 {
                        return false;
                    }

                    match v.item {
                        ItemType::Content(_) => !x.1,
                        ItemType::Path((_, ref p)) => x.1 && p.ends_with(x.2),
                        ItemType::Paths(ref paths) => paths.iter().any(|p| p.ends_with(x.2)),
                        ItemType::Buffers(ref b) => b.stem.replace('\\', "/").ends_with(x.2),
                    }
                }),
                "Unexpected {:?}",
                v
            );
        }

        // Make sure we haven't generated duplicated entries.
        assert!(vec.len() <= expected.len());

        // Assert file exists and file with the same name but with extension .gcda exists.
        for x in expected.iter() {
            if !x.1 {
                continue;
            }

            let p = directory.join(x.2);
            assert!(p.exists(), "{} doesn't exist", p.display());
            if x.0 == ItemFormat::Gcno {
                let gcda =
                    p.with_file_name(format!("{}.gcda", p.file_stem().unwrap().to_str().unwrap()));
                if x.3 {
                    assert!(gcda.exists(), "{} doesn't exist", gcda.display());
                } else {
                    assert!(!gcda.exists(), "{} exists", gcda.display());
                }
            }
        }
    }