1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
use super::{handle_build_cmd, handle_deploy_cmd, handle_simulate_cmd, Error};
use config::{BuildCmd, DeployCmd, SimulateCmd, TestCmd, TestSubCmd};
use new_cmd::generate_tests_source_files;
pub fn handle_test_cmd(test_cmd: &TestCmd) -> Result<(), Error> {
match test_cmd.subcmd {
Some(ref subcmd) => match subcmd {
TestSubCmd::Build => {
generate_tests_source_files(test_cmd.cargo_manifest_path.parent())?;
run_test_build(test_cmd)?;
}
TestSubCmd::Simulate => run_test_simulation(test_cmd)?,
TestSubCmd::Deploy => run_test_deployment(test_cmd)?,
},
None => {
generate_tests_source_files(test_cmd.cargo_manifest_path.parent())?;
run_test_build(test_cmd)?;
run_test_simulation(test_cmd)?
}
};
Ok(())
}
fn run_test_build(test_cmd: &TestCmd) -> Result<(), Error> {
let build_cmd = BuildCmd {
loudness: test_cmd.loudness.clone(),
release: test_cmd.release,
tests: true,
cargo_manifest_path: test_cmd.cargo_manifest_path.clone(),
};
handle_build_cmd(&build_cmd)?;
Ok(())
}
fn run_test_simulation(test_cmd: &TestCmd) -> Result<(), Error> {
let sim_cmd = SimulateCmd {
loudness: test_cmd.loudness.clone(),
release: test_cmd.release,
tests: true,
cargo_manifest_path: test_cmd.cargo_manifest_path.clone(),
};
handle_simulate_cmd(&sim_cmd)?;
Ok(())
}
fn run_test_deployment(test_cmd: &TestCmd) -> Result<(), Error> {
let deploy_cmd = DeployCmd {
loudness: test_cmd.loudness.clone(),
release: test_cmd.release,
tests: true,
cargo_manifest_path: test_cmd.cargo_manifest_path.clone(),
};
handle_deploy_cmd(&deploy_cmd)?;
Ok(())
}