mirror of
https://github.com/facebook/sapling.git
synced 2024-10-06 14:58:03 +03:00
let run-tests run optional code coverage tests.
to enable, set env var TEST_COVERAGE to non-empty string. run-tests will print report after running. after coverage run, file tests/.coverage will contain coverage data. use tests/coverage.py to get more info, like annotated source code.
This commit is contained in:
parent
846e9696ac
commit
82f373878f
@ -8,6 +8,7 @@ syntax: glob
|
||||
*.pyc
|
||||
*.swp
|
||||
*.prof
|
||||
tests/.coverage*
|
||||
tests/*.err
|
||||
build
|
||||
dist
|
||||
|
@ -1,4 +1,9 @@
|
||||
#!/bin/sh -e
|
||||
#
|
||||
# environment variables:
|
||||
#
|
||||
# TEST_COVERAGE - set non-empty if you want to print test coverage report
|
||||
# COVERAGE_STDLIB - set non-empty to report coverage of standard library
|
||||
|
||||
LANG="C"; export LANG
|
||||
LC_CTYPE="C"; export LC_CTYPE
|
||||
@ -64,7 +69,19 @@ else
|
||||
fi
|
||||
cd "$TESTDIR"
|
||||
|
||||
BINDIR="$INST/bin"
|
||||
BINDIR="$INST/bin"; export BINDIR
|
||||
if [ -n "$TEST_COVERAGE" ]; then
|
||||
COVERAGE_FILE="$TESTDIR/.coverage"; export COVERAGE_FILE
|
||||
rm -f "$COVERAGE_FILE"
|
||||
mv "$BINDIR/hg" "$BINDIR/hg.py"
|
||||
{
|
||||
echo '#!/bin/sh'
|
||||
echo "exec \"${PYTHON-python}\" \"$TESTDIR/coverage.py\"" \
|
||||
"-x \"$BINDIR/hg.py\" \"\$@\""
|
||||
} > "$BINDIR/hg"
|
||||
chmod 700 "$BINDIR/hg"
|
||||
fi
|
||||
|
||||
PATH="$BINDIR:$PATH"; export PATH
|
||||
if [ -n "$PYTHON" ]; then
|
||||
{
|
||||
@ -153,6 +170,17 @@ done
|
||||
echo
|
||||
echo "Ran $tests tests, $failed failed."
|
||||
|
||||
if [ -n "$TEST_COVERAGE" ]; then
|
||||
unset PYTHONPATH
|
||||
$ECHO_N "$BINDIR,$TESTDIR,$HGTMP/test-," > "$HGTMP/omit"
|
||||
if [ -z "$COVERAGE_STDLIB" ]; then
|
||||
"${PYTHON-python}" -c 'import sys; print ",".join(sys.path)' \
|
||||
>> "$HGTMP/omit"
|
||||
fi
|
||||
cd "$PYTHONDIR"
|
||||
"${PYTHON-python}" "$TESTDIR/coverage.py" -r --omit="`cat \"$HGTMP/omit\"`"
|
||||
fi
|
||||
|
||||
if [ $failed -gt 0 ] ; then
|
||||
exit 1
|
||||
fi
|
||||
|
Loading…
Reference in New Issue
Block a user