put test generation behind a Cargo feature

to reduce build time for the most common case of not running tests
master
Jorge Aparicio 2017-04-10 17:27:25 -05:00
parent 3f723d1141
commit 55294baf7a
3 changed files with 14 additions and 19 deletions

View File

@ -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]

View File

@ -18,6 +18,7 @@ fn main() {
let llvm_target = target.split('-').collect::<Vec<_>>();
// 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;

View File

@ -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