crate_compile_test/
config.rs

1use std::path::{Path, PathBuf};
2
3use steps::TestStepFactory;
4
5#[derive(PartialEq)]
6pub enum Mode {
7    BuildFail,
8    BuildSuccess,
9    Expand,
10}
11
12#[derive(PartialEq)]
13pub enum Profile {
14    Debug,
15    Release,
16}
17
18pub struct Config {
19    pub mode: Mode,
20
21    pub base_dir: PathBuf,
22    pub target: Option<String>,
23    pub profile: Profile,
24
25    pub cargo_env: Vec<(String, String)>,
26    pub cargo_command: String,
27
28    pub crates_filter: Box<Fn(&Path) -> bool>,
29    pub additional_steps: Vec<Box<TestStepFactory>>,
30}
31
32impl Config {
33    pub fn new<P: AsRef<Path>>(mode: Mode, base_dir: P) -> Self {
34        Config {
35            mode,
36
37            base_dir: base_dir.as_ref().into(),
38            target: None,
39            profile: Profile::Release,
40
41            cargo_env: vec![],
42            cargo_command: "cargo".into(),
43
44            crates_filter: Box::new(|_| true),
45            additional_steps: vec![],
46        }
47    }
48
49    pub fn add_cargo_env<S: Into<String>>(&mut self, key: S, value: S) {
50        self.cargo_env.push((key.into(), value.into()));
51    }
52}