Files
jerryscript/tools/runners/run-unittests.sh
T
Akos Kiss 71471a0416 Add better support for proper installation after build (#2370)
- Add `--install` option to `tools/build.py`.
- Make use of `--install` in `tools/run-tests.py` by testing the
  installed the executables instead of those in the build tree.

Related changes:
- Collect unit test binaries in the `tests` subdir of the build
  tree instead of `bin`.
- The `ls`-based collection of the unit test binaries had some
  shortcomings hitherto unrevealed (it didn't filter for files so
  it could potentially "collect" dictionaries, too), which has now
  been replaced with a more stable `find`-based solution.

JerryScript-DCO-1.0-Signed-off-by: Akos Kiss akiss@inf.u-szeged.hu
2018-06-04 10:55:29 +09:00

109 lines
2.5 KiB
Bash
Executable File

#!/bin/bash
# Copyright JS Foundation and other contributors, http://js.foundation
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
DIR="$1"
shift
VERBOSE=1
if [ "$1" == "-q" ]
then
unset VERBOSE
shift
fi
UNITTEST_ERROR=$DIR/unittests.failed
UNITTEST_OK=$DIR/unittests.passed
rm -f $UNITTEST_ERROR $UNITTEST_OK
UNITTESTS=$(find $DIR -maxdepth 1 -type f -name 'unit-*')
total=$(find $DIR -maxdepth 1 -type f -name 'unit-*' | wc -l)
if [ "$total" -eq 0 ]
then
echo "$0: $DIR: no unit-* test to execute"
exit 1
fi
ROOT_DIR=""
CURRENT_DIR=`pwd`
PATH_STEP=2
while true
do
TMP_ROOT_DIR=`(echo "$CURRENT_DIR"; echo "$0"; echo "$DIR") | cut -f1-$PATH_STEP -d/ | uniq -d`
if [ -z "$TMP_ROOT_DIR" ]
then
break
else
ROOT_DIR="$TMP_ROOT_DIR"
fi
PATH_STEP=$((PATH_STEP+1))
done
if [ -n "$ROOT_DIR" ]
then
ROOT_DIR="$ROOT_DIR/"
fi
tested=1
failed=0
passed=0
UNITTEST_TEMP=`mktemp unittest-out.XXXXXXXXXX`
for unit_test in $UNITTESTS
do
cmd_line="$RUNTIME ${unit_test#$ROOT_DIR}"
$RUNTIME $unit_test &>$UNITTEST_TEMP
status_code=$?
if [ $status_code -ne 0 ]
then
echo "[$tested/$total] $cmd_line: FAIL ($status_code)"
cat $UNITTEST_TEMP
echo "$status_code: $unit_test" >> $UNITTEST_ERROR
echo "============================================" >> $UNITTEST_ERROR
cat $UNITTEST_TEMP >> $UNITTEST_ERROR
echo "============================================" >> $UNITTEST_ERROR
echo >> $UNITTEST_ERROR
echo >> $UNITTEST_ERROR
failed=$((failed+1))
else
test $VERBOSE && echo "[$tested/$total] $cmd_line: PASS"
echo "$unit_test" >> $UNITTEST_OK
passed=$((passed+1))
fi
tested=$((tested+1))
done
rm -f $UNITTEST_TEMP
ratio=$(echo $passed*100/$total | bc)
echo "[summary] ${DIR#$ROOT_DIR}/unit-*: $passed PASS, $failed FAIL, $total total, $ratio% success"
if [ $failed -ne 0 ]
then
echo "$0: see $UNITTEST_ERROR for details about failures"
exit 1
fi
exit 0