-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathrun_tests.sh
57 lines (54 loc) · 2.3 KB
/
run_tests.sh
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
#!/bin/bash
print_message () {
# Print the line with message (first argument) on the full terminal width
# using second argument to fill the space.
# The default color is green. To switch to red pass a third argument with any value.
local terminal_width=$(tput cols)
local message=$1
local symbol=$2
local half_way=$((($terminal_width-${#message})/2))
local left_filler_len=$(printf "%${half_way}s")
local right_filler_len=$(printf "%$(($terminal_width-$half_way-${#message}))s")
if [[ ! -z "$3" ]]; then echo -e "\033[0;31m"; else echo -e "\033[0;32m"; fi
echo -e "${left_filler_len// /$symbol}$message${right_filler_len// /$symbol}\033[0m"
}
if python -m flake8 --config=setup.cfg 1>&2;
then
print_message " flake8 завершил проверку кода, ошибок не обнаружено " "="
echo $LF 1>&2
if python structure_test.py
then
cd ya_news
export DJANGO_SETTINGS_MODULE="${DJANGO_SETTINGS_MODULE:="yanews.settings"}"
if pytest --tb=line 1>&2;
then
cd ../ya_note
unset DJANGO_SETTINGS_MODULE
export DJANGO_SETTINGS_MODULE="${DJANGO_SETTINGS_MODULE:="yanote.settings"}"
if pytest --tb=line 1>&2;
then
exit 0
else
status=$?
print_message " При запуске упали ваши тесты для проекта YaNote. Проверьте тесты этого проекта " "=" 1
echo \`\`\` 1>&2
exit $status
fi
else
status=$?
print_message " При запуске упали ваши тесты для проекта YaNews. Проверьте тесты этого проекта " "=" 1
echo \`\`\` 1>&2
exit $status
fi
else
status=$?
print_message " Убедитесь, что написанные вами тесты скопированы в указанные в ТЗ директории " "=" 1
echo \`\`\` 1>&2
exit $status
fi
else
status=$?
print_message " flake8 обнаружил отклонения от стандартов, приведите код в соответствие с PEP8 " "=" 1
echo \`\`\` 1>&2
exit $status
fi