about summary refs log tree commit diff
path: root/users/glittershark/achilles/tests/compile.rs
blob: 7fa15ad9653ede1a54912c7221375a1d5e6ea122 (plain) (blame)
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
use std::process::Command;

use crate_root::root;

const FIXTURES: &[(&str, i32)] = &[("simple", 5), ("functions", 9)];

#[test]
fn compile_and_run_files() {
    let ach = root().unwrap().join("ach");

    println!("Running: `make clean`");
    assert!(
        Command::new("make")
            .arg("clean")
            .current_dir(&ach)
            .spawn()
            .unwrap()
            .wait()
            .unwrap()
            .success(),
        "make clean failed"
    );

    for (fixture, exit_code) in FIXTURES {
        println!(">>> Testing: {}", fixture);

        println!("    Running: `make {}`", fixture);
        assert!(
            Command::new("make")
                .arg(fixture)
                .current_dir(&ach)
                .spawn()
                .unwrap()
                .wait()
                .unwrap()
                .success(),
            "make failed"
        );

        let out_path = ach.join(fixture);
        println!("    Running: `{}`", out_path.to_str().unwrap());
        assert_eq!(
            Command::new(out_path)
                .spawn()
                .unwrap()
                .wait()
                .unwrap()
                .code()
                .unwrap(),
            *exit_code,
        );
        println!("    OK");
    }
}