vdev/commands/integration/test.rs
1use anyhow::Result;
2use clap::Args;
3
4use crate::testing::integration::ComposeTestLocalConfig;
5
6/// Execute integration tests
7///
8/// If an environment is named, it is used to run the test. If the environment was not previously started,
9/// it is started before the test is run and stopped afterwards.
10///
11/// If no environment is named, but one has been started already, that environment is used for the test.
12///
13/// Otherwise, all environments are started, the test run, and then stopped, one by one.
14#[derive(Args, Debug)]
15#[command()]
16pub struct Cli {
17 /// The desired integration
18 integration: String,
19
20 /// The desired environment (optional)
21 environment: Option<String>,
22
23 /// Number of retries to allow on each integration test case.
24 #[arg(short = 'r', long)]
25 retries: Option<u8>,
26
27 /// Collect code coverage using cargo-llvm-cov (outputs target/coverage/lcov.info)
28 #[arg(long)]
29 coverage: bool,
30
31 /// Extra test command arguments
32 args: Vec<String>,
33}
34
35impl Cli {
36 pub fn exec(self) -> Result<()> {
37 crate::commands::compose_tests::test::exec(
38 ComposeTestLocalConfig::integration(),
39 &self.integration,
40 self.environment.as_ref(),
41 self.retries.unwrap_or_default(),
42 &self.args,
43 self.coverage,
44 )
45 }
46}