eSpeak NG is an open source speech synthesizer that supports more than hundred languages and accents.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

windows-installer.test 2.8KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. #!/usr/bin/env python3
  2. import sys
  3. import xml.etree.ElementTree as etree
  4. passed = True
  5. def check_result(check, message):
  6. global passed
  7. if check:
  8. print('passed')
  9. elif message:
  10. print('failed: ' + message)
  11. passed = False
  12. else:
  13. print('failed')
  14. passed = False
  15. def all_descendants(wix, name):
  16. for e in wix.iter():
  17. if e.tag == '{http://schemas.microsoft.com/wix/2006/wi}' + name:
  18. yield e
  19. def children(e, name):
  20. for c in e:
  21. if not isinstance(c, str):
  22. if c.tag == '{http://schemas.microsoft.com/wix/2006/wi}' + name:
  23. yield c
  24. def element_map(wix, name):
  25. print('testing for duplicate \'' + name + '\' ids ... ', end='')
  26. items = {}
  27. duplicates = []
  28. for e in all_descendants(wix, name):
  29. id = e.attrib.get("Id")
  30. if id in items.keys():
  31. duplicates.append(id)
  32. else:
  33. items[id] = e
  34. check_result(len(duplicates) == 0 , ', '.join(duplicates))
  35. return items
  36. def check_element_guids(wix, name):
  37. print('testing for duplicate \'' + name + '\' guids ... ', end='')
  38. guids = []
  39. missing_guids = []
  40. duplicates = []
  41. for e in all_descendants(wix, name):
  42. id = e.attrib.get("Id")
  43. guid = e.attrib.get("Guid")
  44. if not guid:
  45. missing_guids.append(id)
  46. elif guid in guids:
  47. duplicates.append(guid)
  48. else:
  49. guids.append(guid)
  50. check_result(len(duplicates) == 0 , ', '.join(duplicates))
  51. return (guids, missing_guids)
  52. def check_references(nodes, node_name, name, item_name, items):
  53. print('testing for missing \'' + item_name + '\' ids in \'' + node_name + '/' + name + '\' ... ', end='')
  54. missing = []
  55. for node in nodes.values():
  56. for ref in children(node, name):
  57. id = ref.attrib.get("Id")
  58. if not id in items.keys():
  59. missing.append(id)
  60. check_result(len(missing) == 0 , ', '.join(missing))
  61. # 1. Check for missing/duplicate ids ###################################################################################
  62. wix = etree.parse('src/windows/installer/Product.wxs').getroot()
  63. features = element_map(wix, 'Feature')
  64. component_groups = element_map(wix, 'ComponentGroup')
  65. components = element_map(wix, 'Component')
  66. directories = element_map(wix, 'Directory')
  67. check_references(features, 'Feature', 'ComponentGroupRef', 'ComponentGroup', component_groups)
  68. check_references(component_groups, 'ComponentGroups', 'ComponentRef', 'Component', components)
  69. # 2. Check for missing/duplicate guids #################################################################################
  70. guids, missing_guids = check_element_guids(wix, 'Component')
  71. print('testing for missing \'Component\' guids ... ', end='')
  72. check_result(len(missing_guids) == 0 , ', '.join(missing_guids))
  73. ########################################################################################################################
  74. if not passed:
  75. sys.exit(-1)