• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#!/bin/bash
2
3set -ex
4
5# Change to our project home.
6script_dir=`dirname "${BASH_SOURCE[0]}"`
7cd "$script_dir"/..
8
9# Print our cargo version, for debugging.
10cargo --version
11
12# Force default tests to disable default feature on NO_STD.
13if [ ! -z $NO_STD ]; then
14    DEFAULT_FEATURES="--no-default-features"
15    DOCTESTS="--tests"
16fi
17
18# Test various feature combinations.
19FEATURES=(
20    "compact"
21    "alloc"
22    "compact,alloc"
23)
24
25check() {
26    if [ ! -z $NO_FEATURES ]; then
27        return
28    fi
29
30    # Need to test a few permutations just to ensure everything compiles.
31    for features in "${FEATURES[@]}"; do
32        check_features="$DEFAULT_FEATURES --features=$features"
33        cargo check --tests $check_features
34    done
35}
36
37# Build target.
38build() {
39    cargo build $DEFAULT_FEATURES
40    cargo build $DEFAULT_FEATURES --release
41}
42
43# Test target.
44test() {
45    if [ ! -z $DISABLE_TESTS ]; then
46        return
47    fi
48    if [ ! -z $NO_STD ]; then
49        return
50    fi
51
52    # Default tests.
53    cargo test $DEFAULT_FEATURES $DOCTESTS
54    cargo test $DEFAULT_FEATURES $DOCTESTS --release
55}
56
57# Test target.
58test() {
59    if [ ! -z $DISABLE_TESTS ]; then
60        return
61    fi
62
63    # Default tests.
64    cargo test $DEFAULT_FEATURES $DOCTESTS
65    cargo test $DEFAULT_FEATURES $DOCTESTS --release
66}
67
68main() {
69    check
70    build
71    test
72
73    if [ ! -z $NIGHTLY ]; then
74        scripts/check.sh
75        RUSTFLAGS="--deny warnings" cargo +nightly build --features=lint
76    fi
77}
78