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
pub mod packs;

#[cfg(test)]
pub(crate) mod test_util {
    use packs::parsing::ruby::zeitwerk::get_zeitwerk_constant_resolver;
    use std::path::PathBuf;

    use packs::configuration;

    use crate::packs::{self, constant_resolver::ConstantResolver};

    pub const SIMPLE_APP: &str = "tests/fixtures/simple_app";

    pub fn get_absolute_root(fixture_name: &str) -> PathBuf {
        PathBuf::from(fixture_name).canonicalize().unwrap()
    }

    pub fn get_zeitwerk_constant_resolver_for_fixture(
        fixture_name: &str,
    ) -> Box<dyn ConstantResolver> {
        let absolute_root = get_absolute_root(fixture_name);
        let configuration = configuration::get(&absolute_root);

        get_zeitwerk_constant_resolver(
            &configuration.pack_set,
            &absolute_root,
            &configuration.cache_directory,
            true,
        )
    }
}