diff --git a/Sources/Build/SwiftCompilerOutputParser.swift b/Sources/Build/SwiftCompilerOutputParser.swift index fad652f645a..25fd712d41d 100644 --- a/Sources/Build/SwiftCompilerOutputParser.swift +++ b/Sources/Build/SwiftCompilerOutputParser.swift @@ -162,7 +162,7 @@ extension SwiftCompilerOutputParser: JSONMessageStreamingParserDelegate { return } - let message = SwiftCompilerMessage(name: "unknown", kind: .unparsableOutput(text)) + let message = SwiftCompilerMessage(name: "unknown", kind: .unparsableOutput(text + "\n")) delegate?.swiftCompilerOutputParser(self, didParse: message) } diff --git a/Tests/BuildTests/SwiftCompilerOutputParserTests.swift b/Tests/BuildTests/SwiftCompilerOutputParserTests.swift index be6498dcb06..89990daf851 100644 --- a/Tests/BuildTests/SwiftCompilerOutputParserTests.swift +++ b/Tests/BuildTests/SwiftCompilerOutputParserTests.swift @@ -156,7 +156,7 @@ class SwiftCompilerOutputParserTests: XCTestCase { """.utf8) delegate.assert(messages: [ - SwiftCompilerMessage(name: "unknown", kind: .unparsableOutput("2A")) + SwiftCompilerMessage(name: "unknown", kind: .unparsableOutput("2A\n")) ], errorDescription: nil) parser.parse(bytes: """ diff --git a/Tests/CommandsTests/BuildToolTests.swift b/Tests/CommandsTests/BuildToolTests.swift index ed7314143d9..ecba693e327 100644 --- a/Tests/CommandsTests/BuildToolTests.swift +++ b/Tests/CommandsTests/BuildToolTests.swift @@ -390,4 +390,16 @@ final class BuildToolTests: CommandsTestCase { XCTAssertMatch(output, .prefix("digraph Jobs {")) } } + + func testSwiftDriverRawOutputGetsNewlines() throws { + try fixture(name: "DependencyResolution/Internal/Simple") { fixturePath in + // Building with `-wmo` should result in a `remark: Incremental compilation has been disabled: it is not compatible with whole module optimization` message, which should have a trailing newline. Since that message won't be there at all when the legacy compiler driver is used, we gate this check on whether the remark is there in the first place. + let result = try execute(["-c", "release", "-Xswiftc", "-wmo"], packagePath: fixturePath) + if result.stdout.contains("remark: Incremental compilation has been disabled: it is not compatible with whole module optimization") { + XCTAssertMatch(result.stdout, .contains("optimization\n")) + XCTAssertNoMatch(result.stdout, .contains("optimization[")) + XCTAssertNoMatch(result.stdout, .contains("optimizationremark")) + } + } + } }