]> git.saurik.com Git - apple/security.git/blob - keychain/ckks/tests/gen_test_plist.py
Security-59754.41.1.tar.gz
[apple/security.git] / keychain / ckks / 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 import pprint
15
16 test_dir = sys.argv[1]
17 outfile = sys.argv[2]
18
19 test_plist = Foundation.NSMutableDictionary.dictionary()
20 test_plist['BATSConfigVersion'] = '0.1.0'
21 test_plist['Project'] = 'Security'
22 test_list = Foundation.NSMutableArray.array()
23
24 test_files = glob(test_dir + '/*.m') + glob(test_dir + '/*.h')
25
26 def get_class_names():
27 test_classes = ['CKKSLaunchSequenceTests']
28 for filename in test_files:
29 f = open(filename, 'r')
30 for line in f:
31 match = re.search('@interface ([a-zA-Z0-9_]+) ?: ?CloudKitKeychain[a-zA-Z0-9_]*TestsBase', line)
32 #match = re.search('class (([a-zA-Z0-9_]+Tests)|(OctagonTests[a-zA-Z0-9_]*(?<!Base))): ', line)
33 if match:
34 test_classes.append(match.group(1))
35
36 # And pick up everything that's a default xctest, too
37 match = re.search('@interface ([a-zA-Z0-9_]+) ?: ?XCTestCase', line)
38 if match:
39 test_classes.append(match.group(1))
40
41 # or based on CloudKitMockXCTest
42 match = re.search('@interface ([a-zA-Z0-9_]+) ?: ?CloudKitMockXCTest', line)
43 if match:
44 test_classes.append(match.group(1))
45 f.close()
46
47 # But we don't want any helper classes
48 base_classes = ['CloudKitMockXCTest', 'CloudKitKeychainSyncingMockXCTest', 'CKKSCloudKitTests']
49 for base_class in base_classes:
50 test_classes = [x for x in test_classes if base_class != x]
51 return test_classes
52
53 for x in get_class_names():
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')
64 test_command.append('{}'.format(x))
65 test_command.append('CKKSTests.xctest')
66 test_dictionary['Command'] = test_command
67
68 test_list.append(test_dictionary)
69
70 test_plist['Tests'] = test_list
71
72 out_dir = os.path.dirname(outfile)
73 if not os.path.exists(out_dir):
74 os.makedirs(out_dir)
75 success = test_plist.writeToFile_atomically_(outfile, 1)
76 if not success:
77 print "test plist failed to write, error!"
78 sys.exit(1)