aboutsummaryrefslogtreecommitdiff
path: root/ci-build
blob: 714c5da17d1a759da977550b1cc750d09949b107 (plain)
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
#!/bin/sh

VENV_DIR=".ci-build-venv"
# Directory where coverage HTML report will be written.
COVERAGE_REPORT_DIR="lava_tool_coverage"

set -e

if test -z "$VIRTUAL_ENV"; then
  set -x
  virtualenv $VENV_DIR
  . $VENV_DIR/bin/activate
  python setup.py develop
fi

# requirement for integration tests
if ! pip show Flask | grep -q Flask; then
  pip install 'Flask==0.9'
fi
if ! pip show PyYAML | grep -q PyYAML; then
  pip install PyYAML
fi
# requirement for unit tests
if ! pip show mocker | grep -q mocker; then
  pip install mocker
fi

if ! pip show mock | grep -q mock; then
  pip install mock
fi
# Requirement to run code coverage tests.
if ! pip show coverage | grep -q coverage; then
  pip install coverage
fi

if test -z "$DISPLAY"; then
  # actual CI

  # will install tests dependencies automatically. The output is also more
  # verbose
  python setup.py test < /dev/null

  # integration-tests will pick this up and provide detailed output
  export VERBOSE=1
else
  # in a development workstation, this will produce shorter/nicer output, but
  # requires the test dependencies to be installed manually (or by running
  # `python setup.py test` before).
  python -m unittest lava_tool.tests.test_suite < /dev/null
fi

if test -d $COVERAGE_REPORT_DIR; then
  rm -rf $COVERAGE_REPORT_DIR
fi
# Runs python-coverage.
python-coverage run -m unittest lava_tool.tests.test_suite 2>/dev/null && python-coverage html

./integration-tests