Files
swupd-client/scripts/github_actions/weight_tests.bash
T
2020-03-26 15:44:04 -07:00

21 lines
411 B
Bash
Executable File

#!/bin/bash
MAX_WEIGHT=40
if [ -z "$1" ]; then
TESTS=$(find test/functional/ -name "*.bats")
else
TESTS="$*"
fi
for t in $TESTS; do
echo "Running $t"
WEIGHT=$(($(/usr/bin/time -f %e "$t" 2>&1 |tail -n 1 |cut -d '.' -f 1)+1))
echo "$WEIGHT"
if [ $WEIGHT -gt "$MAX_WEIGHT" ]; then
WEIGHT="$MAX_WEIGHT"
fi
sed -i "/#WEIGHT/d" "$t"
echo "#WEIGHT=$WEIGHT" >> "$t"
done