summaryrefslogtreecommitdiffstats
path: root/tests/auto/JoinResults.py
blob: 8a98572f6007082c3ba038c3f0db674dd81a1f40 (plain)
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
import string, sys, os, datetime, time, re
import socket

Enviroment=''
RstPath=''
QtVersion=''

def JoinResults():
    timestamp = time.localtime()

    #result_qt_WITH_symbian_ON_2008-05-15_09-42-48_USING_4.4.0-rc1.xml
    rstFileName = time.strftime(RstPath+'\\result\\result_qt_WITH_symbian_ON_%Y-%m-%d_%H-%M-%S_USING_'+QtVersion+'.xml', timestamp)
    rst = open(rstFileName,'w')

    rst.write('<?xml version="1.0" encoding="ISO-8859-1"?>\n')
    rst.write('<Testrun>\n')
    rst.write('<Environment>\n')
    rst.write('<HostName>'+socket.gethostname()+'</HostName>\n')
    rst.write('<MakeSpec>symbian-'+Enviroment+'</MakeSpec>\n')
    rst.write('</Environment>\n')
    rst.write(time.strftime('<Timestamp date="%Y-%m-%d" time="%H:%M:%S"/>\n',timestamp))


    for root, dirs, files in os.walk(RstPath):
        for name in files:
            if not re.search('result_qt_WITH_', name ) and \
                re.match(name.split('.')[1], 'xml'):
                rst.write('<TestCase name="'+name.split('.')[0]+'">\n')
                path = root+'/'+name
                temp = open(path,'r')
                templines = temp.readlines()
                Validate( templines )
                rst.writelines(templines);
                temp.close()
                rst.write('</TestCase>\n')

    rst.write('</Testrun>\n')
    rst.close

def Validate(lines):
    regexp1 = re.compile('\s*</TestFunction>\s*')
    regexp2 = re.compile('\s*<TestFunction name=\s*')
    regexp1Flag = False
    regexp2Flag = False
    for index, line in enumerate(lines):
        if len(line) > 0 and regexp1.search(line):
            if regexp1Flag:
                lines[index] = ''
            else:
                regexp1Flag = True
        elif len(line) > 0 and regexp2.search(line):
            if regexp2Flag:
                lines[index] = ''
            else:
                regexp2Flag = True
        else:
            regexp1Flag = False
            regexp2Flag = False


if __name__ == '__main__':
    Enviroment = sys.argv[1]
    RstPath = sys.argv[2]
    QtVersion = sys.argv[3]

    JoinResults()