Skip to content

fix: support --uninstall for all clang-tools #103

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Aug 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/python-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ jobs:
shell: bash
run: |
case "${{ matrix.version }}" in
15|16)
15|16|18)
clang-format.exe --version
clang-tidy.exe --version
clang-query.exe --version
Expand Down
4 changes: 2 additions & 2 deletions clang_tools/install.py
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ def uninstall_tool(tool_name: str, version: str, directory: str):
symlink.unlink()


def uninstall_clang_tools(version: str, directory: str):
def uninstall_clang_tools(tools: str, version: str, directory: str):
"""Uninstall a clang tool of a given version.

:param version: The version of the clang-tools to remove.
Expand All @@ -243,7 +243,7 @@ def uninstall_clang_tools(version: str, directory: str):
"""
install_dir = install_dir_name(directory)
print(f"Uninstalling version {version} from {str(install_dir)}")
for tool in ("clang-format", "clang-tidy"):
for tool in tools:
uninstall_tool(tool, version, install_dir)


Expand Down
2 changes: 1 addition & 1 deletion clang_tools/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ def main():
args = parser.parse_args()

if args.uninstall:
uninstall_clang_tools(args.uninstall, args.directory)
uninstall_clang_tools(args.uninstall, args.tool, args.directory)
elif args.install:
version = Version(args.install)
if version.info != (0, 0, 0):
Expand Down
16 changes: 9 additions & 7 deletions tests/test_install.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,20 +55,22 @@ def test_create_symlink(monkeypatch: pytest.MonkeyPatch, tmp_path: Path):
assert not create_sym_link(tool_name, version, str(tmp_path), True)


@pytest.mark.parametrize(
"tool_name",
["clang-format", "clang-tidy", "clang-query", "clang-apply-replacements"],
)
@pytest.mark.parametrize("version", ["12"])
def test_install_tools(monkeypatch: pytest.MonkeyPatch, tmp_path: Path, version: str):
def test_install_tools(
monkeypatch: pytest.MonkeyPatch, tmp_path: Path, tool_name: str, version: str
):
"""Test install tools to a temp directory."""
monkeypatch.chdir(tmp_path)
tool_name = "clang-format"

assert install_tool(tool_name, version, str(tmp_path), False)
# invoking again should return False
assert not install_tool(tool_name, version, str(tmp_path), False)
# uninstall the tool deliberately
uninstall_clang_tools(version, str(tmp_path))
assert f"{tool_name}-{version}{suffix}" not in [
fd.name for fd in tmp_path.iterdir()
]
uninstall_clang_tools(tool_name, version, str(tmp_path))
assert f"{tool_name}-{version}{suffix}" in [fd.name for fd in tmp_path.iterdir()]


@pytest.mark.parametrize("version", ["0"])
Expand Down