Browse Source

Add unittests for entropy

Added run_tests.sh, taken shamelessly from taskflow.

Change-Id: I39b9cfa106c06296b917077cc3ef93dbf5a9a03b
Pranesh Pandurangan 4 years ago
parent
commit
e2cebf411e
1 changed files with 88 additions and 0 deletions
  1. 88
    0
      run_tests.sh

+ 88
- 0
run_tests.sh View File

@@ -0,0 +1,88 @@
1
+#!/bin/bash
2
+
3
+function usage {
4
+  echo "Usage: $0 [OPTION]..."
5
+  echo "Run Entropy's test suite(s)"
6
+  echo ""
7
+  echo "  -f, --force              Force a clean re-build of the virtual environment. Useful when dependencies have been added."
8
+  echo "  -p, --pep8               Just run pep8"
9
+  echo "  -P, --no-pep8            Don't run static code checks"
10
+  echo "  -v, --verbose            Increase verbosity of reporting output"
11
+  echo "  -h, --help               Print this usage message"
12
+  echo ""
13
+  exit
14
+}
15
+
16
+function process_option {
17
+  case "$1" in
18
+    -h|--help) usage;;
19
+    -p|--pep8) let just_pep8=1;;
20
+    -P|--no-pep8) let no_pep8=1;;
21
+    -f|--force) let force=1;;
22
+    -v|--verbose) let verbose=1;;
23
+    *) pos_args="$pos_args $1"
24
+  esac
25
+}
26
+
27
+verbose=0
28
+force=0
29
+pos_args=""
30
+just_pep8=0
31
+no_pep8=0
32
+tox_args=""
33
+tox=""
34
+
35
+for arg in "$@"; do
36
+  process_option $arg
37
+done
38
+
39
+py=`which python`
40
+if [ -z "$py" ]; then
41
+    echo "Python is required to use $0"
42
+    echo "Please install it via your distributions package management system."
43
+    exit 1
44
+fi
45
+
46
+py_envs=`python -c 'import sys; print("py%s%s" % (sys.version_info[0:2]))'`
47
+py_envs=${PY_ENVS:-$py_envs}
48
+
49
+function run_tests {
50
+    local tox_cmd="${tox} ${tox_args} -e $py_envs ${pos_args}"
51
+    echo "Running tests for environments $py_envs via $tox_cmd"
52
+    bash -c "$tox_cmd"
53
+}
54
+
55
+function run_flake8 {
56
+  local tox_cmd="${tox} ${tox_args} -e pep8 ${pos_args}"
57
+  echo "Running flake8 via $tox_cmd"
58
+  bash -c "$tox_cmd"
59
+}
60
+
61
+if [ $force -eq 1 ]; then
62
+  tox_args="$tox_args -r"
63
+fi
64
+
65
+if [ $verbose -eq 1 ]; then
66
+  tox_args="$tox_args -v"
67
+fi
68
+
69
+tox=`which tox`
70
+if [ -z "$tox" ]; then
71
+    echo "Tox is required to use $0"
72
+    echo "Please install it via \`pip\` or via your distributions" \
73
+         "package management system."
74
+    echo "Visit http://tox.readthedocs.org/ for additional installation" \
75
+         "instructions."
76
+    exit 1
77
+fi
78
+
79
+if [ $just_pep8 -eq 1 ]; then
80
+  run_flake8
81
+  exit
82
+fi
83
+
84
+run_tests || exit
85
+
86
+if [ $no_pep8 -eq 0 ]; then
87
+  run_flake8
88
+fi

Loading…
Cancel
Save