2009-11-18 Chris Toshok <toshok@ximian.com>
[moon.git] / test / convert-drt.py
blob8226e7310dc2a075f7e52ca17496b875a2326aec
1 #!/usr/bin/python
2 import xml.dom.minidom
3 import getopt
4 import sys
6 ##########################
7 # Important: This script is to be run from trunk/moon/test
8 # This file converts a Moonlight DRTList.xml to the MS DRTList.txt
9 ##########################
11 class drtTest:
12 def __init__(self,id):
13 self.id = id
14 self.feature = 'unknown'
15 self.owner = 'moonlight'
17 def _tif_or_png(self):
18 filename = self.master10.split('/')[-1] # mytest.xaml
20 filename = filename.split('.')[0] # mytest
22 if self.feature == "Animation":
23 filename += ".tif"
24 else:
25 filename += ".png"
26 self.master10 = "../harness/masters/%s" % filename
29 def toBadXML(self):
30 self._tif_or_png()
31 x = '\t<Test id="%s">\n' % (self.id)
32 x += '\t\t<inputFile="%s"/>\n' % self.input
33 x += '\t\t<masterFile10="%s"/>\n' % self.master10
34 if self.master11 != None and self.master11 != '':
35 x += '\t\t<masterFile11="%s"/>\n' % self.master11
36 x += '\t\t<owner="%s"/>\n' % self.owner
37 x += '\t\t<featureName="%s"/>\n' % self.feature
38 x += '\t</Test>'
39 return x
40 def usage():
41 print "\nUsage: convert-drt.py [--missing]\n"
42 print " --missing Creates a drtlist.txt of only test with missing master files"
44 def main():
46 # saveMasters.py --missing, --regen
48 regen = False
49 missing = False
51 try:
52 shortopts = 'hm'
53 longopts = ['help','missing',]
54 opts, args = getopt.getopt(sys.argv[1:],shortopts, longopts)
55 except getopt.GetoptError, err:
56 print str(err)
57 sys.exit(1)
60 for o, a in opts:
61 if o in ('-h','--help'):
62 usage()
63 return
64 if o in ('-m','--missing'):
65 missing = True
68 doc = xml.dom.minidom.parse("xaml/drtlist.xml")
69 drtnode = doc.childNodes[0]
71 print "<DRTList>"
73 for testnode in drtnode.childNodes:
74 if ((testnode.localName is not None) and (testnode.localName != "")):
75 #print'\t<Test id="%s">' % (testnode.getAttribute("id"))
77 #if os.path.exists():
79 test = drtTest(testnode.getAttribute("id"))
80 test.input = testnode.getAttribute("inputFile")
81 test.master10 = testnode.getAttribute('masterFile10')
82 test.master11 = testnode.getAttribute('masterFile11')
84 if testnode.getAttribute('inputFile').find('animation') != -1:
85 test.feature = "Animation"
86 elif testnode.getAttribute('featureName') != '':
87 test.feature = testnode.getAttribute('featureName')
89 #print '\t\t<featureName="%s"/>' % feature
91 # Added these attributes if non-existent
92 if testnode.getAttribute('owner') != '':
93 test.owner = testnode.getAttribute('owner')
96 print test.toBadXML()
97 #print "\t</Test>"
99 print "</DRTList>"
102 if __name__ == '__main__':
103 main()