Skip to main content

flowey_lib_hvlite/
test_nextest_vmm_tests_archive.rs

1// Copyright (c) Microsoft Corporation.
2// Licensed under the MIT License.
3
4//! Run cargo-nextest based VMM tests from a pre-built archive.
5//!
6//! NOTE: The caller is responsible for setting `extra_env` and
7//! `pre_run_deps` to ensure that all tests filtered by
8//! `nextest_filter_expr` are able to run successfully.
9
10use crate::build_nextest_vmm_tests::NextestVmmTestsArchive;
11use crate::run_cargo_nextest_run::NextestProfile;
12use flowey::node::prelude::*;
13use flowey_lib_common::run_cargo_nextest_run::TestResults;
14use std::collections::BTreeMap;
15
16flowey_request! {
17    pub struct Request {
18        /// Pre-built VMM tests nextest archive
19        pub nextest_archive_file: ReadVar<NextestVmmTestsArchive>,
20        /// nextest filter expression for what VMM tests to run
21        pub nextest_filter_expr: Option<String>,
22        /// Nextest profile to use when running the source code
23        pub nextest_profile: NextestProfile,
24        /// Nextest working directory (defaults to repo root)
25        pub nextest_working_dir: Option<ReadVar<PathBuf>>,
26        /// Nextest configuration file (defaults to config in repo)
27        pub nextest_config_file: Option<ReadVar<PathBuf>>,
28        /// Optionally provide the nextest bin to use
29        pub nextest_bin: Option<ReadVar<PathBuf>>,
30        /// Target for the tests to run on
31        pub target: Option<target_lexicon::Triple>,
32        /// Additional env vars set when executing the tests.
33        pub extra_env: ReadVar<BTreeMap<String, String>>,
34        /// Wait for specified side-effects to resolve before building / running
35        /// any tests. (e.g: to allow for some ambient packages / dependencies
36        /// to get installed).
37        pub pre_run_deps: Vec<ReadVar<SideEffect>>,
38        /// Results of running the tests
39        pub results: WriteVar<TestResults>,
40    }
41}
42
43new_simple_flow_node!(struct Node);
44
45impl SimpleFlowNode for Node {
46    type Request = Request;
47
48    fn imports(ctx: &mut ImportCtx<'_>) {
49        ctx.import::<crate::run_cargo_nextest_run::Node>();
50    }
51
52    fn process_request(request: Self::Request, ctx: &mut NodeCtx<'_>) -> anyhow::Result<()> {
53        let Request {
54            nextest_archive_file,
55            nextest_filter_expr,
56            nextest_profile,
57            nextest_working_dir,
58            nextest_config_file,
59            nextest_bin,
60            target,
61            extra_env,
62            pre_run_deps,
63            results,
64        } = request;
65
66        let nextest_archive = nextest_archive_file.map(ctx, |x| x.archive_file);
67
68        ctx.req(crate::run_cargo_nextest_run::Request {
69            friendly_name: "vmm_tests".into(),
70            run_kind: flowey_lib_common::run_cargo_nextest_run::NextestRunKind::RunFromArchive {
71                archive_file: nextest_archive,
72                target,
73                nextest_bin,
74            },
75            nextest_profile,
76            nextest_filter_expr,
77            nextest_working_dir,
78            nextest_config_file,
79            run_ignored: false,
80            extra_env: Some(extra_env),
81            pre_run_deps,
82            results,
83        });
84
85        Ok(())
86    }
87}