Skip to content

Commit bc0d74c

Browse files
committed
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).
1 parent 09b7ec6 commit bc0d74c

File tree

3 files changed

+19
-0
lines changed

3 files changed

+19
-0
lines changed

README.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,14 @@ This is an overview of what must / can be changed:
4646

4747
- the "package phase". Tweak what goes into the release tarball / zipfile.
4848

49+
### Managing test failures
50+
51+
Some tests will fail when run in the `qemu` emulated environment even though
52+
they succeed on the actual hardware. In this case the `trust_ci` feature flag
53+
has been exposed to the build, test, and run stages. You can therefore disable
54+
some tests by putting `#[cfg_attr(trust_ci, ignore)]` before them. These tests
55+
will show up as 'ignored' in the test output.
56+
4957
### Generate binary releases
5058

5159
You only need to push an **annotated** tag to kick off the build process.

ci/script.sh

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,11 @@ set -ex
44

55
# TODO This is the "test phase", tweak it as you see fit
66
main() {
7+
# Add a cfg spec to allow disabling specific tests under CI.
8+
if [ ! -z $CI ]; then
9+
export RUSTFLAGS=--cfg=trust_ci
10+
fi
11+
712
cross build --target $TARGET
813
cross build --target $TARGET --release
914

src/lib.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,4 +20,10 @@ pub fn hello() {
2020
mod tests {
2121
#[test]
2222
fn it_works() {}
23+
24+
#[test]
25+
#[cfg_attr(trust_ci, ignore)]
26+
fn ignore_in_ci() {
27+
assert!(false);
28+
}
2329
}

0 commit comments

Comments
 (0)