Name a Swift module after the workspace when both bundles exist.

Coverage already runs the .xcworkspace instead of the .xcodeproj beside
it, but the module name came from the project. A file next to
Proj.xcodeproj and Work.xcworkspace was Demo'd as Proj.ContentView.
The namer now checks the workspace first, and that test expects
Work.ContentView. A directory with only a project is unchanged.

Co-authored-by: Robert C. Martin <[email protected]>
This commit is contained in:
Cursor Agent
2026-11-26 00:02:40 +00:00
co-authored by Robert C. Martin
parent c69b49dea5
commit 95c17c42ab
3 changed files with 16 additions and 4 deletions
+11
View File
@@ -244,6 +244,17 @@ def test_package_and_xcode_names_are_the_module(tmp_path):
assert [(fn.namespace, fn.name) for fn in ios] == [("IOS.ContentView", "body")]
def test_a_workspace_names_the_module_when_a_project_is_beside_it(tmp_path):
(tmp_path / "Proj.xcodeproj").mkdir()
(tmp_path / "Work.xcworkspace").mkdir()
functions = functions_in_source(
"struct ContentView { func body() {} }\n",
"App/ContentView.swift",
str(tmp_path),
)
assert [(fn.namespace, fn.name) for fn in functions] == [("Work.ContentView", "body")]
def test_a_commented_target_does_not_name_the_module(tmp_path):
(tmp_path / "Package.swift").write_text(
"\n".join(