forked from couchbaselabs/sync-gateway-tests
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtap_results_extracter.py
61 lines (44 loc) · 1.4 KB
/
tap_results_extracter.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
import re
import unittest
import sys
import argparse
import os
import urllib2
import xmlrunner
class TestSequence(unittest.TestCase):
pass
def test_generator(b):
def test(self):
self.assertTrue(b)
return test
def tap_it(file):
tests_count = 0
tests_passed = 0
tests_failed = 0
with open (file, 'r') as f:
content = f.read()
match_objects = re.findall(r"^\d+\.+\d+\n+#\s+tests\s+(\d+)\n#\s+pass\s+(\d+)",content,re.MULTILINE)
for obj in match_objects:
tests_count += int(obj[0])
tests_passed += int(obj[1])
print obj
tests_failed = tests_count - tests_passed
print "Total sets:",len(match_objects)
print "Total tests count:",tests_count
print "Total tests passed:", tests_passed
print "Total tests failed:", tests_failed
for t in xrange(0, tests_passed):
test_name = 'test_pass_%s' % t
test = test_generator(True)
setattr(TestSequence, test_name, test)
for t in range(0, tests_failed):
test_name = 'test_failed_%s' % t
test = test_generator(False)
setattr(TestSequence, test_name, test)
del sys.argv[1:]
unittest.main(testRunner=xmlrunner.XMLTestRunner(output='test-reports'))
# Usage: python tap_results_extracter.py mobile_results.log
if len(sys.argv) != 2:
print "Usage tap_results_extractor.py results.tap"
exit(1)
tap_it(file=sys.argv[1])