Parsers the component located at `path` and creates all information necessary for a `Component` return value.
(&self, path: &Path, kind: Kind, mut bindgen: Bindgen)
| 436 | /// Parsers the component located at `path` and creates all information |
| 437 | /// necessary for a `Component` return value. |
| 438 | fn parse_component(&self, path: &Path, kind: Kind, mut bindgen: Bindgen) -> Result<Component> { |
| 439 | let extension = path |
| 440 | .extension() |
| 441 | .and_then(|s| s.to_str()) |
| 442 | .context("non-utf-8 path extension")?; |
| 443 | |
| 444 | let language = match extension { |
| 445 | "rs" => Language::Rust, |
| 446 | "c" => Language::C, |
| 447 | "cpp" => Language::Cpp, |
| 448 | "wat" => Language::Wat, |
| 449 | "cs" => Language::Csharp, |
| 450 | "mbt" => Language::MoonBit, |
| 451 | "go" => Language::Go, |
| 452 | other => Language::Custom(custom::Language::lookup(self, other)?), |
| 453 | }; |
| 454 | |
| 455 | let contents = fs::read_to_string(&path)?; |
| 456 | let config = match language.obj().comment_prefix_for_test_config() { |
| 457 | Some(comment) => { |
| 458 | config::parse_test_config::<config::RuntimeTestConfig>(&contents, comment)? |
| 459 | } |
| 460 | None => Default::default(), |
| 461 | }; |
| 462 | assert!(bindgen.args.is_empty()); |
| 463 | bindgen.args = config.args.into(); |
| 464 | |
| 465 | Ok(Component { |
| 466 | name: path.file_stem().unwrap().to_str().unwrap().to_string(), |
| 467 | path: path.to_path_buf(), |
| 468 | language, |
| 469 | bindgen, |
| 470 | kind, |
| 471 | contents, |
| 472 | lang_config: config.lang, |
| 473 | wasmtime_flags: config.wasmtime_flags, |
| 474 | }) |
| 475 | } |
| 476 | |
| 477 | /// Prepares all languages in use in `test` as part of a one-time |
| 478 | /// initialization step. |
no test coverage detected