Skip to content

Commit 427508e

Browse files
committed
Add example assembly test to test-project
1 parent a8db0ae commit 427508e

File tree

3 files changed

+19
-0
lines changed

3 files changed

+19
-0
lines changed

test-project/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,4 @@ features = ["tmp"]
1111

1212
[features]
1313
rustc = ["compiletest_rs/rustc"]
14+
assembly = []

test-project/tests/assembly/panic.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
// assembly-output: emit-asm
2+
// compile-flags: --crate-type rlib
3+
#![no_std]
4+
5+
#[no_mangle]
6+
fn panic_fun() -> u32 {
7+
// CHECK-LABEL: panic_fun:
8+
// CHECK: ud2
9+
panic!();
10+
}

test-project/tests/tests.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
extern crate compiletest_rs as compiletest;
22

3+
use std::env;
34
use std::path::PathBuf;
45

56
fn run_mode(mode: &'static str, custom_dir: Option<&'static str>) {
@@ -11,6 +12,11 @@ fn run_mode(mode: &'static str, custom_dir: Option<&'static str>) {
1112
let dir = custom_dir.unwrap_or(mode);
1213
config.src_base = PathBuf::from(format!("tests/{}", dir));
1314
config.target_rustcflags = Some("-L target/debug -L target/debug/deps".to_string());
15+
config.llvm_filecheck = Some(
16+
env::var("FILECHECK")
17+
.unwrap_or("FileCheck".to_string())
18+
.into(),
19+
);
1420
config.clean_rmeta();
1521

1622
compiletest::run_tests(&config);
@@ -21,6 +27,8 @@ fn compile_test() {
2127
run_mode("compile-fail", None);
2228
run_mode("run-pass", None);
2329
run_mode("ui", None);
30+
#[cfg(feature = "assembly")]
31+
run_mode("assembly", None);
2432

2533
#[cfg(feature = "rustc")]
2634
run_mode("pretty", None);

0 commit comments

Comments
 (0)