From 9c0fe5be3daf5102ad857ff81df5e660ae6666bb Mon Sep 17 00:00:00 2001 From: Jorge Aparicio Date: Mon, 10 Apr 2017 17:27:25 -0500 Subject: [PATCH] put test generation behind a Cargo feature to reduce build time for the most common case of not running tests --- library/compiler-builtins/Cargo.toml | 23 ++++++++--------------- library/compiler-builtins/build.rs | 2 ++ library/compiler-builtins/ci/run.sh | 8 ++++---- 3 files changed, 14 insertions(+), 19 deletions(-) diff --git a/library/compiler-builtins/Cargo.toml b/library/compiler-builtins/Cargo.toml index 2aefba8bc3f6..59f6b404abdd 100644 --- a/library/compiler-builtins/Cargo.toml +++ b/library/compiler-builtins/Cargo.toml @@ -5,8 +5,8 @@ name = "compiler_builtins" version = "0.1.0" [build-dependencies] -cast = "0.2.0" -rand = "0.3.15" +cast = { version = "0.2.0", optional = true } +rand = { version = "0.3.15", optional = true } [build-dependencies.gcc] optional = true @@ -18,21 +18,14 @@ compiler-builtins = [] default = ["compiler-builtins"] mem = [] rustbuild = ["compiler-builtins"] +# generate tests +gen-tests = ["cast", "rand"] -[target] +[target.'cfg(all(target_arch = "arm", not(any(target_env = "gnu", target_env = "musl")), target_os = "linux"))'.dev-dependencies] +test = { git = "https://github.com/japaric/utest" } +utest-cortex-m-qemu = { default-features = false, git = "https://github.com/japaric/utest" } +utest-macros = { git = "https://github.com/japaric/utest" } -[target."cfg(all(target_arch = \"arm\", not(any(target_env = \"gnu\", target_env = \"musl\")), target_os = \"linux\"))"] -[target."cfg(all(target_arch = \"arm\", not(any(target_env = \"gnu\", target_env = \"musl\")), target_os = \"linux\"))".dev-dependencies] - -[target."cfg(all(target_arch = \"arm\", not(any(target_env = \"gnu\", target_env = \"musl\")), target_os = \"linux\"))".dev-dependencies.test] -git = "https://github.com/japaric/utest" - -[target."cfg(all(target_arch = \"arm\", not(any(target_env = \"gnu\", target_env = \"musl\")), target_os = \"linux\"))".dev-dependencies.utest-cortex-m-qemu] -default-features = false -git = "https://github.com/japaric/utest" - -[target."cfg(all(target_arch = \"arm\", not(any(target_env = \"gnu\", target_env = \"musl\")), target_os = \"linux\"))".dev-dependencies.utest-macros] -git = "https://github.com/japaric/utest" [workspace] diff --git a/library/compiler-builtins/build.rs b/library/compiler-builtins/build.rs index 2c8cff7295c7..ac75e6ede881 100644 --- a/library/compiler-builtins/build.rs +++ b/library/compiler-builtins/build.rs @@ -18,6 +18,7 @@ fn main() { let llvm_target = target.split('-').collect::>(); // Build test files + #[cfg(feature = "gen-tests")] tests::generate(); // Build missing intrinsics from compiler-rt C source code @@ -36,6 +37,7 @@ fn main() { } } +#[cfg(feature = "gen-tests")] mod tests { extern crate cast; extern crate rand; diff --git a/library/compiler-builtins/ci/run.sh b/library/compiler-builtins/ci/run.sh index 17c54ef04279..771f8812a029 100755 --- a/library/compiler-builtins/ci/run.sh +++ b/library/compiler-builtins/ci/run.sh @@ -25,16 +25,16 @@ case $1 in ;; esac - xargo test --test $t --target $1 --features mem --no-run + xargo test --test $t --target $1 --features 'mem gen-tests' --no-run qemu-arm-static target/${1}/debug/$t-* - xargo test --test $t --target $1 --features mem --no-run --release + xargo test --test $t --target $1 --features 'mem gen-tests' --no-run --release qemu-arm-static target/${1}/release/$t-* done ;; *) - cargo test --no-default-features --target $1 - cargo test --no-default-features --target $1 --release + cargo test --no-default-features --features gen-tests --target $1 + cargo test --no-default-features --features gen-tests --target $1 --release ;; esac