1#!/bin/bash -x
2
3# Licensed under the Apache License, Version 2.0 (the "License");
4# you may not use this file except in compliance with the License.
5# You may obtain a copy of the License at
6#
7#     http://www.apache.org/licenses/LICENSE-2.0
8#
9# Unless required by applicable law or agreed to in writing, software
10# distributed under the License is distributed on an "AS IS" BASIS
11# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12# See the License for the specific language governing permissions and
13# limitations under the License.
14
15GET_FEATURES="$(pwd)/ci/get_features.py"
16CARGO_TOML="$(pwd)/sim/Cargo.toml"
17
18pushd sim
19
20all_features="$(${GET_FEATURES} ${CARGO_TOML})"
21[ $? -ne 0 ] && exit 1
22
23EXIT_CODE=0
24
25if [[ ! -z $SINGLE_FEATURES ]]; then
26  if [[ $SINGLE_FEATURES =~ "none" ]]; then
27    echo "Running cargo with no features"
28    time cargo test --no-run
29    time cargo test
30    rc=$? && [ $rc -ne 0 ] && EXIT_CODE=$rc
31  fi
32
33  for feature in $all_features; do
34    if [[ $SINGLE_FEATURES =~ $feature ]]; then
35      echo "Running cargo for feature=\"${feature}\""
36      time cargo test --no-run --features $feature
37      time cargo test --features $feature
38      rc=$? && [ $rc -ne 0 ] && EXIT_CODE=$rc
39    fi
40  done
41fi
42
43if [[ ! -z $MULTI_FEATURES ]]; then
44  IFS=','
45  read -ra multi_features <<< "$MULTI_FEATURES"
46  for features in "${multi_features[@]}"; do
47    echo "Running cargo for features=\"${features}\""
48    time cargo test --no-run --features "$features"
49    time cargo test --features "$features"
50    rc=$? && [ $rc -ne 0 ] && EXIT_CODE=$rc
51  done
52fi
53
54popd
55exit $EXIT_CODE
56