(modules: &HashMap<String, ModuleDef>, aliases: &HashMap<String, String>, manifests: &HashMap<String, ManifestDef>)
| 81 | } |
| 82 | |
| 83 | fn build_resolver(modules: &HashMap<String, ModuleDef>, aliases: &HashMap<String, String>, manifests: &HashMap<String, ManifestDef>) -> TestResolver { |
| 84 | let mut r = TestResolver::new(); |
| 85 | for (spec, def) in modules { |
| 86 | match def { |
| 87 | ModuleDef::Native { native, bytes } => { |
| 88 | let bindings: Vec<NativeBinding> = native.iter() |
| 89 | .map(|n| test_native(n) |
| 90 | .unwrap_or_else(|| panic!("unknown test native: {}", n))) |
| 91 | .collect(); |
| 92 | r = r.with_native(spec, bindings); |
| 93 | if let Some(b) = bytes { r = r.with_bytes(spec, b.clone().into_bytes()); } |
| 94 | } |
| 95 | ModuleDef::Code { code, bytes } => { |
| 96 | r = r.with_code(spec, code); |
| 97 | if let Some(b) = bytes { r = r.with_bytes(spec, b.clone().into_bytes()); } |
| 98 | } |
| 99 | } |
| 100 | /* Auto self-alias bare-name modules so flat fixtures work without explicit `aliases`. */ |
| 101 | if !spec.contains('/') { |
| 102 | r = r.with_alias(spec, spec); |
| 103 | } |
| 104 | } |
| 105 | for (name, target) in aliases { |
| 106 | r = r.with_alias(name, target); |
| 107 | } |
| 108 | for (dir, m) in manifests { |
| 109 | let pairs: Vec<(&str, &str)> = m.imports.iter().map(|(k, v)| (k.as_str(), v.as_str())).collect(); |
| 110 | r = r.with_manifest(dir, &pairs, m.extends.as_deref()); |
| 111 | } |
| 112 | r |
| 113 | } |
| 114 | |
| 115 | /* NoopResolver path: imports must produce a clean diagnostic, not panic. Lives in Rust since the JSON runner always builds a TestResolver. */ |
| 116 | #[test] |
no test coverage detected