blob: 59d65e10d640e27cb66b27c0e6a8ae213c31af0c [file] [log] [blame]
Fabio Utzig94a9b262019-03-07 13:15:02 -03001#!/bin/bash -x
Fabio Utzig0e12f6c2018-10-12 09:52:29 -07002
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
Fabio Utzig729139f2020-01-04 17:44:11 -030015GET_FEATURES="$(pwd)/ci/get_features.py"
16CARGO_TOML="$(pwd)/sim/Cargo.toml"
17
Fabio Utzig0e12f6c2018-10-12 09:52:29 -070018pushd sim
19
Fabio Utzig729139f2020-01-04 17:44:11 -030020all_features="$(${GET_FEATURES} ${CARGO_TOML})"
21[ $? -ne 0 ] && exit 1
22
Fabio Utzig0e12f6c2018-10-12 09:52:29 -070023EXIT_CODE=0
24
25if [[ ! -z $SINGLE_FEATURES ]]; then
Fabio Utzig0e12f6c2018-10-12 09:52:29 -070026 if [[ $SINGLE_FEATURES =~ "none" ]]; then
27 echo "Running cargo with no features"
David Browned90fbf2021-01-12 12:03:19 -070028 time cargo test --no-run
29 time cargo test
Fabio Utzig0e12f6c2018-10-12 09:52:29 -070030 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}\""
David Browned90fbf2021-01-12 12:03:19 -070036 time cargo test --no-run --features $feature
37 time cargo test --features $feature
Fabio Utzig0e12f6c2018-10-12 09:52:29 -070038 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}\""
David Browned90fbf2021-01-12 12:03:19 -070048 time cargo test --no-run --features "$features"
49 time cargo test --features "$features"
Fabio Utzig0e12f6c2018-10-12 09:52:29 -070050 rc=$? && [ $rc -ne 0 ] && EXIT_CODE=$rc
51 done
52fi
53
54popd
55exit $EXIT_CODE