summaryrefslogtreecommitdiff
path: root/tests/depend.rs
blob: 02c59f2e74327769072e606baf4d2f2444db8c17 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
use gentoo_utils::{
    Parseable,
    atom::Atom,
    depend::{self, Expr},
};
use mon::{Parser, eof, input::InputIter, tag, whitespace1};
use std::fs;

#[test]
fn parse_md5_cache() {
    let md5_cache = "/var/db/repos/gentoo/metadata/md5-cache";

    for cat in fs::read_dir(md5_cache).unwrap() {
        for pkg in fs::read_dir(cat.unwrap().path()).unwrap() {
            let metadata = fs::read_to_string(pkg.unwrap().path()).unwrap();

            for line in metadata.lines() {
                if line.starts_with("DEPEND=") {
                    eprintln!("{line}");
                    eprintln!();
                    Expr::<Atom>::parser()
                        .separated_list(whitespace1(), 0..)
                        .ignore()
                        .or(eof())
                        .preceded_by(tag("DEPEND="))
                        .check_finished(InputIter::new(line))
                        .unwrap();
                }
            }
        }
    }
}