Skip to main content

observer_host_dispatch_embedded

Function observer_host_dispatch_embedded 

Source
pub fn observer_host_dispatch_embedded<I, S>(
    provider: &str,
    root_command: &str,
    tests: &[TestRegistration],
    argv: I,
) -> Result<()>
where I: IntoIterator<Item = S>, S: Into<String>,
Examples found in repository?
examples/host_embed_example.rs (line 22)
9fn main() {
10    let tests = collect_tests(|| {
11        describe!("pkg", {
12            test!("embedded smoke test", id = "pkg::embedded-smoke", |ctx| {
13                ctx.stdout("ok\n");
14                expect(true).to_be_truthy();
15            });
16        });
17    })
18    .expect("collection should validate");
19
20    let args = std::env::args().collect::<Vec<_>>();
21    if args.get(1).map(String::as_str) == Some("observe") {
22        let exit_code = match observer_host_dispatch_embedded("rust", "observe", &tests, args) {
23            Ok(()) => 0,
24            Err(error) => {
25                eprintln!("{error}");
26                2
27            }
28        };
29        std::process::exit(exit_code);
30    }
31
32    app_main(&args);
33}