-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathrun_tests.sh
More file actions
executable file
·50 lines (36 loc) · 1 KB
/
run_tests.sh
File metadata and controls
executable file
·50 lines (36 loc) · 1 KB
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
#!/bin/bash
# https://stackoverflow.com/questions/3349105/how-to-set-current-working-directory-to-the-directory-of-the-script-in-bash
# set working dir to the dir of the script so relative paths work
cd "$(dirname "$0")"
pip install -e .[dev] --quiet
echo "Run flake8 test"
flake8
flake8_status=$?
echo "Run mypy test"
mypy --exclude __main__ sc_kernel
mypy_status=$?
echo "Run unit tests"
coverage run --source '.' -m unittest discover
coverage_status=$?
coverage html
coverage report
coverage xml
if [[ -z "${OPEN_BROWSER_AFTER_TEST}" ]]; then
echo "Set OPEN_BROWSER_AFTER_TEST to open webbrowser w/ coverage report after test"
else
python -c "import os, webbrowser; webbrowser.open(f'file://{os.getcwd()}/coverage/index.html')"
fi
failedTests=0
if [ $flake8_status -ne 0 ]; then
echo "Flake8 tests failed"
failedTests=1
fi
if [ $mypy_status -ne 0 ]; then
echo "MyPy tests failed"
failedTests=1
fi
if [ $coverage_status -ne 0 ]; then
echo "Unittests failed"
failedTests=1
fi
exit $failedTests