summaryrefslogtreecommitdiffstats
path: root/vendor/escargot/tests/build.rs
blob: d5e03a22a929691178af909d8ffd6ed6a60041fd (plain)
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
63
64
65
66
67
68
69
fn test_fixture(name: &str) {
    let temp = assert_fs::TempDir::new().unwrap();

    let msgs = escargot::CargoBuild::new()
        .manifest_path(format!("tests/fixtures/{}/Cargo.toml", name))
        .current_release()
        .current_target()
        .target_dir(temp.path())
        .exec()
        .unwrap();
    for msg in msgs {
        let raw_msg = msg.unwrap();
        let msg = raw_msg.decode();
        match msg {
            Ok(msg) => println!("{:#?}", msg),
            Err(err) => panic!("{}\nmsg=`{:#?}`", err, raw_msg),
        }
    }
}

#[test]
fn test_bin() {
    test_fixture("bin");
}

#[test]
fn test_lib() {
    test_fixture("lib");
}

#[test]
fn test_bin_lib() {
    test_fixture("bin_lib");
}

#[test]
fn test_warn() {
    test_fixture("warn");
}

#[test]
fn test_build_script() {
    test_fixture("script");
}

#[test]
fn test_dependency() {
    test_fixture("dep");
}

#[test]
fn test_error() {
    let msgs: Vec<_> = escargot::CargoBuild::new()
        .manifest_path("tests/fixtures/error/Cargo.toml")
        .current_release()
        .current_target()
        .exec()
        .unwrap()
        .collect();
    assert!(1 < msgs.len());
    let error_idx = msgs.len() - 1;
    for msg in &msgs[0..error_idx] {
        let msg = msg.as_ref().unwrap();
        let msg = msg.decode().unwrap();
        println!("{:#?}", msg);
    }
    assert!(msgs[error_idx].is_err());
    println!("```{}```", msgs[error_idx].as_ref().err().unwrap());
}