-
Notifications
You must be signed in to change notification settings - Fork 5
/
check.py
executable file
·78 lines (64 loc) · 1.9 KB
/
check.py
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
#!/usr/bin/env python
import commands
import subprocess
import sys
from tools.check_tidy import check_tidy
def tidy():
err = check_tidy()
return err
def build():
build_command = "xctool -project Paranormal/Paranormal.xcodeproj/ -scheme Paranormal"
err = run(build_command)
return err
def tests():
test_command = 'xctool -project Paranormal/Paranormal.xcodeproj/ -scheme Paranormal test'
err = run(test_command)
return err
def run_check(check):
print colors.OKBLUE + 'Running ' + check.__name__ + colors.ENDC
exit_code = check()
if exit_code is 0:
print colors.OKGREEN + check.__name__ + ' succeeded!\n' + colors.ENDC
else:
print (colors.FAIL + check.__name__ + ' failed with exit code ' + str(exit_code)
+ '. Aborting.\n' + colors.ENDC)
return exit_code
def run(command):
try:
return subprocess.Popen(command.split(' ')).wait()
except:
print "exception raised running command: \n" + command
raise
all_checks = [
tidy,
build,
tests,
]
class colors:
HEADER = '\033[96m'
OKBLUE = '\033[94m'
OKGREEN = '\033[92m'
WARNING = '\033[93m'
FAIL = '\033[91m'
ENDC = '\033[0m'
if __name__ == "__main__":
successes = []
if len(sys.argv) >= 2:
if sys.argv[1] == "build":
all_checks = [tidy, build]
if sys.argv[1] == "tidy":
all_checks = [tidy]
for check in all_checks:
if run_check(check) is 0:
successes.append(True)
else:
sys.exit(1)
print colors.OKBLUE + "Summary:" + colors.ENDC
print '\n'.join([
colors.OKGREEN + all_checks[i].__name__ + ": succeeded" + colors.ENDC if success
else colors.FAIL + all_checks[i].__name__ + ": FAILED" + colors.ENDC
for i, success in enumerate(successes)])
if all(successes):
sys.exit(0)
else:
sys.exit(1)