From 7dcf4a8a64b60bed8aadace0a981aa442220e730 Mon Sep 17 00:00:00 2001 From: Bryant Mairs Date: Tue, 18 Apr 2017 13:02:19 -0700 Subject: [PATCH] Expose 'trust_ci' as a feature flag under CI $CI was chosen instead of $TRAVIS and the ! -z check was done such that this can work on all CI platforms (at least GitLab CI, Travis CI, AppVeyor, and Circle CI). --- .travis.yml | 5 +++++ README.md | 8 ++++++++ ci/script.sh | 5 +++++ src/lib.rs | 6 ++++++ 4 files changed, 24 insertions(+) diff --git a/.travis.yml b/.travis.yml index f10e730..ee8a013 100644 --- a/.travis.yml +++ b/.travis.yml @@ -11,6 +11,11 @@ sudo: required env: global: + # TODO Change this to passthrough additional environment variables. Additional items + # can be appended with a space as a delimiter. The default of "RUSTFLAGS" allows the + # "trust_ci" feature to be passed-through to be compiled by Rust. See the Cross + # README for more details. + - CROSS_BUILD_ENV_PASSTHROUGH=RUSTFLAGS # TODO Update this to match the name of your project. - CRATE_NAME=trust diff --git a/README.md b/README.md index aa1bd68..8ba5a7d 100644 --- a/README.md +++ b/README.md @@ -46,6 +46,14 @@ This is an overview of what must / can be changed: - the "package phase". Tweak what goes into the release tarball / zipfile. +### Managing test failures + +Some tests will fail when run in the `qemu` emulated environment even though +they succeed on the actual hardware. In this case the `trust_ci` feature flag +has been exposed to the build, test, and run stages. You can therefore disable +some tests by putting `#[cfg_attr(trust_ci, ignore)]` before them. These tests +will show up as 'ignored' in the test output. + ### Generate binary releases You only need to push an **annotated** tag to kick off the build process. diff --git a/ci/script.sh b/ci/script.sh index ddd7f93..36d3d16 100644 --- a/ci/script.sh +++ b/ci/script.sh @@ -4,6 +4,11 @@ set -ex # TODO This is the "test phase", tweak it as you see fit main() { + # Add a cfg spec to allow disabling specific tests under CI. + if [ ! -z $CI ]; then + export RUSTFLAGS+=" --cfg=trust_ci" + fi + cross build --target $TARGET cross build --target $TARGET --release diff --git a/src/lib.rs b/src/lib.rs index 3bb7ab7..fe37643 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -20,4 +20,10 @@ pub fn hello() { mod tests { #[test] fn it_works() {} + + #[test] + #[cfg_attr(trust_ci, ignore)] + fn ignore_in_ci() { + assert!(false); + } }