polyhorn_cli/commands/
test.rs1use ansi_term::Colour::Red;
2use clap::Clap;
3use path_absolutize::Absolutize;
4use std::path::Path;
5
6use super::Platform;
7use crate::spec::{Error, Spec};
8
9#[derive(Clap)]
11pub struct Test {
12 #[clap(subcommand)]
13 platform: Platform,
14}
15
16impl Test {
17 pub fn main(&self, manifest_path: &Path) {
20 let spec = match Spec::open(manifest_path) {
21 Ok(spec) => spec,
22 Err(Error::TOML(error)) => {
23 eprintln!(
24 "{}: could not read manifest: {}",
25 Red.bold().paint("error"),
26 error
27 );
28 std::process::abort();
29 }
30 Err(Error::IO(_)) => {
31 eprintln!(
32 "{}: could not find file: {:?}",
33 Red.bold().paint("error"),
34 manifest_path
35 .absolutize_virtually(std::env::current_dir().unwrap())
36 .unwrap(),
37 );
38 std::process::abort();
39 }
40 };
41
42 let manifest_path = std::fs::canonicalize(manifest_path).unwrap();
43
44 let mut manifest_dir = manifest_path.clone();
45 manifest_dir.pop();
46
47 let mut target_dir = manifest_dir.clone();
48 target_dir.push("target");
49
50 let config = crate::Config {
51 manifest_path,
52 manifest_dir,
53 target_dir,
54 spec,
55 };
56
57 match self.platform {
58 Platform::Android => todo!(),
59 Platform::IOS => crate::ios::commands::test(config),
60 }
61 }
62}