From 50fef2d851045f0f6c62c3409b68a2b102ff0fe7 Mon Sep 17 00:00:00 2001 From: Carl Dong Date: Thu, 24 Jan 2019 11:37:55 -0500 Subject: [PATCH] Extract travis testing into locally-runnable script --- .travis.yml | 26 ++++++++++---------------- contrib/test.sh | 34 ++++++++++++++++++++++++++++++++++ 2 files changed, 44 insertions(+), 16 deletions(-) create mode 100755 contrib/test.sh diff --git a/.travis.yml b/.travis.yml index 6300003a..edc000f7 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,22 +1,16 @@ language: rust -rust: - - stable - - beta - - nightly - - 1.22.0 - before_install: - sudo apt-get -qq update - sudo apt-get install -y binutils-dev libunwind8-dev +matrix: + include: + - rust: stable + env: DO_FUZZ=true + - rust: beta + - rust: nightly + env: DO_BENCH=true + - rust: 1.22.0 + script: - - cargo build --verbose - - cargo test --verbose - - cargo build --verbose --features=bitcoinconsensus - - cargo test --verbose --features=bitcoinconsensus - - cargo build --verbose --features=use-serde - - cargo test --verbose --features=use-serde - - cargo build --verbose --features=serde-decimal - - cargo test --verbose --features=serde-decimal - - if [ "$(rustup show | grep default | grep stable)" != "" ]; then cd fuzz && cargo test --verbose && ./travis-fuzz.sh; fi - - if [ "$(rustup show | grep default | grep nightly)" != "" ]; then cargo bench --features unstable; fi + - ./contrib/test.sh diff --git a/contrib/test.sh b/contrib/test.sh new file mode 100755 index 00000000..bdab1848 --- /dev/null +++ b/contrib/test.sh @@ -0,0 +1,34 @@ +#!/bin/sh -ex + +FEATURES="bitcoinconsensus use-serde serde-decimal" + +# Use toolchain if explicitly specified +if [ -n "$TOOLCHAIN" ] +then + alias cargo="cargo +$TOOLCHAIN" +fi + +# Test without any features first +cargo test --verbose + +# Test each feature +for feature in ${FEATURES} +do + cargo test --verbose --features="$feature" +done + +# Fuzz if told to +if [ "$DO_FUZZ" = true ] +then + ( + cd fuzz + cargo test --verbose + ./travis-fuzz.sh + ) +fi + +# Bench if told to +if [ "$DO_BENCH" = true ] +then + cargo bench --features unstable +fi