sagiegurari / cargo-make
1
use super::*;
2
use crate::test;
3
use envmnt;
4

5
#[test]
6
#[should_panic]
7 8
fn wrap_command_invalid_toolchain() {
8 8
    if test::is_not_rust_stable() {
9 4
        wrap_command("invalid-chain", "true", &None);
10
    } else {
11 4
        panic!("test");
12
    }
13 0
}
14

15
#[test]
16 8
fn wrap_command_none_args() {
17 8
    let channel = envmnt::get_or_panic("CARGO_MAKE_RUST_CHANNEL");
18 8
    let output = wrap_command(&channel, "true", &None);
19

20 8
    assert_eq!(output.command, "rustup".to_string());
21

22 8
    let args = output.args.unwrap();
23 8
    assert_eq!(args.len(), 3);
24 8
    assert_eq!(args[0], "run".to_string());
25 8
    assert_eq!(args[1], channel);
26 8
    assert_eq!(args[2], "true".to_string());
27 8
}
28

29
#[test]
30 8
fn wrap_command_empty_args() {
31 8
    let channel = envmnt::get_or_panic("CARGO_MAKE_RUST_CHANNEL");
32 8
    let output = wrap_command(&channel, "true", &Some(vec![]));
33

34 8
    assert_eq!(output.command, "rustup".to_string());
35

36 8
    let args = output.args.unwrap();
37 8
    assert_eq!(args.len(), 3);
38 8
    assert_eq!(args[0], "run".to_string());
39 8
    assert_eq!(args[1], channel);
40 8
    assert_eq!(args[2], "true".to_string());
41 8
}
42

43
#[test]
44 8
fn wrap_command_with_args() {
45 8
    let channel = envmnt::get_or_panic("CARGO_MAKE_RUST_CHANNEL");
46 8
    let output = wrap_command(
47 8
        &channel,
48
        "true",
49 8
        &Some(vec!["echo".to_string(), "test".to_string()]),
50 2
    );
51

52 8
    assert_eq!(output.command, "rustup".to_string());
53

54 8
    let args = output.args.unwrap();
55 8
    assert_eq!(args.len(), 5);
56 8
    assert_eq!(args[0], "run".to_string());
57 8
    assert_eq!(args[1], channel);
58 8
    assert_eq!(args[2], "true".to_string());
59 8
    assert_eq!(args[3], "echo".to_string());
60 8
    assert_eq!(args[4], "test".to_string());
61 8
}

Read our documentation on viewing source code .

Loading