From f6f393996b5d6f0ba010faaa55f41564ceda8dee Mon Sep 17 00:00:00 2001 From: Pascal Hertleif Date: Thu, 14 Apr 2016 12:31:42 +0200 Subject: [PATCH 1/3] Add Compile Test --- tests/compile-test.rs | 37 ++++++++++++++++++++++ {test => tests/run-pass}/arrays.rs | 0 {test => tests/run-pass}/bools.rs | 0 {test => tests/run-pass}/c_enums.rs | 0 {test => tests/run-pass}/calls.rs | 0 {test => tests/run-pass}/closures.rs | 0 {test => tests/run-pass}/errors.rs | 0 {test => tests/run-pass}/heap.rs | 0 {test => tests/run-pass}/ints.rs | 0 {test => tests/run-pass}/loops.rs | 0 {test => tests/run-pass}/pointers.rs | 0 {test => tests/run-pass}/products.rs | 0 {test => tests/run-pass}/specialization.rs | 0 {test => tests/run-pass}/std.rs | 0 {test => tests/run-pass}/strings.rs | 0 {test => tests/run-pass}/sums.rs | 0 {test => tests/run-pass}/trivial.rs | 0 {test => tests/run-pass}/vecs.rs | 0 18 files changed, 37 insertions(+) create mode 100644 tests/compile-test.rs rename {test => tests/run-pass}/arrays.rs (100%) rename {test => tests/run-pass}/bools.rs (100%) rename {test => tests/run-pass}/c_enums.rs (100%) rename {test => tests/run-pass}/calls.rs (100%) rename {test => tests/run-pass}/closures.rs (100%) rename {test => tests/run-pass}/errors.rs (100%) rename {test => tests/run-pass}/heap.rs (100%) rename {test => tests/run-pass}/ints.rs (100%) rename {test => tests/run-pass}/loops.rs (100%) rename {test => tests/run-pass}/pointers.rs (100%) rename {test => tests/run-pass}/products.rs (100%) rename {test => tests/run-pass}/specialization.rs (100%) rename {test => tests/run-pass}/std.rs (100%) rename {test => tests/run-pass}/strings.rs (100%) rename {test => tests/run-pass}/sums.rs (100%) rename {test => tests/run-pass}/trivial.rs (100%) rename {test => tests/run-pass}/vecs.rs (100%) diff --git a/tests/compile-test.rs b/tests/compile-test.rs new file mode 100644 index 0000000000..c7cdb974ca --- /dev/null +++ b/tests/compile-test.rs @@ -0,0 +1,37 @@ +use std::{env, fs}; +use std::process::{Command, Output}; + +fn run_miri(file: &str, sysroot: &str) -> Output { + Command::new("cargo") + .args(&["run", "--", "--sysroot", sysroot, file]) + .output() + .unwrap_or_else(|e| panic!("failed to execute process: {}", e)) +} + +#[test] +fn run_pass() { + let sysroot = env::var("RUST_SYSROOT").expect("env variable `RUST_SYSROOT` not set"); + + let test_files = fs::read_dir("./tests/run-pass/") + .expect("Can't read `run-pass` directory") + .filter_map(|entry| entry.ok()) + .filter(|entry| { + entry.clone() + .file_type() + .map(|x| x.is_file()) + .unwrap_or(false) + }) + .filter_map(|entry| entry.path().to_str().map(|x| x.to_string())); + + for file in test_files { + println!("{}: compile test running", file); + + let test_run = run_miri(&file, &sysroot); + + if test_run.status.code().unwrap_or(-1) != 0 { + println!("{}: error {:?}", file, test_run); + } else { + println!("{}: ok", file); + } + } +} diff --git a/test/arrays.rs b/tests/run-pass/arrays.rs similarity index 100% rename from test/arrays.rs rename to tests/run-pass/arrays.rs diff --git a/test/bools.rs b/tests/run-pass/bools.rs similarity index 100% rename from test/bools.rs rename to tests/run-pass/bools.rs diff --git a/test/c_enums.rs b/tests/run-pass/c_enums.rs similarity index 100% rename from test/c_enums.rs rename to tests/run-pass/c_enums.rs diff --git a/test/calls.rs b/tests/run-pass/calls.rs similarity index 100% rename from test/calls.rs rename to tests/run-pass/calls.rs diff --git a/test/closures.rs b/tests/run-pass/closures.rs similarity index 100% rename from test/closures.rs rename to tests/run-pass/closures.rs diff --git a/test/errors.rs b/tests/run-pass/errors.rs similarity index 100% rename from test/errors.rs rename to tests/run-pass/errors.rs diff --git a/test/heap.rs b/tests/run-pass/heap.rs similarity index 100% rename from test/heap.rs rename to tests/run-pass/heap.rs diff --git a/test/ints.rs b/tests/run-pass/ints.rs similarity index 100% rename from test/ints.rs rename to tests/run-pass/ints.rs diff --git a/test/loops.rs b/tests/run-pass/loops.rs similarity index 100% rename from test/loops.rs rename to tests/run-pass/loops.rs diff --git a/test/pointers.rs b/tests/run-pass/pointers.rs similarity index 100% rename from test/pointers.rs rename to tests/run-pass/pointers.rs diff --git a/test/products.rs b/tests/run-pass/products.rs similarity index 100% rename from test/products.rs rename to tests/run-pass/products.rs diff --git a/test/specialization.rs b/tests/run-pass/specialization.rs similarity index 100% rename from test/specialization.rs rename to tests/run-pass/specialization.rs diff --git a/test/std.rs b/tests/run-pass/std.rs similarity index 100% rename from test/std.rs rename to tests/run-pass/std.rs diff --git a/test/strings.rs b/tests/run-pass/strings.rs similarity index 100% rename from test/strings.rs rename to tests/run-pass/strings.rs diff --git a/test/sums.rs b/tests/run-pass/sums.rs similarity index 100% rename from test/sums.rs rename to tests/run-pass/sums.rs diff --git a/test/trivial.rs b/tests/run-pass/trivial.rs similarity index 100% rename from test/trivial.rs rename to tests/run-pass/trivial.rs diff --git a/test/vecs.rs b/tests/run-pass/vecs.rs similarity index 100% rename from test/vecs.rs rename to tests/run-pass/vecs.rs From 5eb4ab22bf0a85e201a77d659304ef8b10825058 Mon Sep 17 00:00:00 2001 From: Pascal Hertleif Date: Thu, 14 Apr 2016 00:10:20 +0200 Subject: [PATCH 2/3] Add EditorConfig --- .editorconfig | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 .editorconfig diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000000..3c1f41bdcc --- /dev/null +++ b/.editorconfig @@ -0,0 +1,25 @@ +# EditorConfig helps developers define and maintain consistent +# coding styles between different editors and IDEs +# editorconfig.org + +root = true + + +[*] +end_of_line = lf +charset = utf-8 +trim_trailing_whitespace = true +insert_final_newline = true +indent_style = space +indent_size = 4 + +[*.rs] +indent_style = space +indent_size = 4 + +[*.toml] +indent_style = space +indent_size = 4 + +[*.md] +trim_trailing_whitespace = false From 18737f542bc8d5f46b0ac209d99be6cb66a493da Mon Sep 17 00:00:00 2001 From: Pascal Hertleif Date: Thu, 14 Apr 2016 00:10:31 +0200 Subject: [PATCH 3/3] Add Travis Config --- .travis.yml | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 .travis.yml diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000000..8a35c59bfa --- /dev/null +++ b/.travis.yml @@ -0,0 +1,18 @@ +language: rust +rust: +- nightly-2016-04-11 +- nightly +matrix: + allow_failures: + - rust: nightly +before_script: +- | + pip install 'travis-cargo<0.2' --user && + export PATH=$HOME/.local/bin:$PATH +script: +- | + travis-cargo build && + env RUST_SYSROOT=$HOME/rust RUST_TEST_NOCAPTURE=1 travis-cargo test +notifications: + email: + on_success: never