summaryrefslogtreecommitdiffstats
path: root/third_party/rust/gcc/tests/cc_env.rs
blob: 559dbe8ad4e50cf7118bd88b743c79c82d24ceb2 (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
extern crate tempdir;
extern crate gcc;

use std::env;

mod support;
use support::Test;

#[test]
fn main() {
    ccache();
    distcc();
    ccache_spaces();
}

fn ccache() {
    let test = Test::gnu();
    test.shim("ccache");

    env::set_var("CC", "ccache lol-this-is-not-a-compiler foo");
    test.gcc().file("foo.c").compile("libfoo.a");

    test.cmd(0)
        .must_have("lol-this-is-not-a-compiler foo")
        .must_have("foo.c")
        .must_not_have("ccache");
}

fn ccache_spaces() {
    let test = Test::gnu();
    test.shim("ccache");

    env::set_var("CC", "ccache        lol-this-is-not-a-compiler foo");
    test.gcc().file("foo.c").compile("libfoo.a");
    test.cmd(0).must_have("lol-this-is-not-a-compiler foo");
}

fn distcc() {
    let test = Test::gnu();
    test.shim("distcc");

    env::set_var("CC", "distcc lol-this-is-not-a-compiler foo");
    test.gcc().file("foo.c").compile("libfoo.a");

    test.cmd(0)
        .must_have("lol-this-is-not-a-compiler foo")
        .must_have("foo.c")
        .must_not_have("distcc");
}