diff --git a/tools/migration/ctoolchain_comparator_lib.py b/tools/migration/ctoolchain_comparator_lib.py index 0adefd3a..eb47305e 100644 --- a/tools/migration/ctoolchain_comparator_lib.py +++ b/tools/migration/ctoolchain_comparator_lib.py @@ -52,6 +52,11 @@ def _check_with_feature_set_equivalence(before, after): def _check_tool_equivalence(before, after): + """Compares two "CToolchain.Tool"s.""" + if before.tool_path == "NOT_USED": + before.tool_path = "" + if after.tool_path == "NOT_USED": + after.tool_path = "" if before.tool_path != after.tool_path: return False if set(before.execution_requirement) != set(after.execution_requirement): @@ -297,9 +302,11 @@ def _compare_tool_paths(tool_paths_before, tool_paths_after): tool_to_path_before = {} tool_to_path_after = {} for tool_path in tool_paths_before: - tool_to_path_before[tool_path.name] = tool_path.path + tool_to_path_before[tool_path.name] = ( + tool_path.path if tool_path.path != "NOT_USED" else "") for tool_path in tool_paths_after: - tool_to_path_after[tool_path.name] = tool_path.path + tool_to_path_after[tool_path.name] = ( + tool_path.path if tool_path.path != "NOT_USED" else "") tool_names_before = set(tool_to_path_before.keys()) tool_names_after = set(tool_to_path_after.keys()) diff --git a/tools/migration/ctoolchain_comparator_lib_test.py b/tools/migration/ctoolchain_comparator_lib_test.py index 06645b0a..c81ff478 100644 --- a/tools/migration/ctoolchain_comparator_lib_test.py +++ b/tools/migration/ctoolchain_comparator_lib_test.py @@ -1665,6 +1665,45 @@ def test_action_config_implies_preserves_order(self): self.assertIn("* Action config 'config' differs before and after", mock_stdout.getvalue()) + def test_unused_tool_path(self): + first = make_toolchain(""" + tool_path { + name: "empty" + path: "" + } + """) + second = make_toolchain(""" + tool_path { + name: "empty" + path: "NOT_USED" + } + """) + mock_stdout = StringIO() + with mock.patch("sys.stdout", mock_stdout): + compare_ctoolchains(first, second) + self.assertIn("No difference", mock_stdout.getvalue()) + + def test_unused_tool_path_in_tool(self): + first = make_toolchain(""" + action_config { + config_name: 'config' + tool { + tool_path: '' + } + } + """) + second = make_toolchain(""" + action_config { + config_name: 'config' + tool { + tool_path: 'NOT_USED' + } + } + """) + mock_stdout = StringIO() + with mock.patch("sys.stdout", mock_stdout): + compare_ctoolchains(first, second) + self.assertIn("No difference", mock_stdout.getvalue()) if __name__ == "__main__": unittest.main()