Skip to content

Commit f6f3939

Browse files
committed
Add Compile Test
1 parent 4b9d141 commit f6f3939

18 files changed

+37
-0
lines changed

tests/compile-test.rs

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
use std::{env, fs};
2+
use std::process::{Command, Output};
3+
4+
fn run_miri(file: &str, sysroot: &str) -> Output {
5+
Command::new("cargo")
6+
.args(&["run", "--", "--sysroot", sysroot, file])
7+
.output()
8+
.unwrap_or_else(|e| panic!("failed to execute process: {}", e))
9+
}
10+
11+
#[test]
12+
fn run_pass() {
13+
let sysroot = env::var("RUST_SYSROOT").expect("env variable `RUST_SYSROOT` not set");
14+
15+
let test_files = fs::read_dir("./tests/run-pass/")
16+
.expect("Can't read `run-pass` directory")
17+
.filter_map(|entry| entry.ok())
18+
.filter(|entry| {
19+
entry.clone()
20+
.file_type()
21+
.map(|x| x.is_file())
22+
.unwrap_or(false)
23+
})
24+
.filter_map(|entry| entry.path().to_str().map(|x| x.to_string()));
25+
26+
for file in test_files {
27+
println!("{}: compile test running", file);
28+
29+
let test_run = run_miri(&file, &sysroot);
30+
31+
if test_run.status.code().unwrap_or(-1) != 0 {
32+
println!("{}: error {:?}", file, test_run);
33+
} else {
34+
println!("{}: ok", file);
35+
}
36+
}
37+
}
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)