Skip to main content

host_example/
host_example.rs

1// SPDX-License-Identifier: MIT
2
3use observer_rust_lib::{collect_tests, describe, expect, observer_host_main, test};
4
5fn main() {
6    let tests = collect_tests(|| {
7        describe!("pkg", {
8            test!("smoke test", id = "pkg::smoke", |ctx| {
9                ctx.stdout("ok\n");
10                expect(true).to_be_truthy();
11            });
12
13            test!("failing test", id = "pkg::fail", |ctx| {
14                ctx.stderr("failure\n");
15                ctx.set_exit(1);
16            });
17        });
18    })
19    .expect("collection should validate");
20
21    let exit_code = match observer_host_main("rust", &tests) {
22        Ok(()) => 0,
23        Err(error) => {
24            eprintln!("{error}");
25            2
26        }
27    };
28    std::process::exit(exit_code);
29}