Fabio Utzig | 94a9b26 | 2019-03-07 13:15:02 -0300 | [diff] [blame] | 1 | #!/bin/bash -x |
Fabio Utzig | 0e12f6c | 2018-10-12 09:52:29 -0700 | [diff] [blame] | 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 | |
Fabio Utzig | 729139f | 2020-01-04 17:44:11 -0300 | [diff] [blame] | 15 | GET_FEATURES="$(pwd)/ci/get_features.py" |
| 16 | CARGO_TOML="$(pwd)/sim/Cargo.toml" |
| 17 | |
Fabio Utzig | 0e12f6c | 2018-10-12 09:52:29 -0700 | [diff] [blame] | 18 | pushd sim |
| 19 | |
Fabio Utzig | 729139f | 2020-01-04 17:44:11 -0300 | [diff] [blame] | 20 | all_features="$(${GET_FEATURES} ${CARGO_TOML})" |
| 21 | [ $? -ne 0 ] && exit 1 |
| 22 | |
Fabio Utzig | 0e12f6c | 2018-10-12 09:52:29 -0700 | [diff] [blame] | 23 | EXIT_CODE=0 |
| 24 | |
| 25 | if [[ ! -z $SINGLE_FEATURES ]]; then |
Fabio Utzig | 0e12f6c | 2018-10-12 09:52:29 -0700 | [diff] [blame] | 26 | if [[ $SINGLE_FEATURES =~ "none" ]]; then |
| 27 | echo "Running cargo with no features" |
David Brown | ed90fbf | 2021-01-12 12:03:19 -0700 | [diff] [blame] | 28 | time cargo test --no-run |
| 29 | time cargo test |
Fabio Utzig | 0e12f6c | 2018-10-12 09:52:29 -0700 | [diff] [blame] | 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}\"" |
David Brown | ed90fbf | 2021-01-12 12:03:19 -0700 | [diff] [blame] | 36 | time cargo test --no-run --features $feature |
| 37 | time cargo test --features $feature |
Fabio Utzig | 0e12f6c | 2018-10-12 09:52:29 -0700 | [diff] [blame] | 38 | rc=$? && [ $rc -ne 0 ] && EXIT_CODE=$rc |
| 39 | fi |
| 40 | done |
| 41 | fi |
| 42 | |
| 43 | if [[ ! -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 Brown | ed90fbf | 2021-01-12 12:03:19 -0700 | [diff] [blame] | 48 | time cargo test --no-run --features "$features" |
| 49 | time cargo test --features "$features" |
Fabio Utzig | 0e12f6c | 2018-10-12 09:52:29 -0700 | [diff] [blame] | 50 | rc=$? && [ $rc -ne 0 ] && EXIT_CODE=$rc |
| 51 | done |
| 52 | fi |
| 53 | |
| 54 | popd |
| 55 | exit $EXIT_CODE |