put test generation behind a Cargo feature
to reduce build time for the most common case of not running tests
This commit is contained in:
parent
3f723d1141
commit
55294baf7a
23
Cargo.toml
23
Cargo.toml
|
@ -5,8 +5,8 @@ name = "compiler_builtins"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
|
|
||||||
[build-dependencies]
|
[build-dependencies]
|
||||||
cast = "0.2.0"
|
cast = { version = "0.2.0", optional = true }
|
||||||
rand = "0.3.15"
|
rand = { version = "0.3.15", optional = true }
|
||||||
|
|
||||||
[build-dependencies.gcc]
|
[build-dependencies.gcc]
|
||||||
optional = true
|
optional = true
|
||||||
|
@ -18,21 +18,14 @@ compiler-builtins = []
|
||||||
default = ["compiler-builtins"]
|
default = ["compiler-builtins"]
|
||||||
mem = []
|
mem = []
|
||||||
rustbuild = ["compiler-builtins"]
|
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]
|
[workspace]
|
||||||
|
|
2
build.rs
2
build.rs
|
@ -18,6 +18,7 @@ fn main() {
|
||||||
let llvm_target = target.split('-').collect::<Vec<_>>();
|
let llvm_target = target.split('-').collect::<Vec<_>>();
|
||||||
|
|
||||||
// Build test files
|
// Build test files
|
||||||
|
#[cfg(feature = "gen-tests")]
|
||||||
tests::generate();
|
tests::generate();
|
||||||
|
|
||||||
// Build missing intrinsics from compiler-rt C source code
|
// Build missing intrinsics from compiler-rt C source code
|
||||||
|
@ -36,6 +37,7 @@ fn main() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(feature = "gen-tests")]
|
||||||
mod tests {
|
mod tests {
|
||||||
extern crate cast;
|
extern crate cast;
|
||||||
extern crate rand;
|
extern crate rand;
|
||||||
|
|
|
@ -25,16 +25,16 @@ case $1 in
|
||||||
;;
|
;;
|
||||||
esac
|
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-*
|
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-*
|
qemu-arm-static target/${1}/release/$t-*
|
||||||
done
|
done
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
cargo test --no-default-features --target $1
|
cargo test --no-default-features --features gen-tests --target $1
|
||||||
cargo test --no-default-features --target $1 --release
|
cargo test --no-default-features --features gen-tests --target $1 --release
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue