]> git.saurik.com Git - apple/security.git/blob - keychain/ot/tests/gen_test_plist.py
Security-59754.41.1.tar.gz
[apple/security.git] / keychain / ot / tests / gen_test_plist.py
1 #!/usr/bin/python
2 #
3 # TODO(kirk or SEAR/QA) after radar 53867279 is fixed, please delete this script
4 #
5 # WARNING: if you add new tests to the swift octagon tests, it is possible that
6 # this script will not find them and then your new tests will not get executed
7 # in BATS!
8 #
9 import sys
10 import Foundation
11 from glob import glob
12 import re
13 import os
14
15 test_dir = sys.argv[1]
16 outfile = sys.argv[2]
17
18 test_plist = Foundation.NSMutableDictionary.dictionary()
19 test_plist['BATSConfigVersion'] = '0.1.0'
20 test_plist['Project'] = 'Security'
21 test_list = Foundation.NSMutableArray.array()
22
23 test_files = glob(test_dir + '/octagon/*.swift') + glob(test_dir + '/octagon/*/*.swift')
24
25 def get_class_names():
26 test_classes = ['OTFollowupTests']
27 for filename in test_files:
28 f = open(filename, 'r')
29 for line in f:
30 match = re.search('class (([a-zA-Z0-9_]+Tests)|(OctagonTests[a-zA-Z0-9_]*(?<!Base))): ', line)
31 if match:
32 test_classes.append('OctagonTests.{}'.format(match.group(1)))
33 f.close()
34 return test_classes
35
36
37 for x in ['TrustedPeersTests', 'TrustedPeersHelperUnitTests']:
38
39 test_dictionary = Foundation.NSMutableDictionary.dictionary()
40 test_dictionary['TestName'] = x
41 test_dictionary['Timeout']= 1200
42 test_dictionary['ShowSubtestResults']= True
43 test_dictionary['WorkingDirectory'] = '/AppleInternal/XCTests/com.apple.security/'
44
45 test_command = Foundation.NSMutableArray.array()
46 test_command.append('BATS_XCTEST_CMD')
47 test_command.append('{}.xctest'.format(x))
48 test_dictionary['Command'] = test_command
49
50 test_list.append(test_dictionary)
51
52
53 for x in ['OctagonTrustTests']:
54
55 test_dictionary = Foundation.NSMutableDictionary.dictionary()
56 test_dictionary['TestName'] = x
57 test_dictionary['Timeout']= 1200
58 test_dictionary['ShowSubtestResults']= True
59 test_dictionary['WorkingDirectory'] = '/AppleInternal/XCTests/com.apple.security/'
60
61 test_command = Foundation.NSMutableArray.array()
62 test_command.append('BATS_XCTEST_CMD')
63 test_command.append('{}.xctest'.format(x))
64 test_dictionary['Command'] = test_command
65
66 test_list.append(test_dictionary)
67
68
69 for x in get_class_names():
70
71 test_dictionary = Foundation.NSMutableDictionary.dictionary()
72 test_dictionary['TestName'] = x
73 test_dictionary['Timeout']= 1200
74 test_dictionary['ShowSubtestResults']= True
75 test_dictionary['WorkingDirectory'] = '/AppleInternal/XCTests/com.apple.security/'
76
77 test_command = Foundation.NSMutableArray.array()
78 test_command.append('BATS_XCTEST_CMD')
79 test_command.append('-XCTest')
80 test_command.append('{}'.format(x))
81 test_command.append('OctagonTests.xctest')
82 test_dictionary['Command'] = test_command
83
84 test_list.append(test_dictionary)
85
86 test_plist['Tests'] = test_list
87
88 out_dir = os.path.dirname(outfile)
89 if not os.path.exists(out_dir):
90 os.makedirs(out_dir)
91 success = test_plist.writeToFile_atomically_(outfile, 1)
92 if not success:
93 print "test plist failed to write, error!"
94 sys.exit(1)