2017-02-24 16:58:21 +00:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
# This is the script that's executed by travis, you can run it yourself to run
|
|
|
|
# the exact same suite
|
|
|
|
|
|
|
|
set -e
|
|
|
|
|
|
|
|
DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
|
|
|
2019-09-16 00:44:37 +00:00
|
|
|
|
|
|
|
main() {
|
|
|
|
if [[ -n $CHANNEL ]] ; then
|
|
|
|
if [[ $CHANNEL == 1.13.0 ]]; then
|
|
|
|
banner "Building $CHANNEL"
|
|
|
|
build_only
|
|
|
|
else
|
|
|
|
banner "Building/testing $CHANNEL"
|
|
|
|
#build_and_test
|
|
|
|
banner "Testing Core $CHANNEL"
|
|
|
|
build_core_test
|
|
|
|
fi
|
|
|
|
else
|
|
|
|
CHANNEL=nightly
|
|
|
|
matching_banner "Test $CHANNEL"
|
|
|
|
if [ "x${CLIPPY}" = xy ] ; then
|
|
|
|
run_clippy
|
|
|
|
else
|
|
|
|
build_and_test
|
|
|
|
fi
|
|
|
|
|
|
|
|
CHANNEL=beta
|
|
|
|
matching_banner "Test $CHANNEL"
|
|
|
|
build_and_test
|
|
|
|
|
|
|
|
CHANNEL=stable
|
|
|
|
matching_banner "Test $CHANNEL"
|
|
|
|
build_and_test
|
|
|
|
build_core_test
|
|
|
|
|
|
|
|
CHANNEL=1.13.0
|
|
|
|
matching_banner "Test $CHANNEL"
|
|
|
|
build_only
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2017-02-24 16:58:21 +00:00
|
|
|
channel() {
|
2019-09-13 19:24:28 +00:00
|
|
|
channel_run cargo "$@"
|
|
|
|
}
|
|
|
|
|
|
|
|
channel_run() {
|
2019-09-16 00:44:37 +00:00
|
|
|
if channel_matches ; then
|
|
|
|
pwd
|
|
|
|
local the_cmd="$ $*"
|
|
|
|
echo "$the_cmd"
|
|
|
|
"$@"
|
2017-02-24 16:58:21 +00:00
|
|
|
else
|
|
|
|
pwd
|
2019-09-13 19:24:28 +00:00
|
|
|
local cmd="$1"
|
|
|
|
shift
|
2019-09-16 00:44:37 +00:00
|
|
|
if [[ $cmd == cargo || $cmd == rustc ]] ; then
|
|
|
|
underline "$ $cmd +${CHANNEL} $*"
|
2019-09-13 19:24:28 +00:00
|
|
|
"$cmd" "+${CHANNEL}" "$@"
|
2019-09-16 00:44:37 +00:00
|
|
|
|
2019-09-13 19:24:28 +00:00
|
|
|
else
|
2019-09-16 00:44:37 +00:00
|
|
|
underline "$ $cmd $*"
|
2019-09-13 19:24:28 +00:00
|
|
|
"$cmd" "$@"
|
|
|
|
fi
|
2017-02-24 16:58:21 +00:00
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2019-09-16 00:44:37 +00:00
|
|
|
channel_matches() {
|
|
|
|
if [ -n "${TRAVIS}" ]; then
|
|
|
|
if [ "${TRAVIS_RUST_VERSION}" = "${CHANNEL}" ]; then
|
|
|
|
return 0
|
|
|
|
fi
|
|
|
|
elif [ -n "${APPVEYOR}" ]; then
|
|
|
|
if [ "${APPVEYOR_RUST_CHANNEL}" = "${CHANNEL}" ]; then
|
|
|
|
return 0
|
|
|
|
fi
|
|
|
|
else
|
|
|
|
return 1
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2017-02-24 16:58:21 +00:00
|
|
|
build_and_test() {
|
|
|
|
# interleave building and testing in hope that it saves time
|
|
|
|
# also vary the local time zone to (hopefully) catch tz-dependent bugs
|
|
|
|
# also avoid doc-testing multiple times---it takes a lot and rarely helps
|
|
|
|
cargo clean
|
2019-09-02 15:00:34 +00:00
|
|
|
|
|
|
|
if [ "${WASMBIND}" != "y" ]; then
|
|
|
|
build_and_test_nonwasm
|
|
|
|
else
|
|
|
|
build_and_test_wasm
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [[ "$CHANNEL" == stable ]]; then
|
|
|
|
if [[ -n "$TRAVIS" ]] ; then
|
|
|
|
check_readme
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
build_and_test_nonwasm() {
|
2017-02-24 16:58:21 +00:00
|
|
|
channel build -v
|
|
|
|
TZ=ACST-9:30 channel test -v --lib
|
|
|
|
channel build -v --features rustc-serialize
|
|
|
|
TZ=EST4 channel test -v --features rustc-serialize --lib
|
2019-09-13 18:49:41 +00:00
|
|
|
channel build -v --features serde
|
|
|
|
TZ=UTC0 channel test -v --features serde --lib
|
|
|
|
channel build -v --features serde,rustc-serialize
|
|
|
|
TZ=Asia/Katmandu channel test -v --features serde,rustc-serialize
|
2017-02-24 23:20:07 +00:00
|
|
|
|
|
|
|
# without default "clock" feature
|
2019-09-07 10:20:52 +00:00
|
|
|
channel build -v --no-default-features --features std
|
2017-02-24 23:20:07 +00:00
|
|
|
TZ=ACST-9:30 channel test -v --no-default-features --lib
|
2019-09-07 10:20:52 +00:00
|
|
|
channel build -v --no-default-features --features std,rustc-serialize
|
2017-02-24 23:20:07 +00:00
|
|
|
TZ=EST4 channel test -v --no-default-features --features rustc-serialize --lib
|
2019-09-13 18:49:41 +00:00
|
|
|
channel build -v --no-default-features --features std,serde
|
|
|
|
TZ=UTC0 channel test -v --no-default-features --features serde --lib
|
|
|
|
channel build -v --no-default-features --features std,serde,rustc-serialize
|
|
|
|
TZ=Asia/Katmandu channel test -v --no-default-features --features std,serde,rustc-serialize --lib
|
2019-09-16 00:44:37 +00:00
|
|
|
|
|
|
|
channel build -v --no-default-features --features 'alloc serde'
|
|
|
|
TZ=UTC0 channel test -v --no-default-features --features 'alloc serde' --lib
|
2019-09-02 15:00:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
build_and_test_wasm() {
|
2019-08-16 17:11:30 +00:00
|
|
|
touch tests/wasm.rs # ensure rebuild happens so TZ / NOW take effect
|
2019-09-04 02:30:25 +00:00
|
|
|
TZ=ACST-9:30 NOW=$(date +%s) wasm-pack test --node -- --features wasmbind
|
2019-08-16 20:04:09 +00:00
|
|
|
touch tests/wasm.rs
|
2019-09-04 02:30:25 +00:00
|
|
|
TZ=EST4 NOW=$(date +%s) wasm-pack test --node -- --features wasmbind
|
2019-08-16 17:11:30 +00:00
|
|
|
touch tests/wasm.rs
|
2019-09-04 02:30:25 +00:00
|
|
|
TZ=UTC0 NOW=$(date +%s) wasm-pack test --node -- --features wasmbind
|
2019-08-16 17:11:30 +00:00
|
|
|
touch tests/wasm.rs
|
2019-09-04 02:30:25 +00:00
|
|
|
TZ=Asia/Katmandu NOW=$(date +%s) wasm-pack test --node -- --features wasmbind
|
2017-02-24 16:58:21 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
build_only() {
|
|
|
|
# Rust 1.13 doesn't support custom derive, so, to avoid doctests which
|
|
|
|
# validate that, we just build there.
|
|
|
|
cargo clean
|
|
|
|
channel build -v
|
|
|
|
channel build -v --features rustc-serialize
|
2019-09-16 00:44:37 +00:00
|
|
|
channel build -v --features serde
|
2019-09-07 10:20:52 +00:00
|
|
|
channel build -v --no-default-features --features std
|
2019-09-16 00:44:37 +00:00
|
|
|
channel build -v --no-default-features --features 'std serde_std'
|
2017-02-24 16:58:21 +00:00
|
|
|
}
|
|
|
|
|
2019-09-07 10:12:49 +00:00
|
|
|
build_core_test() {
|
2019-09-13 19:24:28 +00:00
|
|
|
channel_run rustup target add thumbv6m-none-eabi --toolchain "$CHANNEL"
|
2019-09-13 18:49:41 +00:00
|
|
|
(
|
|
|
|
cd ci/core-test
|
2019-09-16 00:44:37 +00:00
|
|
|
channel build -v --features alloc --target thumbv6m-none-eabi
|
2019-09-13 18:49:41 +00:00
|
|
|
)
|
2019-09-07 10:12:49 +00:00
|
|
|
}
|
|
|
|
|
2017-06-24 17:27:37 +00:00
|
|
|
run_clippy() {
|
|
|
|
# cached installation will not work on a later nightly
|
|
|
|
if [ -n "${TRAVIS}" ] && ! cargo install clippy --debug --force; then
|
|
|
|
echo "COULD NOT COMPILE CLIPPY, IGNORING CLIPPY TESTS"
|
|
|
|
exit
|
|
|
|
fi
|
|
|
|
|
2019-09-16 00:44:37 +00:00
|
|
|
cargo clippy --features 'serde rustc-serialize' -- -Dclippy
|
2017-06-24 17:27:37 +00:00
|
|
|
}
|
|
|
|
|
2018-08-25 19:51:46 +00:00
|
|
|
check_readme() {
|
|
|
|
make readme
|
|
|
|
(set -x; git diff --exit-code -- README.md) ; echo $?
|
|
|
|
}
|
|
|
|
|
2019-09-16 00:44:37 +00:00
|
|
|
banner() {
|
|
|
|
echo "======================================================================"
|
|
|
|
echo "$*"
|
|
|
|
echo "======================================================================"
|
|
|
|
}
|
2017-02-24 16:58:21 +00:00
|
|
|
|
2019-09-16 00:44:37 +00:00
|
|
|
underline() {
|
|
|
|
echo "$*"
|
|
|
|
echo "${*//?/^}"
|
|
|
|
}
|
2017-02-24 16:58:21 +00:00
|
|
|
|
2019-09-16 00:44:37 +00:00
|
|
|
matching_banner() {
|
|
|
|
if channel_matches || [[ -z $TRAVIS && -z $APPVEYOR ]] ; then
|
|
|
|
banner "$*"
|
|
|
|
fi
|
|
|
|
}
|
2017-02-24 16:58:21 +00:00
|
|
|
|
2019-09-16 00:44:37 +00:00
|
|
|
channel_run rustc --version
|
|
|
|
channel_run cargo --version
|
|
|
|
node --version
|
2017-02-24 16:58:21 +00:00
|
|
|
|
2019-09-16 00:44:37 +00:00
|
|
|
main
|