-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathsanity.py
executable file
·50 lines (40 loc) · 1.29 KB
/
sanity.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
#!/usr/bin/env python
# encoding: utf-8
from optparse import OptionParser
from clint.textui import colored
import sys
import os
import re
import time
testfile_pattern = 'test_(.+)\.[json|yaml]'
def run_tests(folder):
"""
searches for testfiles in a folder recursively
"""
test_files = []
start = time.clock()
for root, subfolder, files in os.walk(folder):
for file_ in files:
match_ = re.match(testfile_pattern, file_)
if match_:
testfile_ = os.path.abspath(file_)
test_files.append(testfile_)
elapsed = (time.clock() - start)
print 'RAN %s tests in %s' % (len(test_files), elapsed)
print colored.green('OK')
#print colored.red('OK')
def main():
usage = 'usage: %prog [options] user -h for help'
parser = OptionParser(usage)
parser.add_option('-f', '--testfolder', action='store',
type='string', dest='testfolder', help='folder containg the tests')
#parser.add_option('-t', '--type', action='store',
#type='string', dest='testfolder', help='folder containg the tests')
(options, args) = parser.parse_args()
if options.testfolder:
run_tests(options.testfolder)
else:
parser.print_help()
if __name__ == '__main__':
status = main()
sys.exit(status)