Returns differences between command lines that generate same outputs.
(before_proto, after_proto, attrs, before_file, after_file)
| 184 | |
| 185 | |
| 186 | def _aquery_diff(before_proto, after_proto, attrs, before_file, after_file): |
| 187 | """Returns differences between command lines that generate same outputs.""" |
| 188 | found_difference = False |
| 189 | artifacts_before = _map_artifact_id_to_path(before_proto.artifacts, |
| 190 | before_proto.path_fragments) |
| 191 | artifacts_after = _map_artifact_id_to_path(after_proto.artifacts, |
| 192 | after_proto.path_fragments) |
| 193 | |
| 194 | action_to_output_files_before = _map_action_index_to_output_files( |
| 195 | before_proto.actions, artifacts_before) |
| 196 | action_to_output_files_after = _map_action_index_to_output_files( |
| 197 | after_proto.actions, artifacts_after) |
| 198 | |
| 199 | # There's a 1-to-1 mapping between action and outputs |
| 200 | output_files_before = set(action_to_output_files_before.values()) |
| 201 | output_files_after = set(action_to_output_files_after.values()) |
| 202 | |
| 203 | before_after_diff = output_files_before - output_files_after |
| 204 | after_before_diff = output_files_after - output_files_before |
| 205 | |
| 206 | if before_after_diff: |
| 207 | print(("Aquery output 'before' change contains an action that generates " |
| 208 | "the following outputs that aquery output 'after' change doesn't:" |
| 209 | "\n%s\n") % "\n".join(before_after_diff)) |
| 210 | found_difference = True |
| 211 | if after_before_diff: |
| 212 | print(("Aquery output 'after' change contains an action that generates " |
| 213 | "the following outputs that aquery output 'before' change doesn't:" |
| 214 | "\n%s\n") % "\n".join(after_before_diff)) |
| 215 | found_difference = True |
| 216 | |
| 217 | if "cmdline" in attrs: |
| 218 | output_to_command_line_before = _map_output_files_to_command_line( |
| 219 | before_proto.actions, action_to_output_files_before) |
| 220 | output_to_command_line_after = _map_output_files_to_command_line( |
| 221 | after_proto.actions, action_to_output_files_after) |
| 222 | for output_files in output_to_command_line_before: |
| 223 | arguments = output_to_command_line_before[output_files] |
| 224 | after_arguments = output_to_command_line_after.get(output_files, None) |
| 225 | if after_arguments and arguments != after_arguments: |
| 226 | _print_diff(output_files, arguments, after_arguments, "cmdline", |
| 227 | before_file, after_file) |
| 228 | found_difference = True |
| 229 | |
| 230 | if "inputs" in attrs: |
| 231 | output_to_input_files_before = _map_output_files_to_input_artifacts( |
| 232 | before_proto, artifacts_before, action_to_output_files_before) |
| 233 | output_to_input_files_after = _map_output_files_to_input_artifacts( |
| 234 | after_proto, artifacts_after, action_to_output_files_after) |
| 235 | for output_files in output_to_input_files_before: |
| 236 | before_inputs = output_to_input_files_before[output_files] |
| 237 | after_inputs = output_to_input_files_after.get(output_files, None) |
| 238 | if after_inputs and before_inputs != after_inputs: |
| 239 | _print_diff(output_files, before_inputs, after_inputs, "inputs", |
| 240 | before_file, after_file) |
| 241 | found_difference = True |
| 242 | |
| 243 | if not found_difference: |
no test coverage detected