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
use clap;

use crate::config::SimiConfig;
use crate::error::*;
use crate::external_cmds as cmds;

pub struct TestArgs {
    pub with_head: bool,
    pub nightly: bool,
}

impl TestArgs {
    pub fn from_clap<'a>(matches: &clap::ArgMatches<'a>) -> Self {
        Self {
            with_head: matches.is_present("with_head"),
            nightly: !matches.is_present("stable"),
        }
    }
}

pub fn run(args: TestArgs) -> Result<(), Error> {
    let config = SimiConfig::for_test(args)?;
    if config.has_browser_driver() == false {
        return Err(format_err!("You must specify at least one browser driver in `simi.toml` (at the same place as `Cargo.toml`)"));
    }
    //let nightly = true;
    //cmds::cargo_build(config.release(), nightly, config.target())?;
    for driver_path in config.browser_drivers() {
        println!("Test with {}", driver_path);
        cmds::cargo_test(&config, driver_path)?;
    }
    Ok(())
}