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 ansi_term::Colour::Red;
use clap::Clap;
use path_absolutize::Absolutize;
use std::path::Path;
use super::Platform;
use crate::spec::{Error, Spec};
#[derive(Clap)]
pub struct Test {
#[clap(subcommand)]
platform: Platform,
}
impl Test {
pub fn main(&self, manifest_path: &Path) {
let spec = match Spec::open(manifest_path) {
Ok(spec) => spec,
Err(Error::TOML(error)) => {
eprintln!(
"{}: could not read manifest: {}",
Red.bold().paint("error"),
error
);
std::process::abort();
}
Err(Error::IO(_)) => {
eprintln!(
"{}: could not find file: {:?}",
Red.bold().paint("error"),
manifest_path
.absolutize_virtually(std::env::current_dir().unwrap())
.unwrap(),
);
std::process::abort();
}
};
let manifest_path = std::fs::canonicalize(manifest_path).unwrap();
let mut manifest_dir = manifest_path.clone();
manifest_dir.pop();
let mut target_dir = manifest_dir.clone();
target_dir.push("target");
let config = crate::Config {
manifest_path,
manifest_dir,
target_dir,
spec,
};
match self.platform {
Platform::Android => todo!(),
Platform::IOS => crate::ios::commands::test(config),
}
}
}