mirror of
https://github.com/unclebob/crapper.git
synced 2026-11-26 18:18:49 +00:00
Drop -format=json so Apple LLVM 21 can export Swift coverage.
Apple's llvm-cov rejects -format=json with "Cannot find option named 'json'". The default export is already JSON, so swift_export_command omits the flag. Proved by test_swift_export_uses_the_default_json_format and the package export test. Co-authored-by: Robert C. Martin <[email protected]>
This commit is contained in:
co-authored by
Robert C. Martin
parent
5e7cbcd431
commit
7391131886
@@ -555,7 +555,13 @@ def swift_test_command() -> list[str]:
|
|||||||
|
|
||||||
|
|
||||||
def swift_export_command(tool: str, binary: Path, profdata: Path) -> list[str]:
|
def swift_export_command(tool: str, binary: Path, profdata: Path) -> list[str]:
|
||||||
return [tool, "export", "-format=json", f"-instr-profile={profdata}", str(binary)]
|
"""argv for llvm-cov's default export, which is JSON.
|
||||||
|
|
||||||
|
Apple LLVM 21 rejects `-format=json` (`Cannot find option named 'json'`).
|
||||||
|
Its default export already writes `llvm.coverage.json.export`.
|
||||||
|
"""
|
||||||
|
|
||||||
|
return [tool, "export", f"-instr-profile={profdata}", str(binary)]
|
||||||
|
|
||||||
|
|
||||||
def xcode_export_command(result: Path) -> list[str]:
|
def xcode_export_command(result: Path) -> list[str]:
|
||||||
|
|||||||
+11
-2
@@ -5,7 +5,7 @@ from pathlib import Path
|
|||||||
from crapper.cli import run
|
from crapper.cli import run
|
||||||
from crapper.discover import is_test_file, iter_source_files
|
from crapper.discover import is_test_file, iter_source_files
|
||||||
from crapper.languages.swift import functions_in_source
|
from crapper.languages.swift import functions_in_source
|
||||||
from crapper.runners import run_coverage
|
from crapper.runners import run_coverage, swift_export_command
|
||||||
|
|
||||||
_FIXTURES = Path(__file__).parent / "fixtures" / "swift"
|
_FIXTURES = Path(__file__).parent / "fixtures" / "swift"
|
||||||
_BOX = (_FIXTURES / "Box.swift").read_text(encoding="utf-8")
|
_BOX = (_FIXTURES / "Box.swift").read_text(encoding="utf-8")
|
||||||
@@ -336,6 +336,16 @@ def _plant(root: Path, relative: str, source: str = "") -> Path:
|
|||||||
return path
|
return path
|
||||||
|
|
||||||
|
|
||||||
|
def test_swift_export_uses_the_default_json_format():
|
||||||
|
command = swift_export_command("llvm-cov", Path("DemoTests"), Path("default.profdata"))
|
||||||
|
assert command == [
|
||||||
|
"llvm-cov",
|
||||||
|
"export",
|
||||||
|
"-instr-profile=default.profdata",
|
||||||
|
"DemoTests",
|
||||||
|
]
|
||||||
|
|
||||||
|
|
||||||
def test_a_swift_package_exports_llvm_cov_json(tmp_path, monkeypatch, capsys):
|
def test_a_swift_package_exports_llvm_cov_json(tmp_path, monkeypatch, capsys):
|
||||||
_plant(tmp_path, "Package.swift", "// swift-tools-version: 5.9\n")
|
_plant(tmp_path, "Package.swift", "// swift-tools-version: 5.9\n")
|
||||||
source = _plant(tmp_path, "Sources/Demo/Box.swift", "func open() {}\n")
|
source = _plant(tmp_path, "Sources/Demo/Box.swift", "func open() {}\n")
|
||||||
@@ -369,7 +379,6 @@ def test_a_swift_package_exports_llvm_cov_json(tmp_path, monkeypatch, capsys):
|
|||||||
[
|
[
|
||||||
"/usr/bin/llvm-cov",
|
"/usr/bin/llvm-cov",
|
||||||
"export",
|
"export",
|
||||||
"-format=json",
|
|
||||||
f"-instr-profile={profdata}",
|
f"-instr-profile={profdata}",
|
||||||
str(binary),
|
str(binary),
|
||||||
]
|
]
|
||||||
|
|||||||
Reference in New Issue
Block a user