Skip to content

Commit

Permalink
Add tests for --emit=* + --json=artifacts
Browse files Browse the repository at this point in the history
  • Loading branch information
pacak committed Mar 31, 2024
1 parent 0ae288a commit ee64861
Show file tree
Hide file tree
Showing 2 changed files with 60 additions and 0 deletions.
23 changes: 23 additions & 0 deletions tests/run-make/emit-notify/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
//@ compile-flags: -C codegen-units=1 --emit asm,llvm-ir,llvm-bc,obj --json=artifacts --error-format=json

fn one() -> usize {
1
}

pub mod a {
pub fn two() -> usize {
::one() + ::one()
}
}

pub mod b {
pub fn three() -> usize {
::one() + ::a::two()
}
}

#[inline(never)]
pub fn main() {
a::two();
b::three();
}
37 changes: 37 additions & 0 deletions tests/run-make/emit-notify/rmake.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
extern crate run_make_support;

use run_make_support::{rustc, tmp_dir, ErrorFormat};

fn main() {
let inc_dir = tmp_dir();

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(ErrorFormat::Json)
.incremental(&inc_dir)
.run();
let stderr = String::from_utf8_lossy(&output.stderr);
for file in &["lib.o", "lib.ll", "lib.bc", "lib.s"] {
assert!(stderr.contains(file), "No {:?} in {:?}", file, stderr);
}
}

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(ErrorFormat::Json)
.incremental(&inc_dir)
.run();
let stderr = String::from_utf8_lossy(&output.stderr);
for file in &["rcgu.o", "rcgu.ll", "rcgu.bc", "rcgu.s"] {
assert!(stderr.contains(file), "No {:?} in {:?}", file, stderr);
}
}
}

0 comments on commit ee64861

Please sign in to comment.