in tools/migration/ctoolchain_comparator_lib.py [0:0]
def _compare_features(features_before, features_after):
"""Compares two "CToolchain.FlagFeature" lists."""
feature_name_to_feature_before = {}
feature_name_to_feature_after = {}
for feature in features_before:
feature_name_to_feature_before[feature.name] = feature
for feature in features_after:
feature_name_to_feature_after[feature.name] = feature
feature_names_before = set(feature_name_to_feature_before.keys())
feature_names_after = set(feature_name_to_feature_after.keys())
before_after_diff = feature_names_before - feature_names_after
after_before_diff = feature_names_after - feature_names_before
diff_string = "Difference in 'feature' field:"
found_difference = False
if before_after_diff:
if not found_difference:
print(diff_string) # pylint: disable=superfluous-parens
found_difference = True
print(("* List before change contains entries for the following features "
"that the list after the change doesn't:\n%s") % _array_to_string(
before_after_diff, ordered=True))
if after_before_diff:
if not found_difference:
print(diff_string) # pylint: disable=superfluous-parens
found_difference = True
print(("* List after change contains entries for the following features "
"that the list before the change doesn't:\n%s") % _array_to_string(
after_before_diff, ordered=True))
names_before = [feature.name for feature in features_before]
names_after = [feature.name for feature in features_after]
if names_before != names_after:
if not found_difference:
print(diff_string) # pylint: disable=superfluous-parens
found_difference = True
print(("Features not in right order:\n"
"* List of features before change:\t%s"
"* List of features before change:\t%s") %
(_array_to_string(names_before), _array_to_string(names_after)))
for name in feature_name_to_feature_before:
feature_before = feature_name_to_feature_before[name]
feature_after = feature_name_to_feature_after.get(name, None)
if feature_after and not _check_feature_equivalence(feature_before,
feature_after):
if not found_difference:
print(diff_string) # pylint: disable=superfluous-parens
found_difference = True
print(("* Feature '%s' differs before and after the change:\n"
"Value before change:\n%s\n"
"Value after change:\n%s") % (name, str(feature_before),
str(feature_after)))
if found_difference:
print("") # pylint: disable=superfluous-parens
return found_difference