flowey_lib_hvlite/_jobs/
build_and_run_doc_tests.rs1use crate::common::{CommonArch, CommonProfile};
10use flowey::node::prelude::*;
11
12flowey_request! {
13 pub struct Params {
14 pub target: target_lexicon::Triple,
16 pub profile: CommonProfile,
18 pub done: WriteVar<SideEffect>,
19 }
20}
21
22new_simple_flow_node!(struct Node);
23
24impl SimpleFlowNode for Node {
25 type Request = Params;
26
27 fn imports(ctx: &mut ImportCtx<'_>) {
28 ctx.import::<crate::git_checkout_openvmm_repo::Node>();
29 ctx.import::<crate::init_openvmm_magicpath_openhcl_sysroot::Node>();
30 ctx.import::<crate::install_openvmm_rust_build_essential::Node>();
31 }
32
33 fn process_request(request: Self::Request, ctx: &mut NodeCtx<'_>) -> anyhow::Result<()> {
34 let Params {
35 target,
36 profile,
37 done,
38 } = request;
39
40 let rust_installed = ctx.reqv(crate::install_openvmm_rust_build_essential::Request);
41 let openvmm_repo_path = ctx.reqv(crate::git_checkout_openvmm_repo::req::GetRepoDir);
42 let sysroot_ready = if matches!(target.environment, target_lexicon::Environment::Musl) {
43 let arch = CommonArch::from_architecture(target.architecture)?;
44 Some(
45 ctx.reqv(|v| crate::init_openvmm_magicpath_openhcl_sysroot::Request {
46 arch,
47 path: v,
48 })
49 .into_side_effect(),
50 )
51 } else {
52 None
53 };
54
55 ctx.emit_rust_step(format!("run doctests for {target}"), |ctx| {
56 done.claim(ctx);
57 rust_installed.claim(ctx);
58 if let Some(sysroot_ready) = sysroot_ready {
59 sysroot_ready.claim(ctx);
60 }
61 let openvmm_repo_path = openvmm_repo_path.claim(ctx);
62 move |rt| {
63 let mut extra_args = Vec::new();
64 if matches!(
66 target.operating_system,
67 target_lexicon::OperatingSystem::Windows
68 | target_lexicon::OperatingSystem::Darwin(_)
69 ) {
70 extra_args.extend(["--exclude", "vtpm_util"]);
71 }
72
73 let target = target.to_string();
74 let profile = match profile {
75 CommonProfile::Release => "release",
76 CommonProfile::Debug => "dev",
77 };
78
79 let path = rt.read(openvmm_repo_path);
80 rt.sh.change_dir(path);
81 flowey::shell_cmd!(rt, "cargo test --locked --doc --workspace --no-fail-fast --target {target} --profile {profile} {extra_args...}").run()?;
82
83 Ok(())
84 }
85 });
86
87 Ok(())
88 }
89}