Skip to content

Commit 55294ba

Browse files
author
Jorge Aparicio
committed
put test generation behind a Cargo feature
to reduce build time for the most common case of not running tests
1 parent 3f723d1 commit 55294ba

File tree

3 files changed

+14
-19
lines changed

3 files changed

+14
-19
lines changed

Cargo.toml

+8-15
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ name = "compiler_builtins"
55
version = "0.1.0"
66

77
[build-dependencies]
8-
cast = "0.2.0"
9-
rand = "0.3.15"
8+
cast = { version = "0.2.0", optional = true }
9+
rand = { version = "0.3.15", optional = true }
1010

1111
[build-dependencies.gcc]
1212
optional = true
@@ -18,21 +18,14 @@ compiler-builtins = []
1818
default = ["compiler-builtins"]
1919
mem = []
2020
rustbuild = ["compiler-builtins"]
21+
# generate tests
22+
gen-tests = ["cast", "rand"]
2123

22-
[target]
24+
[target.'cfg(all(target_arch = "arm", not(any(target_env = "gnu", target_env = "musl")), target_os = "linux"))'.dev-dependencies]
25+
test = { git = "https://github.com/japaric/utest" }
26+
utest-cortex-m-qemu = { default-features = false, git = "https://github.com/japaric/utest" }
27+
utest-macros = { git = "https://github.com/japaric/utest" }
2328

24-
[target."cfg(all(target_arch = \"arm\", not(any(target_env = \"gnu\", target_env = \"musl\")), target_os = \"linux\"))"]
2529

26-
[target."cfg(all(target_arch = \"arm\", not(any(target_env = \"gnu\", target_env = \"musl\")), target_os = \"linux\"))".dev-dependencies]
27-
28-
[target."cfg(all(target_arch = \"arm\", not(any(target_env = \"gnu\", target_env = \"musl\")), target_os = \"linux\"))".dev-dependencies.test]
29-
git = "https://github.com/japaric/utest"
30-
31-
[target."cfg(all(target_arch = \"arm\", not(any(target_env = \"gnu\", target_env = \"musl\")), target_os = \"linux\"))".dev-dependencies.utest-cortex-m-qemu]
32-
default-features = false
33-
git = "https://github.com/japaric/utest"
34-
35-
[target."cfg(all(target_arch = \"arm\", not(any(target_env = \"gnu\", target_env = \"musl\")), target_os = \"linux\"))".dev-dependencies.utest-macros]
36-
git = "https://github.com/japaric/utest"
3730

3831
[workspace]

build.rs

+2
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ fn main() {
1818
let llvm_target = target.split('-').collect::<Vec<_>>();
1919

2020
// Build test files
21+
#[cfg(feature = "gen-tests")]
2122
tests::generate();
2223

2324
// Build missing intrinsics from compiler-rt C source code
@@ -36,6 +37,7 @@ fn main() {
3637
}
3738
}
3839

40+
#[cfg(feature = "gen-tests")]
3941
mod tests {
4042
extern crate cast;
4143
extern crate rand;

ci/run.sh

+4-4
Original file line numberDiff line numberDiff line change
@@ -25,16 +25,16 @@ case $1 in
2525
;;
2626
esac
2727

28-
xargo test --test $t --target $1 --features mem --no-run
28+
xargo test --test $t --target $1 --features 'mem gen-tests' --no-run
2929
qemu-arm-static target/${1}/debug/$t-*
3030

31-
xargo test --test $t --target $1 --features mem --no-run --release
31+
xargo test --test $t --target $1 --features 'mem gen-tests' --no-run --release
3232
qemu-arm-static target/${1}/release/$t-*
3333
done
3434
;;
3535
*)
36-
cargo test --no-default-features --target $1
37-
cargo test --no-default-features --target $1 --release
36+
cargo test --no-default-features --features gen-tests --target $1
37+
cargo test --no-default-features --features gen-tests --target $1 --release
3838
;;
3939
esac
4040

0 commit comments

Comments
 (0)