about summary refs log tree commit diff
path: root/tests/run-make/notify-all-emit-artifacts/rmake.rs
blob: 5896cffefcce47228cd81b099fa4b269822cd68a (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
//@ needs-target-std
//
// rust should produce artifact notifications about files it was asked to --emit.
//
// It should work in incremental mode both on the first pass where files are generated as well
// as on subsequent passes where they are taken from the incremental cache
//
// See <https://internals.rust-lang.org/t/easier-access-to-files-generated-by-emit-foo/20477>
extern crate run_make_support;

use run_make_support::{cwd, rustc};

fn main() {
    // With single codegen unit files are renamed to match the source file name
    for _ in 0..=1 {
        let output = rustc()
            .input("lib.rs")
            .emit("obj,asm,llvm-ir,llvm-bc,mir")
            .codegen_units(1)
            .json("artifacts")
            .error_format("json")
            .incremental(cwd())
            .run();
        let stderr = output.stderr_utf8();
        for file in &["lib.o", "lib.ll", "lib.bc", "lib.s"] {
            assert!(stderr.contains(file), "No {:?} in {:?}", file, stderr);
        }
    }

    // with multiple codegen units files keep codegen unit id part.
    for _ in 0..=1 {
        let output = rustc()
            .input("lib.rs")
            .emit("obj,asm,llvm-ir,llvm-bc,mir")
            .codegen_units(2)
            .json("artifacts")
            .error_format("json")
            .incremental(cwd())
            .run();
        let stderr = output.stderr_utf8();
        for file in &["rcgu.o", "rcgu.ll", "rcgu.bc", "rcgu.s"] {
            assert!(stderr.contains(file), "No {:?} in {:?}", file, stderr);
        }
    }
}