mirror of
https://github.com/GothenburgBitFactory/taskwarrior.git
synced 2025-06-26 10:54:26 +02:00
203 lines
4.5 KiB
Bash
Executable file
203 lines
4.5 KiB
Bash
Executable file
#! /bin/sh
|
|
|
|
# Look for taskd in $PATH instead of task/src/
|
|
export TASKD_USE_PATH=1
|
|
|
|
|
|
runlog_cleanup() {
|
|
if [ -f "_run_all_parallel.txt" ]; then
|
|
rm _run_all_parallel.txt
|
|
fi
|
|
if [ -f "_run_all_serial.txt" ]; then
|
|
rm _run_all_serial.txt
|
|
fi
|
|
if [ -f "_run_all_parallel_rc1" ]; then
|
|
rm _run_all_parallel_rc1
|
|
fi
|
|
for i in *.runlog; do
|
|
# Ugly hack. :)
|
|
if [ -f "$i" ]; then
|
|
rm *.runlog
|
|
fi
|
|
break
|
|
done
|
|
}
|
|
|
|
get_numprocs() {
|
|
numprocs=""
|
|
# Most Linux systems and OSX have getconf and _NPROCESSORS_ONLN.
|
|
if command -v getconf >/dev/null 2>&1; then
|
|
numprocs=$(getconf _NPROCESSORS_ONLN 2>/dev/null)
|
|
fi
|
|
|
|
# OpenBSD doesn't know _NPROCESSORS_ONLN, but it does have hw.ncpu
|
|
if [ "$numprocs" = "" ] && command -v sysctl >/dev/null 2>&1; then
|
|
numprocs=$(sysctl -n hw.ncpu 2>/dev/null)
|
|
fi
|
|
|
|
# If we still haven't found the number of CPU cores available, give up.
|
|
if [ "$numprocs" = "" ] || [ "$numprocs" -lt 1 ]; then
|
|
echo "Couldn't find number of CPU cores for parallelization. Assuming 2." 1>&2
|
|
numprocs=2
|
|
else
|
|
numprocs=$((numprocs+1))
|
|
fi
|
|
|
|
echo $numprocs
|
|
}
|
|
|
|
run_all_parallel() {
|
|
numprocs=$(get_numprocs)
|
|
cat _run_all_parallel.txt | xargs -n 1 -P $numprocs sh -c 'echo "#" $0 > $0.runlog; $0 >> $0.runlog 2>&1'
|
|
if [ $? -ne 0 ]; then
|
|
touch _run_all_parallel_rc1
|
|
fi
|
|
rm _run_all_parallel.txt
|
|
}
|
|
|
|
if [ ! -z "$1" ] && [ "$1" != "--verbose" ] && [ "$1" != "--fast" ];
|
|
then
|
|
echo "Did you mean --fast or --verbose?"
|
|
exit 1
|
|
fi
|
|
|
|
if [ "$#" -gt 1 ];
|
|
then
|
|
echo "Can only use arguments one at a time."
|
|
exit 1
|
|
fi
|
|
|
|
rc=0
|
|
if [ x"$1" = x"--verbose" ];
|
|
then
|
|
for i in ${TESTBLOB}
|
|
do
|
|
if [ -x "$i" ]; then
|
|
echo '#' $i
|
|
$i > test.log 2>&1
|
|
while read LINE
|
|
do
|
|
echo "$LINE"
|
|
done < test.log
|
|
if [ $? -ne 0 ]; then
|
|
rc=1
|
|
fi
|
|
rm test.log
|
|
else
|
|
echo "# Skipping $(basename $i) execute bit not set"
|
|
fi
|
|
done
|
|
exit $rc
|
|
|
|
elif [ "$1" = "--fast" ]; then
|
|
# Useful for faster local testing, might not be portable. Use at own risk.
|
|
# Results in (almost) the exact same "all.log" as a normal run.
|
|
# Ordering is off, but could easily be adjusted to be the same.
|
|
|
|
date > all.log
|
|
|
|
# Perl is used here to get the time in seconds
|
|
# because 'date +%s' isn't supported on Solaris.
|
|
STARTEPOCH=`perl -e 'print time'`
|
|
|
|
# Clean up after aborted runs
|
|
runlog_cleanup
|
|
|
|
for i in ${TESTBLOB}; do
|
|
if [ -x "$i" ]; then
|
|
# Only Python tests are guaranteed to run isolated.
|
|
if head -n 1 "$i" | grep -q '/usr/bin/env python'; then
|
|
echo $i >> _run_all_parallel.txt
|
|
else
|
|
echo $i >> _run_all_serial.txt
|
|
fi
|
|
else
|
|
echo "# Skipping $(basename $i) execute bit not set" >> all.log 2>&1
|
|
fi
|
|
done
|
|
|
|
run_all_parallel&
|
|
|
|
while read i; do
|
|
echo '#' $i >>all.log
|
|
|
|
$i >> all.log 2>&1
|
|
if [ $? -ne 0 ]; then
|
|
rc=1
|
|
fi
|
|
done < _run_all_serial.txt
|
|
|
|
while [ -f "_run_all_parallel.txt" ]; do
|
|
# Wait for the parallelized tests to finish running.
|
|
sleep 1 # sleep 0.1 is not portable.
|
|
done
|
|
|
|
if [ -f "_run_all_parallel_rc1" ]; then
|
|
rc=1
|
|
fi
|
|
|
|
cat *.runlog >> all.log
|
|
|
|
runlog_cleanup
|
|
|
|
date >> all.log
|
|
|
|
ENDEPOCH=`perl -e 'print time'`
|
|
RUNTIME=`expr $ENDEPOCH - $STARTEPOCH`
|
|
|
|
printf "Pass: %5d\n" `grep -c '^ok' all.log`
|
|
printf "Fail: %5d\n" `grep -c '^not' all.log`
|
|
printf "Skipped: %5d\n" `grep -c '^skip' all.log`
|
|
printf "Runtime: %5d seconds\n" $RUNTIME
|
|
exit $rc
|
|
|
|
else
|
|
date > all.log
|
|
|
|
# Perl is used here to get the time in seconds
|
|
# because 'date +%s' isn't supported on Solaris.
|
|
STARTEPOCH=`perl -e 'print time'`
|
|
|
|
VRAMSTEG=`which vramsteg 2>/dev/null`
|
|
BAR=0
|
|
if [ -x "$VRAMSTEG" ]; then
|
|
BAR=1
|
|
COUNT=0
|
|
TOTAL=`ls ${TESTBLOB} | wc -l`
|
|
START=`$VRAMSTEG --now`
|
|
fi
|
|
|
|
for i in ${TESTBLOB}
|
|
do
|
|
if [ -x "$i" ]; then
|
|
echo '#' $i >>all.log
|
|
|
|
$i >> all.log 2>&1
|
|
if [ $? -ne 0 ]; then
|
|
rc=1
|
|
fi
|
|
else
|
|
echo "# Skipping $(basename $i) execute bit not set" >> all.log 2>&1
|
|
fi
|
|
|
|
if [ $BAR -eq 1 ]; then
|
|
$VRAMSTEG --label 'All tests' --min 0 --max $TOTAL --current $COUNT --percentage --start $START --estimate
|
|
COUNT=`expr $COUNT + 1`
|
|
fi
|
|
done
|
|
|
|
if [ $BAR -eq 1 ]; then
|
|
$VRAMSTEG --remove
|
|
fi
|
|
|
|
date >> all.log
|
|
|
|
ENDEPOCH=`perl -e 'print time'`
|
|
RUNTIME=`expr $ENDEPOCH - $STARTEPOCH`
|
|
|
|
printf "Pass: %5d\n" `grep -c '^ok' all.log`
|
|
printf "Fail: %5d\n" `grep -c '^not' all.log`
|
|
printf "Skipped: %5d\n" `grep -c '^skip' all.log`
|
|
printf "Runtime: %5d seconds\n" $RUNTIME
|
|
exit $rc
|
|
fi
|