]> git.saurik.com Git - apple/security.git/blob - keychain/ot/tests/gen_test_plist.py
Security-59306.41.2.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 {}.xctest'.format(x))
47 test_dictionary['Command'] = test_command
48
49 test_list.append(test_dictionary)
50
51
52 for x in get_class_names():
53
54 test_dictionary = Foundation.NSMutableDictionary.dictionary()
55 test_dictionary['TestName'] = x
56 test_dictionary['Timeout']= 1200
57 test_dictionary['ShowSubtestResults']= True
58 test_dictionary['WorkingDirectory'] = '/AppleInternal/XCTests/com.apple.security/'
59
60 test_command = Foundation.NSMutableArray.array()
61 test_command.append('BATS_XCTEST_CMD -XCTest {} OctagonTests.xctest'.format(x))
62 test_dictionary['Command'] = test_command
63
64 test_list.append(test_dictionary)
65
66 test_plist['Tests'] = test_list
67
68 out_dir = os.path.dirname(outfile)
69 if not os.path.exists(out_dir):
70 os.makedirs(out_dir)
71 success = test_plist.writeToFile_atomically_(outfile, 1)
72 if not success:
73 print "test plist failed to write, error!"
74 sys.exit(1)