Skip to content

Commit 8d50cd8

Browse files
authored
fix: support --uninstall for all clang-tools (#103)
* fix: support uninstall all clang-tools * fix: update tests * fix: update tests * fix: update python-test.yml
1 parent 7d78b27 commit 8d50cd8

File tree

4 files changed

+13
-11
lines changed

4 files changed

+13
-11
lines changed

.github/workflows/python-test.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ jobs:
119119
shell: bash
120120
run: |
121121
case "${{ matrix.version }}" in
122-
15|16)
122+
15|16|18)
123123
clang-format.exe --version
124124
clang-tidy.exe --version
125125
clang-query.exe --version

clang_tools/install.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,7 @@ def uninstall_tool(tool_name: str, version: str, directory: str):
234234
symlink.unlink()
235235

236236

237-
def uninstall_clang_tools(version: str, directory: str):
237+
def uninstall_clang_tools(tools: str, version: str, directory: str):
238238
"""Uninstall a clang tool of a given version.
239239
240240
:param version: The version of the clang-tools to remove.
@@ -243,7 +243,7 @@ def uninstall_clang_tools(version: str, directory: str):
243243
"""
244244
install_dir = install_dir_name(directory)
245245
print(f"Uninstalling version {version} from {str(install_dir)}")
246-
for tool in ("clang-format", "clang-tidy"):
246+
for tool in tools:
247247
uninstall_tool(tool, version, install_dir)
248248

249249

clang_tools/main.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ def main():
6868
args = parser.parse_args()
6969

7070
if args.uninstall:
71-
uninstall_clang_tools(args.uninstall, args.directory)
71+
uninstall_clang_tools(args.uninstall, args.tool, args.directory)
7272
elif args.install:
7373
version = Version(args.install)
7474
if version.info != (0, 0, 0):

tests/test_install.py

+9-7
Original file line numberDiff line numberDiff line change
@@ -55,20 +55,22 @@ def test_create_symlink(monkeypatch: pytest.MonkeyPatch, tmp_path: Path):
5555
assert not create_sym_link(tool_name, version, str(tmp_path), True)
5656

5757

58+
@pytest.mark.parametrize(
59+
"tool_name",
60+
["clang-format", "clang-tidy", "clang-query", "clang-apply-replacements"],
61+
)
5862
@pytest.mark.parametrize("version", ["12"])
59-
def test_install_tools(monkeypatch: pytest.MonkeyPatch, tmp_path: Path, version: str):
63+
def test_install_tools(
64+
monkeypatch: pytest.MonkeyPatch, tmp_path: Path, tool_name: str, version: str
65+
):
6066
"""Test install tools to a temp directory."""
6167
monkeypatch.chdir(tmp_path)
62-
tool_name = "clang-format"
63-
6468
assert install_tool(tool_name, version, str(tmp_path), False)
6569
# invoking again should return False
6670
assert not install_tool(tool_name, version, str(tmp_path), False)
6771
# uninstall the tool deliberately
68-
uninstall_clang_tools(version, str(tmp_path))
69-
assert f"{tool_name}-{version}{suffix}" not in [
70-
fd.name for fd in tmp_path.iterdir()
71-
]
72+
uninstall_clang_tools(tool_name, version, str(tmp_path))
73+
assert f"{tool_name}-{version}{suffix}" in [fd.name for fd in tmp_path.iterdir()]
7274

7375

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

0 commit comments

Comments
 (0)