From a2067f8dfe90536bc3e580076d62df8422b804b6 Mon Sep 17 00:00:00 2001 From: Bartosz Polaczyk Date: Sat, 26 Feb 2022 16:19:37 +0100 Subject: [PATCH] Add unit test --- .../XCRemoteCacheTests/Commands/XCCCTests.swift | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/Tests/XCRemoteCacheTests/Commands/XCCCTests.swift b/Tests/XCRemoteCacheTests/Commands/XCCCTests.swift index 50bb158..b73d49d 100644 --- a/Tests/XCRemoteCacheTests/Commands/XCCCTests.swift +++ b/Tests/XCRemoteCacheTests/Commands/XCCCTests.swift @@ -332,11 +332,27 @@ class TemplateBasedCCWrapperBuilderTests: FileXCTestCase { XCTAssertNotEqual(newFileOutputData, Data()) } + func testPCHCompilationFallbacks() throws { + // Marker is empty to mimic the new file scenario + let pchFile = directory.appendingPathComponent("input.pch") + createValidPCCFile(pchFile) + arguments = ["-x", "objective-c-header", "-MF", dependencyFile.path, "-o", outputFile.path, pchFile.path] + + try shellExec(Self.xccc.path, args: arguments, inDir: directory.path) + + XCTAssertTrue(fileManager.fileExists(atPath: outputFile.path)) + } + /// Creates a simple C code in the location private func createValidCFile(_ location: URL) { fileManager.createFile(atPath: location.path, contents: "int main(){}".data(using: .utf8), attributes: nil) } + /// Creates a simple PCH code in the location + private func createValidPCCFile(_ location: URL) { + fileManager.createFile(atPath: location.path, contents: "#import ".data(using: .utf8), attributes: nil) + } + /// Creates a C code that requires extra CUSTOM_STR clang macro to compile private func createInvalidCFile(_ location: URL) { fileManager.createFile(