Skip to content

Commit cea1ff4

Browse files
committed
Merge pull request #3 from killercup/feature/tests
Run Tests on Travis
2 parents 926bbba + 18737f5 commit cea1ff4

20 files changed

+80
-0
lines changed

.editorconfig

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# EditorConfig helps developers define and maintain consistent
2+
# coding styles between different editors and IDEs
3+
# editorconfig.org
4+
5+
root = true
6+
7+
8+
[*]
9+
end_of_line = lf
10+
charset = utf-8
11+
trim_trailing_whitespace = true
12+
insert_final_newline = true
13+
indent_style = space
14+
indent_size = 4
15+
16+
[*.rs]
17+
indent_style = space
18+
indent_size = 4
19+
20+
[*.toml]
21+
indent_style = space
22+
indent_size = 4
23+
24+
[*.md]
25+
trim_trailing_whitespace = false

.travis.yml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
language: rust
2+
rust:
3+
- nightly-2016-04-11
4+
- nightly
5+
matrix:
6+
allow_failures:
7+
- rust: nightly
8+
before_script:
9+
- |
10+
pip install 'travis-cargo<0.2' --user &&
11+
export PATH=$HOME/.local/bin:$PATH
12+
script:
13+
- |
14+
travis-cargo build &&
15+
env RUST_SYSROOT=$HOME/rust RUST_TEST_NOCAPTURE=1 travis-cargo test
16+
notifications:
17+
email:
18+
on_success: never

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.

0 commit comments

Comments
 (0)