Bug 1874684 - Part 28: Return DateDuration from DifferenceISODateTime. r=mgaudet
[gecko.git] / testing / mozharness / unit.sh
blob1b96f495f2d1c59b615ce3a751b98bb86f368cfe
1 #!/bin/bash
2 ###########################################################################
3 # This requires coverage and nosetests:
5 # pip install -r requirements.txt
7 # test_base_vcs_mercurial.py requires hg >= 1.6.0 with mq, rebase, share
8 # extensions to fully test.
9 ###########################################################################
11 COVERAGE_ARGS="--omit='/usr/*,/opt/*'"
12 OS_TYPE='linux'
13 uname -v | grep -q Darwin
14 if [ $? -eq 0 ] ; then
15 OS_TYPE='osx'
16 COVERAGE_ARGS="--omit='/Library/*,/usr/*,/opt/*'"
18 uname -s | egrep -q MINGW32 # Cygwin will be linux in this case?
19 if [ $? -eq 0 ] ; then
20 OS_TYPE='windows'
22 NOSETESTS=`env which nosetests`
24 echo "### Finding mozharness/ .py files..."
25 files=`find mozharness -name [a-z]\*.py`
26 if [ $OS_TYPE == 'windows' ] ; then
27 MOZHARNESS_PY_FILES=""
28 for f in $files; do
29 file $f | grep -q "Assembler source"
30 if [ $? -ne 0 ] ; then
31 MOZHARNESS_PY_FILES="$MOZHARNESS_PY_FILES $f"
33 done
34 else
35 MOZHARNESS_PY_FILES=$files
37 echo "### Finding scripts/ .py files..."
38 files=`find scripts -name [a-z]\*.py`
39 if [ $OS_TYPE == 'windows' ] ; then
40 SCRIPTS_PY_FILES=""
41 for f in $files; do
42 file $f | grep -q "Assembler source"
43 if [ $? -ne 0 ] ; then
44 SCRIPTS_PY_FILES="$SCRIPTS_PY_FILES $f"
46 done
47 else
48 SCRIPTS_PY_FILES=$files
50 export PYTHONPATH=`env pwd`:$PYTHONPATH
52 echo "### Running pyflakes"
53 pyflakes $MOZHARNESS_PY_FILES $SCRIPTS_PY_FILES | grep -v "local variable 'url' is assigned to" | grep -v "redefinition of unused 'json'"
55 echo "### Running pylint"
56 pylint -E -e F -f parseable $MOZHARNESS_PY_FILES $SCRIPTS_PY_FILES 2>&1 | egrep -v '(No config file found, using default configuration|Instance of .* has no .* member|Unable to import .devicemanager|Undefined variable .DMError|Module .hashlib. has no .sha512. member)'
58 rm -rf build logs
59 if [ $OS_TYPE != 'windows' ] ; then
60 echo "### Testing non-networked unit tests"
61 coverage run -a --branch $COVERAGE_ARGS $NOSETESTS test/test_*.py
62 echo "### Running *.py [--list-actions]"
63 for filename in $MOZHARNESS_PY_FILES; do
64 coverage run -a --branch $COVERAGE_ARGS $filename
65 done
66 for filename in $SCRIPTS_PY_FILES ; do
67 coverage run -a --branch $COVERAGE_ARGS $filename --list-actions > /dev/null
68 done
69 echo "### Running scripts/configtest.py --log-level warning"
70 coverage run -a --branch $COVERAGE_ARGS scripts/configtest.py --log-level warning
72 echo "### Creating coverage html"
73 coverage html $COVERAGE_ARGS -d coverage.new
74 if [ -e coverage ] ; then
75 mv coverage coverage.old
76 mv coverage.new coverage
77 rm -rf coverage.old
78 else
79 mv coverage.new coverage
81 else
82 echo "### Running nosetests..."
83 nosetests test/
85 rm -rf build logs