File: unit.sh

package info (click to toggle)
firefox 147.0.4-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 4,683,532 kB
  • sloc: cpp: 7,607,356; javascript: 6,533,348; ansic: 3,775,236; python: 1,415,508; xml: 634,561; asm: 438,949; java: 186,241; sh: 62,760; makefile: 18,079; objc: 13,092; perl: 12,808; yacc: 4,583; cs: 3,846; pascal: 3,448; lex: 1,720; ruby: 1,003; php: 436; lisp: 258; awk: 247; sql: 66; sed: 54; csh: 10; exp: 6
file content (85 lines) | stat: -rwxr-xr-x 2,742 bytes parent folder | download | duplicates (32)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
#!/bin/bash
###########################################################################
# This requires coverage and nosetests:
#
#  pip install -r requirements.txt
#
# test_base_vcs_mercurial.py requires hg >= 1.6.0 with mq, rebase, share
# extensions to fully test.
###########################################################################

COVERAGE_ARGS="--omit='/usr/*,/opt/*'"
OS_TYPE='linux'
uname -v | grep -q Darwin
if [ $? -eq 0 ] ; then
  OS_TYPE='osx'
  COVERAGE_ARGS="--omit='/Library/*,/usr/*,/opt/*'"
fi
uname -s | egrep -q MINGW32   # Cygwin will be linux in this case?
if [ $? -eq 0 ] ; then
  OS_TYPE='windows'
fi
NOSETESTS=`env which nosetests`

echo "### Finding mozharness/ .py files..."
files=`find mozharness -name [a-z]\*.py`
if [ $OS_TYPE == 'windows' ] ; then
  MOZHARNESS_PY_FILES=""
  for f in $files; do
    file $f | grep -q "Assembler source"
    if [ $? -ne 0 ] ; then
      MOZHARNESS_PY_FILES="$MOZHARNESS_PY_FILES $f"
    fi
  done
else
  MOZHARNESS_PY_FILES=$files
fi
echo "### Finding scripts/ .py files..."
files=`find scripts -name [a-z]\*.py`
if [ $OS_TYPE == 'windows' ] ; then
  SCRIPTS_PY_FILES=""
  for f in $files; do
    file $f | grep -q "Assembler source"
    if [ $? -ne 0 ] ; then
      SCRIPTS_PY_FILES="$SCRIPTS_PY_FILES $f"
    fi
  done
else
  SCRIPTS_PY_FILES=$files
fi
export PYTHONPATH=`env pwd`:$PYTHONPATH

echo "### Running pyflakes"
pyflakes $MOZHARNESS_PY_FILES $SCRIPTS_PY_FILES | grep -v "local variable 'url' is assigned to" | grep -v "redefinition of unused 'json'"

echo "### Running pylint"
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)'

rm -rf build logs
if [ $OS_TYPE != 'windows' ] ; then
  echo "### Testing non-networked unit tests"
  coverage run -a --branch $COVERAGE_ARGS $NOSETESTS test/test_*.py
  echo "### Running *.py [--list-actions]"
  for filename in $MOZHARNESS_PY_FILES; do
    coverage run -a --branch $COVERAGE_ARGS $filename
  done
  for filename in $SCRIPTS_PY_FILES ; do
    coverage run -a --branch $COVERAGE_ARGS $filename --list-actions > /dev/null
  done
  echo "### Running scripts/configtest.py --log-level warning"
  coverage run -a --branch $COVERAGE_ARGS scripts/configtest.py --log-level warning

  echo "### Creating coverage html"
  coverage html $COVERAGE_ARGS -d coverage.new
  if [ -e coverage ] ; then
      mv coverage coverage.old
      mv coverage.new coverage
      rm -rf coverage.old
  else
      mv coverage.new coverage
  fi
else
  echo "### Running nosetests..."
  nosetests test/
fi
rm -rf build logs