@@ -26,7 +26,8 @@ def verbose_print_command(command):
26
26
27
27
class ResilienceTest (object ):
28
28
def __init__ (self , target_build_swift , target_run , tmp_dir , test_dir ,
29
- test_src , additional_compile_flags_library ):
29
+ test_src , additional_compile_flags_library ,
30
+ no_backward_deployment ):
30
31
self .target_build_swift = shlex .split (target_build_swift )
31
32
self .target_run = shlex .split (target_run )
32
33
self .tmp_dir = tmp_dir
@@ -44,6 +45,8 @@ class ResilienceTest(object):
44
45
self .lib_obj_name = self .lib_src_name [:- 6 ] + '.o'
45
46
self .lib_src = os .path .join (self .test_dir , 'Inputs' , self .lib_src_name )
46
47
48
+ self .no_backward_deployment = no_backward_deployment
49
+
47
50
def run (self ):
48
51
self .set_up ()
49
52
self .compile_library ()
@@ -73,44 +76,53 @@ class ResilienceTest(object):
73
76
74
77
def compile_main (self ):
75
78
for config in self .config_dir_map :
76
- output_obj = os .path .join (self .config_dir_map [config ], 'main.o' )
77
- compiler_flags = ['-D' , config , '-c' , self .test_src , '-I' ,
78
- self .config_dir_map [config ], '-o' , output_obj ]
79
- command = self .target_build_swift + compiler_flags
80
- verbose_print_command (command )
81
- returncode = subprocess .call (command )
82
- assert returncode == 0 , str (command )
83
-
84
- def link (self ):
79
+ output_obj = os .path .join (self .config_dir_map [config ], 'main.o' )
80
+ compiler_flags = ['-D' , config , '-c' , self .test_src , '-I' ,
81
+ self .config_dir_map [config ], '-o' , output_obj ]
82
+ command = self .target_build_swift + compiler_flags
83
+ verbose_print_command (command )
84
+ returncode = subprocess .call (command )
85
+ assert returncode == 0 , str (command )
86
+
87
+ def configs (self ):
85
88
for config1 in self .config_dir_map :
86
89
for config2 in self .config_dir_map :
87
- config1_lower = config1 .lower ()
88
- config2_lower = config2 .lower ()
89
- output_obj = os .path .join (self .tmp_dir ,
90
- config1_lower + '_' + config2_lower )
91
- compiler_flags = [
92
- os .path .join (self .config_dir_map [config1 ],
93
- self .lib_obj_name ),
94
- os .path .join (self .config_dir_map [config2 ],
95
- 'main.o' ),
96
- '-o' , output_obj
97
- ]
98
- command = self .target_build_swift + compiler_flags
99
- verbose_print_command (command )
100
- returncode = subprocess .call (command )
101
- assert returncode == 0 , str (command )
90
+ # --no-backward-deployment skips testing a new application
91
+ # linked against an old library.
92
+ if config1 == "BEFORE" and config2 == "AFTER" and \
93
+ self .no_backward_deployment :
94
+ continue
95
+
96
+ yield (config1 , config2 )
97
+
98
+ def link (self ):
99
+ for config1 , config2 in self .configs ():
100
+ config1_lower = config1 .lower ()
101
+ config2_lower = config2 .lower ()
102
+ output_obj = os .path .join (self .tmp_dir ,
103
+ config1_lower + '_' + config2_lower )
104
+ compiler_flags = [
105
+ os .path .join (self .config_dir_map [config1 ],
106
+ self .lib_obj_name ),
107
+ os .path .join (self .config_dir_map [config2 ],
108
+ 'main.o' ),
109
+ '-o' , output_obj
110
+ ]
111
+ command = self .target_build_swift + compiler_flags
112
+ verbose_print_command (command )
113
+ returncode = subprocess .call (command )
114
+ assert returncode == 0 , str (command )
102
115
103
116
def execute (self ):
104
- for config1 in self .config_dir_map :
105
- for config2 in self .config_dir_map :
106
- config1_lower = config1 .lower ()
107
- config2_lower = config2 .lower ()
108
- output_obj = os .path .join (self .tmp_dir ,
109
- config1_lower + '_' + config2_lower )
110
- command = self .target_run + [output_obj ]
111
- verbose_print_command (command )
112
- returncode = subprocess .call (command )
113
- assert returncode == 0 , str (command )
117
+ for config1 , config2 in self .configs ():
118
+ config1_lower = config1 .lower ()
119
+ config2_lower = config2 .lower ()
120
+ output_obj = os .path .join (self .tmp_dir ,
121
+ config1_lower + '_' + config2_lower )
122
+ command = self .target_run + [output_obj ]
123
+ verbose_print_command (command )
124
+ returncode = subprocess .call (command )
125
+ assert returncode == 0 , str (command )
114
126
115
127
def main ():
116
128
parser = argparse .ArgumentParser (description = 'Resilience test helper' )
@@ -120,12 +132,15 @@ def main():
120
132
parser .add_argument ('--S' , required = True )
121
133
parser .add_argument ('--s' , required = True )
122
134
parser .add_argument ('--additional-compile-flags-library' , default = '' )
135
+ parser .add_argument ('--no-backward-deployment' , default = False ,
136
+ action = 'store_true' )
123
137
124
138
args = parser .parse_args ()
125
139
126
140
resilience_test = ResilienceTest (args .target_build_swift , args .target_run ,
127
141
args .t , args .S , args .s ,
128
- args .additional_compile_flags_library )
142
+ args .additional_compile_flags_library ,
143
+ args .no_backward_deployment )
129
144
130
145
return resilience_test .run ()
131
146
0 commit comments