tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

unit.sh (2742B)


      1 #!/bin/bash
      2 ###########################################################################
      3 # This requires coverage and nosetests:
      4 #
      5 #  pip install -r requirements.txt
      6 #
      7 # test_base_vcs_mercurial.py requires hg >= 1.6.0 with mq, rebase, share
      8 # extensions to fully test.
      9 ###########################################################################
     10 
     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/*'"
     17 fi
     18 uname -s | egrep -q MINGW32   # Cygwin will be linux in this case?
     19 if [ $? -eq 0 ] ; then
     20  OS_TYPE='windows'
     21 fi
     22 NOSETESTS=`env which nosetests`
     23 
     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"
     32    fi
     33  done
     34 else
     35  MOZHARNESS_PY_FILES=$files
     36 fi
     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"
     45    fi
     46  done
     47 else
     48  SCRIPTS_PY_FILES=$files
     49 fi
     50 export PYTHONPATH=`env pwd`:$PYTHONPATH
     51 
     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'"
     54 
     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)'
     57 
     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
     71 
     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
     80  fi
     81 else
     82  echo "### Running nosetests..."
     83  nosetests test/
     84 fi
     85 rm -rf build logs