Skip to content

Commit

Permalink
Run miri
Browse files Browse the repository at this point in the history
To spare CI resources, only doc tests are run there.
And some non-doc tests are so slow with miri that I don't even want
to run them locally.
  • Loading branch information
tormol committed Aug 6, 2022
1 parent 5644c4e commit 4b4c1c9
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 4 deletions.
6 changes: 5 additions & 1 deletion .cirrus.yml
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ task:
# rustc version is so likely to have changed that build artefacts are not worth caching
setup_script:
- cargo install cargo-fuzz
- rustup component add miri
info_script:
- rustc --version
check_script:
Expand All @@ -81,6 +82,9 @@ task:
- cargo build --benches --all-features
- cargo fuzz build
# fuzz supports feature selection,
# but --no-default-features doesn't seem to have any effect.
# but --no-default-features doesn't seem to have any effect
test_script:
# the doc tets are fast and should cover a lot of code
- cargo miri test --all-features --doc -- --test-threads=1
before_cache_script:
- rm -rf $HOME/.cargo/registry/index
11 changes: 10 additions & 1 deletion do.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ if [[ ${1:0:1} == - || $1 == help ]] || (( $# > 1 )); then
echo "A script to make it easy to check & lint & test everything." >&2
echo "It assumes rustup is installed and that cargo +release works." >&2
echo >&2
echo "Usage: $0 ([setup|MSRV|check|test|ignored|clippy|fuzz|bench|shellcheck|help])" >&2
echo "Usage: $0 ([setup|MSRV|check|test|ignored|clippy|miri|fuzz|bench|shellcheck|help])" >&2
echo "If no argument is provided, all parts except ignored and help are run," >&2
echo "but setup is only done if auto-detection fails." >&2
exit 1
Expand Down Expand Up @@ -55,6 +55,15 @@ if [[ -z $1 || $1 == clippy ]]; then
cargo +nightly clippy --all-features --tests --benches --examples
fi

# miri, nightly
if [[ $1 == setup ]] || ! cargo +nightly help miri >/dev/null 2>/dev/null; then
rustup component add miri --toolchain nightly
cargo +nightly miri setup
fi
if [[ -z $1 || $1 == miri ]]; then
cargo +nightly miri test --all-features -- --quiet
fi

# fuzzing tests, nightly
if [[ $1 == setup ]] || ! command -V cargo-fuzz >/dev/null 2>/dev/null; then
cargo +nightly install cargo-fuzz
Expand Down
8 changes: 6 additions & 2 deletions tests/errs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,9 @@ fn kind<T>(result: Result<T,Utf8Error>) -> Result<T,Utf8ErrorKind> {
}
}

#[test] fn utf16_extra_unit() {
#[test]
#[cfg_attr(miri, ignore)]
fn utf16_extra_unit() {
for c in 0..0x1_00_00 {
assert_eq!( (c as u16).utf16_needs_extra_unit(), match c {
0b_0000_0000_0000_0000..=0b_1101_0111_1111_1111 => Ok(false),
Expand All @@ -80,7 +82,9 @@ fn kind<T>(result: Result<T,Utf8Error>) -> Result<T,Utf8ErrorKind> {
}


#[test] fn from_utf16_tuple() {
#[test]
#[cfg_attr(miri, ignore)]
fn from_utf16_tuple() {
use encode_unicode::error::InvalidUtf16Tuple::*;
for u in 0xdc00..0xe000 {
let close = if u%3==0 {u-100} else {u+100};
Expand Down
1 change: 1 addition & 0 deletions tests/exhaustive.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ fn from_ascii() {
}

#[test]
#[cfg_attr(miri, ignore)]
fn from_bmp() {
for cp in 0u32..0x1_00_00 {
assert_eq!(
Expand Down

0 comments on commit 4b4c1c9

Please sign in to comment.