forked from Backblaze/B2_Command_Line_Tool
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathpre-commit.sh
executable file
·105 lines (88 loc) · 1.69 KB
/
pre-commit.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
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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
#!/bin/bash
function header
{
echo
echo "#"
echo "# $*"
echo "#"
echo
}
if yapf --version &> /dev/null
then
echo "yapf is installed"
else
echo "Please install yapf, then try again."
exit 1
fi
header Unit Tests
if make test
then
echo "Unit tests PASSED"
else
echo "Unit tests FAILED"
exit 1
fi
header Checking Formatting
SOURCE_FILES="b2/*.py test/*.py *.py"
for src_file in $SOURCE_FILES
do
echo "$src_file"
if yapf "$src_file" > yapf.out
then
rm yapf.out
else
echo
echo "Formatting updated:"
echo
diff "$src_file" yapf.out
mv yapf.out "$src_file"
sleep 5
fi
done
header Pyflakes
for d in b2 test
do
if pyflakes $d
then
echo pyflakes passed on $d
else
echo pyflakes FAILED on %d
exit 1
fi
done
header test_raw_api
if [[ -n "$TEST_ACCOUNT_ID" && -n "$TEST_APPLICATION_KEY" ]]
then
python -m b2.__main__ test_raw_api
else
echo "Skipping because TEST_ACCOUNT_ID and TEST_APPLICATION_KEY are not set"
fi
if [[ $# -ne 0 && "$1" == quick ]]
then
header QUICK
echo Skipping integration tests in quick mode.
echo
exit 0
fi
function run_integration_tests
{
if time python test_b2_command_line.py $(head -n 1 ~/.b2_auth) $(tail -n 1 ~/.b2_auth)
then
echo "integration tests passed"
else
echo
echo "integration tests FAILED"
exit 1
fi
}
if [[ -z "$PYTHON_VIRTUAL_ENVS" ]]
then
run_integration_tests
else
for virtual_env in $PYTHON_VIRTUAL_ENVS
do
header Integration tests in: $virtual_env
source $virtual_env/bin/activate
run_integration_tests
done
fi