Skip to content

Commit d47e4f5

Browse files
committed
refactor: remove testSupport from generated interface modules
The tool was creating an empty TestSupport/ directory and keeping .testSupport() in the interface module's features with no content. Remove both since they serve no purpose.
1 parent ddb784b commit d47e4f5

3 files changed

Lines changed: 4 additions & 6 deletions

File tree

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ Given a module name and its compiler arguments, the tool:
1717
1. **Extracts the module interface** via SourceKit (the same engine Xcode uses for code completion and indexing)
1818
2. **Rewrites the interface** using SwiftSyntax - strips private/internal imports (prefixed with `_`), removes `some`/`any` type erasure wrappers, simplifies member type syntax, filters out builder classes, and merges duplicate extensions
1919
3. **Replaces declarations** with their original source versions when available (preserving doc comments, attributes, and formatting)
20-
4. **Creates the interface module directory** with `Sources/` and `TestSupport/` folders
20+
4. **Creates the interface module directory** with a `Sources/` folder
2121
5. **Rewrites import statements** across the codebase (`import Module` -> `import ModuleInterface`)
2222
6. **Updates Project.swift** to register the new interface module with the correct dependencies (Tuist-specific)
2323

@@ -54,7 +54,7 @@ cd SampleProject
5454
The script builds the tool, compiles a sample Swift module via SPM, extracts compiler arguments, and runs the tool. Use `--write` to execute the full pipeline, or omit it to preview with `--print-only`.
5555

5656
After running with `--write`, you'll see:
57-
- `libraries/business/UserProfileInterface/` created with `Sources/` and `TestSupport/`
57+
- `libraries/business/UserProfileInterface/` created with `Sources/`
5858
- `Project.swift` updated with the new interface module declaration
5959

6060
To reset the sample project after a full run:

Sources/FileOps.swift

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,9 @@ func createInterfaceModuleDirectoryWithSource(_ directory: String, moduleName: S
2222
let interfacePath = firstLevelPath
2323
let interfaceFolder = (interfacePath as NSString).appendingPathComponent("\(moduleName)Interface")
2424
let sourcesFolder = (interfaceFolder as NSString).appendingPathComponent("Sources")
25-
let testSupportFolder = (interfaceFolder as NSString).appendingPathComponent("TestSupport")
26-
25+
2726
try createDirectoryIfNeeded(at: interfaceFolder)
2827
try createDirectoryIfNeeded(at: sourcesFolder)
29-
try createDirectoryIfNeeded(at: testSupportFolder)
3028

3129
let filePath = (sourcesFolder as NSString).appendingPathComponent("\(moduleName)Interface.swift")
3230
try createFile(at: filePath, withContent: fileContent)

Sources/ProjectRewriter.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ private class ProjectRewriter: SyntaxRewriter {
129129
featuresArray.elements.filter { element in
130130
if let functionCall = element.expression.as(FunctionCallExprSyntax.self) {
131131
let functionName = functionCall.calledExpression.as(MemberAccessExprSyntax.self)?.name.text
132-
return functionName != "snapshotTests" && functionName != "tests"
132+
return functionName != "snapshotTests" && functionName != "tests" && functionName != "testSupport"
133133
}
134134
return true
135135
}

0 commit comments

Comments
 (0)